{
  "openapi": "3.0.3",
  "info": {
    "title": "CivicDrones Operations Authority Partner API",
    "version": "4.3.1",
    "description": "Partner flight, fleet telemetry, mission, and airspace operations APIs."
  },
  "servers": [
    {"url": "https://api.civicdrones.org", "description": "Production API gateway"},
    {"url": "https://partner-api.civicdrones.org", "description": "Production partner API"}
  ],
  "paths": {
    "/api/v1/partners/{partnerId}/settlements": {
      "get": {
        "summary": "List partner settlement batches",
        "security": [{"bearerAuth": []}, {"partnerKey": []}],
        "parameters": [
          {"name": "partnerId", "in": "path", "required": true, "schema": {"type": "string"}},
          {"name": "date", "in": "query", "schema": {"type": "string", "format": "date"}}
        ],
        "responses": {"200": {"description": "Settlement batch list"}}
      }
    },
    "/api/v1/payments/quote": {
      "post": {
        "summary": "Create a payment quote",
        "security": [{"bearerAuth": []}],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {"$ref": "#/components/schemas/PaymentQuoteRequest"}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Quote response",
            "content": {
              "application/json": {
                "schema": {"$ref": "#/components/schemas/PaymentQuoteResponse"}
              }
            }
          }
        }
      }
    },
    "/api/v1/webhooks": {
      "get": {
        "summary": "List registered partner webhooks",
        "security": [{"bearerAuth": []}, {"partnerKey": []}],
        "responses": {"200": {"description": "Registered webhook list"}}
      },
      "post": {
        "summary": "Register a partner settlement webhook",
        "security": [{"bearerAuth": []}, {"partnerKey": []}],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {"$ref": "#/components/schemas/WebhookRegistrationRequest"}
            }
          }
        },
        "responses": {"201": {"description": "Webhook registered"}}
      }
    },
    "/api/v1/partners/{partnerId}/kyc-status": {
      "get": {
        "summary": "Return partner KYC status summary",
        "security": [{"bearerAuth": []}],
        "parameters": [
          {"name": "partnerId", "in": "path", "required": true, "schema": {"type": "string"}}
        ],
        "responses": {"200": {"description": "KYC status response"}}
      }
    },
    "/api/v1/treasury/limits": {
      "get": {
        "summary": "Return treasury exposure limits",
        "x-internal-owner": "treasury-risk-platform",
        "x-runbook": "vault://platform/partner-api/prod/payments-readonly",
        "responses": {"200": {"description": "Treasury limit response"}}
      }
    },
    "/graphql": {
      "post": {
        "summary": "Partner GraphQL query endpoint",
        "responses": {"200": {"description": "GraphQL response"}}
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {"type": "http", "scheme": "bearer", "bearerFormat": "JWT"},
      "partnerKey": {"type": "apiKey", "in": "header", "name": "x-partner-key"}
    },
    "schemas": {
      "PaymentQuoteRequest": {
        "type": "object",
        "required": ["sourceCurrency", "destinationCurrency", "amountMinor", "partnerId"],
        "properties": {
          "partnerId": {"type": "string", "example": "cdoa-partner-0421"},
          "sourceCurrency": {"type": "string", "example": "USD"},
          "destinationCurrency": {"type": "string", "example": "CAD"},
          "amountMinor": {"type": "integer", "format": "int64", "example": 125000}
        }
      },
      "PaymentQuoteResponse": {
        "type": "object",
        "properties": {
          "quoteId": {"type": "string", "example": "qt_01JY9K5VAMR9YZS4A20S8Y22VP"},
          "expiresAt": {"type": "string", "format": "date-time"},
          "settlementRail": {"type": "string", "example": "same-day-ach"}
        }
      },
      "WebhookRegistrationRequest": {
        "type": "object",
        "required": ["callbackUrl", "eventTypes"],
        "properties": {
          "callbackUrl": {"type": "string", "format": "uri"},
          "eventTypes": {
            "type": "array",
            "items": {"type": "string"},
            "example": ["settlement.completed", "payment.quote.expired"]
          }
        }
      }
    }
  }
}
