{
  "openapi": "3.1.0",
  "info": {
    "title": "Storspay API",
    "version": "1.0.0-draft",
    "summary": "Accounts, transfers with escrow, collections and payouts for platforms and marketplaces.",
    "description": "Skeleton from the phase 1 spec (docs/specs/2026-11-16-developer-platform.md). Conventions:\ndocs/api/CONVENTIONS.md. These are the new routes. The September v1 payouts API (app.storspay.com/api/v1/,\nsk_ keys, numbers, `completed`) stays supported and deprecated, and is described separately. Every amount is a decimal string in major units. Every call that moves money needs a\n`clientRef`. StorsApp Inc. is a FINTRAC-registered money services business.\n",
    "contact": {
      "name": "Storspay support",
      "email": "info@storsapp.com"
    }
  },
  "servers": [
    {
      "url": "https://api.sandbox.storspay.com/v1",
      "description": "Sandbox (test money only)"
    },
    {
      "url": "https://api.storspay.com/v1",
      "description": "Live"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Auth"
    },
    {
      "name": "API keys"
    },
    {
      "name": "Accounts"
    },
    {
      "name": "Applications"
    },
    {
      "name": "Information requests"
    },
    {
      "name": "Ledger"
    },
    {
      "name": "Quotes"
    },
    {
      "name": "Conversions"
    },
    {
      "name": "Money in"
    },
    {
      "name": "Beneficiaries"
    },
    {
      "name": "Payouts"
    },
    {
      "name": "Transfers"
    },
    {
      "name": "Escrows",
      "description": "Escrow hold, release, and refund operations"
    },
    {
      "name": "Platform fees"
    },
    {
      "name": "Webhooks"
    },
    {
      "name": "Sandbox"
    }
  ],
  "paths": {
    "/oauth/token": {
      "post": {
        "tags": [
          "Auth"
        ],
        "operationId": "createToken",
        "summary": "Exchange a client ID and secret for an access token (24 h)",
        "security": [
          {
            "clientBasic": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "grant_type"
                ],
                "properties": {
                  "grant_type": {
                    "type": "string",
                    "const": "client_credentials"
                  },
                  "scope": {
                    "type": "string",
                    "description": "Space-separated subset of the key's scopes"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Access token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Token"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api-keys": {
      "get": {
        "tags": [
          "API keys"
        ],
        "operationId": "listApiKeys",
        "summary": "List API keys (metadata only; secrets are never returned)",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/ApiKeyList"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/api-keys/current": {
      "get": {
        "tags": [
          "API keys"
        ],
        "operationId": "getCurrentApiKey",
        "summary": "The key behind the calling token",
        "responses": {
          "200": {
            "description": "Key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKey"
                }
              }
            }
          }
        }
      }
    },
    "/api-keys/{id}/revoke": {
      "post": {
        "tags": [
          "API keys"
        ],
        "operationId": "revokeApiKey",
        "summary": "Revoke a key (create and rotate happen in the dashboard)",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Revoked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKey"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/accounts/me": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "operationId": "getMyAccount",
        "summary": "Your workspace",
        "responses": {
          "200": {
            "description": "Workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          }
        }
      }
    },
    "/accounts": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "operationId": "createAccount",
        "summary": "Open an account holder (individual or business) for one of your customers",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/AccountReplayed"
          },
          "201": {
            "$ref": "#/components/responses/AccountCreated"
          },
          "400": {
            "$ref": "#/components/responses/ValidationError"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      },
      "get": {
        "tags": [
          "Accounts"
        ],
        "operationId": "listAccounts",
        "summary": "List your account holders",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/AccountStatus"
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "individual",
                "business",
                "organisation"
              ]
            }
          },
          {
            "name": "clientRef",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/AccountList"
          }
        }
      }
    },
    "/accounts/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "tags": [
          "Accounts"
        ],
        "operationId": "getAccount",
        "responses": {
          "200": {
            "description": "Account holder",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "tags": [
          "Accounts"
        ],
        "operationId": "updateAccount",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Accounts"
        ],
        "operationId": "closeAccount",
        "summary": "Close an account holder (balance must be zero)",
        "responses": {
          "200": {
            "description": "Closed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/accounts/{id}/freeze": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "operationId": "freezeAccount",
        "summary": "Freeze your account holder (blocks new movements from it)",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Frozen",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          }
        }
      }
    },
    "/accounts/{id}/unfreeze": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "operationId": "unfreezeAccount",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Active again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          }
        }
      }
    },
    "/accounts/{id}/requirements": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "operationId": "getAccountRequirements",
        "summary": "What the account's verification still needs",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Requirements"
          }
        }
      }
    },
    "/applications": {
      "get": {
        "tags": [
          "Applications"
        ],
        "operationId": "listApplications",
        "summary": "List your applications (ordered by id)",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "accountId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Applications",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Application"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Applications"
        ],
        "operationId": "createApplication",
        "summary": "Open a verification application (KYB or KYC) for an account",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "accountId"
                ],
                "properties": {
                  "accountId": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Application",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Application"
                }
              }
            }
          }
        }
      }
    },
    "/applications/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "tags": [
          "Applications"
        ],
        "operationId": "getApplication",
        "responses": {
          "200": {
            "description": "Application",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Application"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Applications"
        ],
        "operationId": "updateApplication",
        "summary": "Save answers (any time; resume later)",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Application"
                }
              }
            }
          }
        }
      }
    },
    "/applications/{id}/persons": {
      "post": {
        "tags": [
          "Applications"
        ],
        "operationId": "addPerson",
        "summary": "Add a director or shareholder",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Person"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Person",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Person"
                }
              }
            }
          }
        }
      }
    },
    "/applications/{id}/persons/{personId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        },
        {
          "name": "personId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "patch": {
        "tags": [
          "Applications"
        ],
        "operationId": "updatePerson",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Person"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Person",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Person"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Applications"
        ],
        "operationId": "removePerson",
        "responses": {
          "204": {
            "description": "Removed"
          }
        }
      }
    },
    "/applications/{id}/documents": {
      "post": {
        "tags": [
          "Applications"
        ],
        "operationId": "createDocumentUpload",
        "summary": "Get a pre-signed upload URL (PDF, JPG or PNG, up to 10 MB)",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "type",
                  "contentType"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "examples": [
                      "certificate_of_incorporation",
                      "pharmacy_licence",
                      "proof_of_address"
                    ]
                  },
                  "contentType": {
                    "type": "string",
                    "enum": [
                      "application/pdf",
                      "image/jpeg",
                      "image/png"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Upload URL",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "documentId": {
                      "type": "string"
                    },
                    "uploadUrl": {
                      "type": "string",
                      "format": "uri"
                    },
                    "expiresAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/applications/{id}/verification-links": {
      "post": {
        "tags": [
          "Applications"
        ],
        "operationId": "createVerificationLink",
        "summary": "Hosted verification link (single use, 7 days)",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "returnUrl"
                ],
                "properties": {
                  "returnUrl": {
                    "type": "string",
                    "format": "uri"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Link",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "expiresAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/applications/{id}/submit": {
      "post": {
        "tags": [
          "Applications"
        ],
        "operationId": "submitApplication",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Submitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Application"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/applications/{id}/requirements": {
      "get": {
        "tags": [
          "Applications"
        ],
        "operationId": "getApplicationRequirements",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Requirements"
          }
        }
      }
    },
    "/information-requests": {
      "get": {
        "tags": [
          "Information requests"
        ],
        "operationId": "listInformationRequests",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Information requests",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/InformationRequest"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/information-requests/{id}": {
      "get": {
        "tags": [
          "Information requests"
        ],
        "operationId": "getInformationRequest",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Information request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InformationRequest"
                }
              }
            }
          }
        }
      }
    },
    "/information-requests/{id}/responses": {
      "post": {
        "tags": [
          "Information requests"
        ],
        "operationId": "respondInformationRequest",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "answers": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "documentIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InformationRequest"
                }
              }
            }
          }
        }
      }
    },
    "/balances": {
      "get": {
        "tags": [
          "Ledger"
        ],
        "operationId": "listBalances",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "Balances per currency",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Balance"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/balances/closing": {
      "get": {
        "tags": [
          "Ledger"
        ],
        "operationId": "getClosingBalances",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          },
          {
            "name": "date",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Closing balances at the end of that UTC day",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "date": {
                      "type": "string",
                      "format": "date"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Money"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/transactions": {
      "get": {
        "tags": [
          "Ledger"
        ],
        "operationId": "listTransactions",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Ledger entries",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/LedgerTransaction"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/transactions/{id}": {
      "get": {
        "tags": [
          "Ledger"
        ],
        "operationId": "getTransaction",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Ledger entry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LedgerTransaction"
                }
              }
            }
          }
        }
      }
    },
    "/statements": {
      "get": {
        "tags": [
          "Ledger"
        ],
        "operationId": "listStatements",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          },
          {
            "name": "month",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Monthly statements",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Statement"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/statements/{id}": {
      "get": {
        "tags": [
          "Ledger"
        ],
        "operationId": "getStatement",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Statement",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Statement"
                }
              }
            }
          }
        }
      }
    },
    "/quotes": {
      "post": {
        "tags": [
          "Quotes"
        ],
        "operationId": "createQuote",
        "summary": "Single-use, intent-locked quote with expiresAt",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Quote"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ValidationError"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/quotes/{id}": {
      "get": {
        "tags": [
          "Quotes"
        ],
        "operationId": "getQuote",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Quote"
                }
              }
            }
          }
        }
      }
    },
    "/conversions/pairs": {
      "get": {
        "tags": [
          "Conversions"
        ],
        "operationId": "listConversionPairs",
        "responses": {
          "200": {
            "description": "Pairs available",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "from": {
                            "$ref": "#/components/schemas/Currency"
                          },
                          "to": {
                            "$ref": "#/components/schemas/Currency"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/conversions": {
      "post": {
        "tags": [
          "Conversions"
        ],
        "operationId": "createConversion",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "quoteId",
                  "clientRef"
                ],
                "properties": {
                  "quoteId": {
                    "type": "string"
                  },
                  "clientRef": {
                    "$ref": "#/components/schemas/ClientRef"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Conversion",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversion"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      },
      "get": {
        "tags": [
          "Conversions"
        ],
        "operationId": "listConversions",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Conversions",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Conversion"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/conversions/{id}": {
      "get": {
        "tags": [
          "Conversions"
        ],
        "operationId": "getConversion",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Conversion",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversion"
                }
              }
            }
          }
        }
      }
    },
    "/deposits": {
      "get": {
        "tags": [
          "Money in"
        ],
        "operationId": "listDeposits",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Deposits",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Deposit"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/deposits/{id}": {
      "get": {
        "tags": [
          "Money in"
        ],
        "operationId": "getDeposit",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Deposit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deposit"
                }
              }
            }
          }
        }
      }
    },
    "/virtual-accounts": {
      "get": {
        "tags": [
          "Money in"
        ],
        "operationId": "listVirtualAccounts",
        "summary": "Storspay Account details per currency",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "Account details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/VirtualAccount"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Money in"
        ],
        "operationId": "requestVirtualAccount",
        "summary": "Ask for account details in a currency. With holder, also opens an account holder (one call) and returns its verification link.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "currency"
                ],
                "properties": {
                  "currency": {
                    "type": "string",
                    "enum": [
                      "USD",
                      "EUR",
                      "GBP"
                    ]
                  },
                  "clientRef": {
                    "$ref": "#/components/schemas/ClientRef"
                  },
                  "accountId": {
                    "type": "string"
                  },
                  "holder": {
                    "$ref": "#/components/schemas/AccountCreate"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replay of the same clientRef",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VirtualAccount"
                }
              }
            }
          },
          "201": {
            "description": "Account details (pending_verification until the holder is approved)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VirtualAccount"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/virtual-accounts/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "tags": [
          "Money in"
        ],
        "operationId": "getVirtualAccount",
        "summary": "Account details with balance and holder summary",
        "responses": {
          "200": {
            "description": "Account details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VirtualAccount"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "tags": [
          "Money in"
        ],
        "operationId": "closeVirtualAccount",
        "summary": "Close (balance must be zero)",
        "responses": {
          "200": {
            "description": "Closed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VirtualAccount"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/virtual-accounts/{id}/transactions": {
      "get": {
        "tags": [
          "Money in"
        ],
        "operationId": "listVirtualAccountTransactions",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "The holder's ledger",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/LedgerTransaction"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/virtual-accounts/{id}/verification-link": {
      "post": {
        "tags": [
          "Money in"
        ],
        "operationId": "reissueVerificationLink",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "New hosted verification link",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "expiresAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/virtual-accounts/requirements": {
      "get": {
        "tags": [
          "Money in"
        ],
        "operationId": "getVirtualAccountRequirements",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          },
          {
            "name": "currency",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Currency"
            }
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Requirements"
          }
        }
      }
    },
    "/collections": {
      "post": {
        "tags": [
          "Money in"
        ],
        "operationId": "createCollection",
        "summary": "Get paid. The payer settles locally or by bank transfer.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CollectionCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replay of the same clientRef",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Collection"
                }
              }
            }
          },
          "201": {
            "description": "Collection with payment instructions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Collection"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      },
      "get": {
        "tags": [
          "Money in"
        ],
        "operationId": "listCollections",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/CollectionStatus"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Collections",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Collection"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/collections/{id}": {
      "get": {
        "tags": [
          "Money in"
        ],
        "operationId": "getCollection",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Collection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Collection"
                }
              }
            }
          }
        }
      }
    },
    "/collections/{id}/cancel": {
      "post": {
        "tags": [
          "Money in"
        ],
        "operationId": "cancelCollection",
        "summary": "Cancel while pending",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Collection"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/beneficiaries": {
      "post": {
        "tags": [
          "Beneficiaries"
        ],
        "operationId": "createBeneficiary",
        "summary": "Create a recipient. The same details return the existing one (deduplicated).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BeneficiaryCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Existing beneficiary with the same details (deduplicated true)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Beneficiary"
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Beneficiary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ValidationError"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "get": {
        "tags": [
          "Beneficiaries"
        ],
        "operationId": "listBeneficiaries",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Beneficiaries",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Beneficiary"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/beneficiaries/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "tags": [
          "Beneficiaries"
        ],
        "operationId": "getBeneficiary",
        "responses": {
          "200": {
            "description": "Beneficiary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Beneficiary"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Beneficiaries"
        ],
        "operationId": "updateBeneficiary",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BeneficiaryCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Beneficiary"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Beneficiaries"
        ],
        "operationId": "deleteBeneficiary",
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/banks": {
      "get": {
        "tags": [
          "Beneficiaries"
        ],
        "operationId": "listBanks",
        "summary": "Banks in a country with Storspay's stable bankCode",
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Country"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Banks",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "bankCode": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "country": {
                            "$ref": "#/components/schemas/Country"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/payouts/requirements": {
      "get": {
        "tags": [
          "Payouts"
        ],
        "operationId": "getPayoutRequirements",
        "summary": "Exact recipient and sender fields for a country, currency and route",
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Country"
            }
          },
          {
            "name": "currency",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Currency"
            }
          },
          {
            "name": "route",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Route"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Field requirements",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "individual": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FieldRequirement"
                      }
                    },
                    "business": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FieldRequirement"
                      }
                    },
                    "sender": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FieldRequirement"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/payouts": {
      "post": {
        "tags": [
          "Payouts"
        ],
        "operationId": "createPayout",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PayoutCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replay of the same clientRef",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payout"
                }
              }
            }
          },
          "201": {
            "description": "Payout created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payout"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ValidationError"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "get": {
        "tags": [
          "Payouts"
        ],
        "operationId": "listPayouts",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/PayoutStatus"
            }
          },
          {
            "name": "clientRef",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payouts",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Payout"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/payouts/batch": {
      "post": {
        "tags": [
          "Payouts"
        ],
        "operationId": "createPayoutBatch",
        "summary": "Up to 500 payouts, each with its own clientRef",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "items"
                ],
                "properties": {
                  "items": {
                    "type": "array",
                    "maxItems": 500,
                    "items": {
                      "$ref": "#/components/schemas/PayoutCreate"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Batch with per-item results",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayoutBatch"
                }
              }
            }
          }
        }
      }
    },
    "/payout-batches/{id}": {
      "get": {
        "tags": [
          "Payouts"
        ],
        "operationId": "getPayoutBatch",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Batch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayoutBatch"
                }
              }
            }
          }
        }
      }
    },
    "/payouts/{id}": {
      "get": {
        "tags": [
          "Payouts"
        ],
        "operationId": "getPayout",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Payout",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payout"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/payouts/{id}/cancel": {
      "post": {
        "tags": [
          "Payouts"
        ],
        "operationId": "cancelPayout",
        "summary": "Cancel while cancellable is true (created, or queued before hand-off)",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payout"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/transfers": {
      "post": {
        "tags": [
          "Transfers"
        ],
        "operationId": "createTransfer",
        "summary": "Move money between Storspay accounts (optionally into escrow), or cash out to a beneficiary. Paying a seller's Storspay Account is always a transfer; POST /payouts pays beneficiaries.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransferCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replay of the same clientRef",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Transfer"
                }
              }
            }
          },
          "201": {
            "description": "Transfer (completed, or held in escrow)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Transfer"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      },
      "get": {
        "tags": [
          "Transfers"
        ],
        "operationId": "listTransfers",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/TransferStatus"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transfers",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Transfer"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/transfers/{id}": {
      "get": {
        "tags": [
          "Transfers"
        ],
        "operationId": "getTransfer",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Transfer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Transfer"
                }
              }
            }
          }
        }
      }
    },
    "/transfers/{id}/release": {
      "post": {
        "tags": [
          "Transfers"
        ],
        "operationId": "releaseTransfer",
        "summary": "Release a held escrow to the destination account; optionally cash it out straight away",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "clientRef"
                ],
                "properties": {
                  "clientRef": {
                    "$ref": "#/components/schemas/ClientRef"
                  },
                  "cashOut": {
                    "type": "object",
                    "description": "Then pay the released amount out to this beneficiary of the destination account (a cash-out transfer)",
                    "properties": {
                      "beneficiaryId": {
                        "type": "string"
                      },
                      "quoteId": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Released",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Transfer"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/transfers/{id}/cancel": {
      "post": {
        "tags": [
          "Transfers"
        ],
        "operationId": "cancelTransfer",
        "summary": "Cancel a held escrow; the money returns to the source account (status refunded)",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "clientRef"
                ],
                "properties": {
                  "clientRef": {
                    "$ref": "#/components/schemas/ClientRef"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Refunded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Transfer"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/platform-fees": {
      "get": {
        "tags": [
          "Platform fees"
        ],
        "operationId": "getPlatformFees",
        "responses": {
          "200": {
            "description": "Fee rules",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlatformFeeRules"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Platform fees"
        ],
        "operationId": "setPlatformFees",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlatformFeeRules"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlatformFeeRules"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/platform-fees/earnings": {
      "get": {
        "tags": [
          "Platform fees"
        ],
        "operationId": "getPlatformFeeEarnings",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "day",
                "month",
                "account"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Earnings",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "period": {
                            "type": "string"
                          },
                          "accountId": {
                            "type": "string"
                          },
                          "earned": {
                            "$ref": "#/components/schemas/Money"
                          },
                          "count": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/webhook-endpoints": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "createWebhookEndpoint",
        "summary": "Register an endpoint; the signing secret is returned once",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url",
                  "events"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "description": "https and a public host only"
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "examples": [
                      [
                        "payout.*",
                        "transfer.released"
                      ]
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Endpoint, with signingSecret this one time",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/WebhookEndpoint"
                    },
                    {
                      "properties": {
                        "signingSecret": {
                          "type": "string",
                          "description": "whsec_… shown once"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "listWebhookEndpoints",
        "responses": {
          "200": {
            "description": "Endpoints",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookEndpoint"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/webhook-endpoints/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "getWebhookEndpoint",
        "responses": {
          "200": {
            "description": "Endpoint",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "updateWebhookEndpoint",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "enabled": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "deleteWebhookEndpoint",
        "responses": {
          "204": {
            "description": "Deleted"
          }
        }
      }
    },
    "/webhook-endpoints/{id}/rotate-secret": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "rotateWebhookSecret",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "overlapHours": {
                    "type": "integer",
                    "enum": [
                      0,
                      24
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "New secret, shown once",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "signingSecret": {
                      "type": "string"
                    },
                    "previousSecretExpiresAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/webhook-endpoints/{id}/test": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "sendTestEvent",
        "summary": "Sends webhook.test with \"test\" true",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "202": {
            "description": "Delivery queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDelivery"
                }
              }
            }
          }
        }
      }
    },
    "/webhook-deliveries": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "listWebhookDeliveries",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "endpointId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "succeeded",
                "failed"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deliveries",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/WebhookDelivery"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/webhook-deliveries/{id}": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "getWebhookDelivery",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Delivery with full payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDelivery"
                }
              }
            }
          }
        }
      }
    },
    "/webhook-deliveries/{id}/resend": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "resendWebhookDelivery",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "202": {
            "description": "New delivery queued for the same event",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDelivery"
                }
              }
            }
          }
        }
      }
    },
    "/events": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "listEvents",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Events of the last 30 days",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Page"
                    },
                    {
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Event"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/events/{id}": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "getEvent",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Event",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Event"
                }
              }
            }
          }
        }
      }
    },
    "/sandbox/deposits": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "operationId": "sandboxDeposit",
        "summary": "Add test money (sandbox only; 404 on live)",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "amount": {
                    "$ref": "#/components/schemas/Amount"
                  },
                  "currency": {
                    "$ref": "#/components/schemas/Currency"
                  },
                  "accountNumber": {
                    "type": "string"
                  },
                  "narration": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Deposit credited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deposit"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/sandbox/virtual-accounts/{id}/deposits": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "operationId": "sandboxDepositToAccountDetails",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "amount"
                ],
                "properties": {
                  "amount": {
                    "$ref": "#/components/schemas/Amount"
                  },
                  "narration": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Deposit credited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deposit"
                }
              }
            }
          }
        }
      }
    },
    "/sandbox/collections/{id}/pay": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "operationId": "sandboxPayCollection",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "scenario": {
                    "type": "string",
                    "enum": [
                      "paid_exact",
                      "paid_short",
                      "paid_over",
                      "returned",
                      "expired",
                      "late_paid"
                    ],
                    "default": "paid_exact"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Collection after the simulated payment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Collection"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/sandbox/payouts/{id}/release": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "operationId": "sandboxReleasePayout",
        "summary": "Let a payout held for review (…06) continue to paid",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Payout",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payout"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/sandbox/payouts/{id}/decline": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "operationId": "sandboxDeclinePayout",
        "summary": "Fail a payout held for review (…06) with payment_not_approved",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Payout",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payout"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/sandbox/accounts/{id}/approve": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "operationId": "sandboxApproveAccount",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/sandbox/accounts/{id}/reject": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "operationId": "sandboxRejectAccount",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/sandbox/information-requests": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "operationId": "sandboxOpenInformationRequest",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "accountId"
                ],
                "properties": {
                  "accountId": {
                    "type": "string"
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Information request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InformationRequest"
                }
              }
            }
          }
        }
      }
    },
    "/sandbox/information-requests/{id}/close": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "operationId": "sandboxCloseInformationRequest",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Closed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InformationRequest"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/sandbox/transfers/{id}/expire": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "operationId": "sandboxExpireEscrow",
        "summary": "Run the escrow deadline now (automatic refund)",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Transfer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Transfer"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/escrows": {
      "post": {
        "tags": [
          "Escrows"
        ],
        "operationId": "createEscrow",
        "summary": "Hold funds in escrow on the payer balance (returns HTTP 409 not_enabled while held payments guard is off)",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EscrowCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replay of the same clientRef",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Escrow"
                }
              }
            }
          },
          "201": {
            "description": "Escrow created (held)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Escrow"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/escrows/{id}/release": {
      "post": {
        "tags": [
          "Escrows"
        ],
        "operationId": "releaseEscrow",
        "summary": "Release held escrow funds to the seller account",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Released",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Escrow"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/escrows/{id}/cancel": {
      "post": {
        "tags": [
          "Escrows"
        ],
        "operationId": "cancelEscrow",
        "summary": "Cancel held escrow and return funds to payer balance",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Refunded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Escrow"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/cash-outs": {
      "post": {
        "tags": [
          "Transfers"
        ],
        "operationId": "createCashOut",
        "summary": "Cash out account funds to an external beneficiary or payout rail (returns HTTP 409 not_enabled while held payments guard is off)",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CashOutCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replay",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CashOut"
                }
              }
            }
          },
          "201": {
            "description": "Cash-out initiated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CashOut"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "clientBasic": {
        "type": "http",
        "scheme": "basic",
        "description": "client ID as the user name, client secret as the password"
      }
    },
    "parameters": {
      "Id": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "Limit": {
        "name": "limit",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 25
        }
      },
      "Cursor": {
        "name": "cursor",
        "in": "query",
        "schema": {
          "type": "string"
        }
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255
        }
      },
      "AccountHeader": {
        "name": "Storspay-Account-Id",
        "in": "header",
        "description": "Act on one of your account holders (acct_…). The parent always comes from your token.",
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "ValidationError": {
        "description": "Invalid request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthenticated": {
        "description": "Bad or missing credentials",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Scope, verification or recipient refusal",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "Not found, or not yours",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Conflict": {
        "description": "State conflict, account frozen, clientRef reused, quote expired or used, balance not zero",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unprocessable": {
        "description": "Insufficient balance, amount too small, quote intent mismatch, sandbox value on live",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Too many requests",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unavailable": {
        "description": "Corridor or collections unavailable, or payouts briefly paused",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Requirements": {
        "description": "What is still needed",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Requirements"
            }
          }
        }
      },
      "ApiKeyList": {
        "description": "API keys",
        "content": {
          "application/json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Page"
                },
                {
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiKey"
                      }
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "AccountCreated": {
        "description": "Account holder created (pending until verified)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Account"
            }
          }
        }
      },
      "AccountReplayed": {
        "description": "Replay of the same clientRef",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Account"
            }
          }
        }
      },
      "AccountList": {
        "description": "Account holders",
        "content": {
          "application/json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Page"
                },
                {
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Account"
                      }
                    }
                  }
                }
              ]
            }
          }
        }
      }
    },
    "schemas": {
      "Amount": {
        "type": "string",
        "description": "Major units with exactly the currency's decimals (\"1000.00\", \"5000\"). Never a number.",
        "pattern": "^(0|[1-9]\\d*)(\\.\\d{1,3})?$",
        "examples": [
          "1000.00",
          "5000"
        ]
      },
      "Currency": {
        "type": "string",
        "pattern": "^[A-Z]{3}$",
        "examples": [
          "USD",
          "EUR",
          "NGN"
        ]
      },
      "Country": {
        "type": "string",
        "description": "ISO 3166-1 alpha-3",
        "pattern": "^[A-Z]{3}$",
        "examples": [
          "NGA",
          "KEN",
          "USA"
        ]
      },
      "Money": {
        "type": "object",
        "required": [
          "amount",
          "currency"
        ],
        "properties": {
          "amount": {
            "$ref": "#/components/schemas/Amount"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          }
        }
      },
      "ClientRef": {
        "type": "string",
        "minLength": 1,
        "maxLength": 128,
        "description": "Your own reference, unique per account you act on. A retry with the same body returns the original."
      },
      "Route": {
        "type": "string",
        "enum": [
          "bank",
          "mobile_money"
        ]
      },
      "Page": {
        "type": "object",
        "required": [
          "data",
          "hasMore"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {}
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "hasMore": {
            "type": "boolean"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "code",
          "message",
          "requestId"
        ],
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "VALIDATION_ERROR",
              "UNAUTHENTICATED",
              "TOKEN_EXPIRED",
              "WRONG_ENVIRONMENT",
              "INSUFFICIENT_SCOPE",
              "STEP_UP_REQUIRED",
              "ACCOUNT_NOT_VERIFIED",
              "ACCOUNT_FROZEN",
              "RECIPIENT_NOT_ALLOWED",
              "METHOD_NOT_ENTITLED",
              "NOT_FOUND",
              "STATE_CONFLICT",
              "CLIENT_REF_REUSED",
              "IDEMPOTENCY_KEY_IN_PROGRESS",
              "IDEMPOTENCY_KEY_REUSED",
              "QUOTE_EXPIRED",
              "QUOTE_ALREADY_USED",
              "QUOTE_INTENT_MISMATCH",
              "INSUFFICIENT_BALANCE",
              "AMOUNT_TOO_SMALL",
              "CORRIDOR_UNAVAILABLE",
              "BALANCE_NOT_ZERO",
              "SANDBOX_VALUE_ON_LIVE",
              "PAYOUTS_PAUSED",
              "RATE_LIMITED",
              "INTERNAL_ERROR"
            ]
          },
          "message": {
            "type": "string"
          },
          "details": {
            "type": "object",
            "additionalProperties": true
          },
          "requestId": {
            "type": "string"
          }
        }
      },
      "Token": {
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string"
          },
          "tokenType": {
            "type": "string",
            "const": "Bearer"
          },
          "expiresIn": {
            "type": "integer",
            "examples": [
              86400
            ]
          },
          "scope": {
            "type": "string"
          }
        }
      },
      "ApiKey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "clientId": {
            "type": "string"
          },
          "environment": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ]
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "secretLast4": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "revoked"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastUsedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "AccountStatus": {
        "type": "string",
        "enum": [
          "pending",
          "active",
          "frozen",
          "closed"
        ]
      },
      "Account": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "examples": [
              "acct_9f2k1m"
            ]
          },
          "kind": {
            "type": "string",
            "enum": [
              "workspace",
              "account_holder"
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "individual",
              "business",
              "organisation"
            ]
          },
          "name": {
            "type": "string"
          },
          "country": {
            "$ref": "#/components/schemas/Country"
          },
          "status": {
            "$ref": "#/components/schemas/AccountStatus"
          },
          "verification": {
            "type": "string",
            "enum": [
              "not_started",
              "in_review",
              "needs_information",
              "approved",
              "rejected"
            ]
          },
          "clientRef": {
            "$ref": "#/components/schemas/ClientRef"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AccountCreate": {
        "type": "object",
        "required": [
          "clientRef",
          "type",
          "name",
          "email",
          "country"
        ],
        "properties": {
          "clientRef": {
            "$ref": "#/components/schemas/ClientRef"
          },
          "type": {
            "type": "string",
            "enum": [
              "individual",
              "business",
              "organisation"
            ]
          },
          "name": {
            "type": "string"
          },
          "legalName": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string",
            "description": "E.164"
          },
          "country": {
            "$ref": "#/components/schemas/Country"
          },
          "address": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "dateOfBirth": {
            "type": "string",
            "format": "date"
          }
        }
      },
      "AccountUpdate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string"
          }
        }
      },
      "Requirements": {
        "type": "object",
        "properties": {
          "complete": {
            "type": "boolean"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RequirementItem"
            }
          }
        }
      },
      "RequirementItem": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "field",
              "document",
              "disclosure",
              "information_request",
              "activity"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "missing",
              "submitted",
              "accepted",
              "rejected"
            ]
          },
          "description": {
            "type": "string"
          }
        }
      },
      "Application": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "accountId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "submitted",
              "in_review",
              "needs_information",
              "approved",
              "rejected"
            ]
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "not_started",
                    "in_progress",
                    "completed"
                  ]
                }
              }
            }
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Person": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "firstName": {
            "type": "string"
          },
          "lastName": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "director",
              "shareholder",
              "representative"
            ]
          },
          "position": {
            "type": "string"
          },
          "ownershipPercent": {
            "type": "string",
            "description": "Decimal string",
            "e.g. \"25.00\"": null
          },
          "status": {
            "type": "string",
            "enum": [
              "incomplete",
              "complete"
            ]
          }
        }
      },
      "InformationRequest": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "accountId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "closed"
            ]
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RequirementItem"
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Balance": {
        "type": "object",
        "properties": {
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "available": {
            "$ref": "#/components/schemas/Amount"
          },
          "reserved": {
            "$ref": "#/components/schemas/Amount"
          },
          "inEscrow": {
            "$ref": "#/components/schemas/Amount"
          },
          "total": {
            "$ref": "#/components/schemas/Amount"
          }
        }
      },
      "LedgerTransaction": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "examples": [
              "deposit",
              "payout",
              "fee",
              "transfer_in",
              "transfer_out",
              "escrow_hold",
              "escrow_release",
              "escrow_refund",
              "platform_fee_earning",
              "refund"
            ]
          },
          "direction": {
            "type": "string",
            "enum": [
              "credit",
              "debit"
            ]
          },
          "amount": {
            "$ref": "#/components/schemas/Money"
          },
          "balanceAfter": {
            "$ref": "#/components/schemas/Amount"
          },
          "reference": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Statement": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "month": {
            "type": "string"
          },
          "opening": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Money"
            }
          },
          "closing": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Money"
            }
          },
          "pdfUrl": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "QuoteCreate": {
        "type": "object",
        "required": [
          "intent"
        ],
        "properties": {
          "intent": {
            "type": "string",
            "enum": [
              "payout",
              "convert"
            ]
          },
          "sourceCurrency": {
            "$ref": "#/components/schemas/Currency"
          },
          "destinationCurrency": {
            "$ref": "#/components/schemas/Currency"
          },
          "amount": {
            "$ref": "#/components/schemas/Amount"
          },
          "amountType": {
            "type": "string",
            "enum": [
              "send",
              "receive"
            ],
            "description": "Whether amount is what you send or what the recipient gets"
          },
          "country": {
            "$ref": "#/components/schemas/Country"
          },
          "route": {
            "$ref": "#/components/schemas/Route"
          },
          "beneficiaryId": {
            "type": "string"
          }
        }
      },
      "Quote": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "intent": {
            "type": "string",
            "enum": [
              "payout",
              "convert"
            ]
          },
          "source": {
            "$ref": "#/components/schemas/Money"
          },
          "destination": {
            "$ref": "#/components/schemas/Money"
          },
          "rate": {
            "type": "string",
            "description": "Decimal string; \"Sandbox example rate\" in the sandbox"
          },
          "fee": {
            "$ref": "#/components/schemas/Money"
          },
          "platformFee": {
            "$ref": "#/components/schemas/Money"
          },
          "total": {
            "$ref": "#/components/schemas/Money"
          },
          "deliveryEstimate": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "usedBy": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Conversion": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "clientRef": {
            "$ref": "#/components/schemas/ClientRef"
          },
          "quoteId": {
            "type": "string"
          },
          "from": {
            "$ref": "#/components/schemas/Money"
          },
          "to": {
            "$ref": "#/components/schemas/Money"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "completed",
              "failed"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Deposit": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "amount": {
            "$ref": "#/components/schemas/Money"
          },
          "method": {
            "type": "string",
            "enum": [
              "bank_transfer",
              "collection",
              "internal"
            ]
          },
          "reference": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "received",
              "credited",
              "returned"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "VirtualAccount": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "kind": {
            "type": "string",
            "enum": [
              "transfer_route",
              "dedicated"
            ]
          },
          "accountId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending_verification",
              "active",
              "paused",
              "closed"
            ]
          },
          "verificationUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "balance": {
            "type": "object",
            "properties": {
              "available": {
                "$ref": "#/components/schemas/Amount"
              },
              "pending": {
                "$ref": "#/components/schemas/Amount"
              }
            }
          },
          "bankName": {
            "type": "string"
          },
          "accountHolderName": {
            "type": "string"
          },
          "accountNumber": {
            "type": "string"
          },
          "routingNumber": {
            "type": "string"
          },
          "iban": {
            "type": "string"
          },
          "bic": {
            "type": "string"
          },
          "sortCode": {
            "type": "string"
          },
          "reference": {
            "type": "string",
            "description": "Required on every incoming transfer for a transfer route"
          }
        }
      },
      "CollectionStatus": {
        "type": "string",
        "enum": [
          "pending",
          "received",
          "converting",
          "credited",
          "expired",
          "cancelled",
          "failed"
        ]
      },
      "CollectionCreate": {
        "type": "object",
        "required": [
          "clientRef",
          "amount"
        ],
        "properties": {
          "clientRef": {
            "$ref": "#/components/schemas/ClientRef"
          },
          "amount": {
            "$ref": "#/components/schemas/Money"
          },
          "creditTo": {
            "$ref": "#/components/schemas/TransferParty"
          },
          "country": {
            "$ref": "#/components/schemas/Country"
          },
          "method": {
            "type": "string",
            "enum": [
              "bank_transfer",
              "mobile_money"
            ]
          },
          "payer": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "email": {
                "type": "string",
                "format": "email"
              },
              "phone": {
                "type": "string"
              }
            }
          },
          "memo": {
            "type": "string"
          },
          "platformFee": {
            "$ref": "#/components/schemas/PlatformFeeOverride"
          }
        }
      },
      "Collection": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "clientRef": {
            "$ref": "#/components/schemas/ClientRef"
          },
          "status": {
            "$ref": "#/components/schemas/CollectionStatus"
          },
          "requested": {
            "$ref": "#/components/schemas/Money"
          },
          "payerAmount": {
            "$ref": "#/components/schemas/Money"
          },
          "fee": {
            "$ref": "#/components/schemas/Money"
          },
          "credited": {
            "$ref": "#/components/schemas/Money"
          },
          "payLink": {
            "type": "string",
            "format": "uri"
          },
          "paymentInstructions": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "BeneficiaryCreate": {
        "type": "object",
        "required": [
          "type",
          "name",
          "country",
          "currency",
          "route"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "individual",
              "business"
            ]
          },
          "name": {
            "type": "string"
          },
          "country": {
            "$ref": "#/components/schemas/Country"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "route": {
            "$ref": "#/components/schemas/Route"
          },
          "bankCode": {
            "type": "string"
          },
          "accountNumber": {
            "type": "string"
          },
          "iban": {
            "type": "string"
          },
          "phone": {
            "type": "string",
            "description": "E.164",
            "for mobile money": null
          },
          "extra": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Country-specific fields from /payouts/requirements"
          }
        }
      },
      "Beneficiary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "individual",
              "business"
            ]
          },
          "name": {
            "type": "string"
          },
          "resolvedName": {
            "type": [
              "string",
              "null"
            ],
            "description": "Holder name returned by the bank or network",
            "when available": null
          },
          "country": {
            "$ref": "#/components/schemas/Country"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "route": {
            "$ref": "#/components/schemas/Route"
          },
          "accountLast4": {
            "type": "string"
          },
          "deduplicated": {
            "type": "boolean"
          }
        }
      },
      "FieldRequirement": {
        "type": "object",
        "properties": {
          "field": {
            "type": "string"
          },
          "required": {
            "type": "boolean"
          },
          "format": {
            "type": "string"
          },
          "example": {
            "type": "string"
          },
          "allowedValues": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "PayoutStatus": {
        "type": "string",
        "enum": [
          "created",
          "queued",
          "processing",
          "paid",
          "failed",
          "cancelled",
          "reverted"
        ]
      },
      "PayoutCreate": {
        "type": "object",
        "required": [
          "quoteId",
          "beneficiaryId",
          "clientRef"
        ],
        "properties": {
          "quoteId": {
            "type": "string"
          },
          "beneficiaryId": {
            "type": "string"
          },
          "clientRef": {
            "$ref": "#/components/schemas/ClientRef"
          },
          "reference": {
            "type": "string",
            "description": "Narration the recipient may see"
          },
          "purpose": {
            "type": "string"
          },
          "platformFee": {
            "$ref": "#/components/schemas/PlatformFeeOverride"
          }
        }
      },
      "Payout": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "examples": [
              "po_8F2K1M3QZ"
            ]
          },
          "clientRef": {
            "$ref": "#/components/schemas/ClientRef"
          },
          "status": {
            "$ref": "#/components/schemas/PayoutStatus"
          },
          "cancellable": {
            "type": "boolean"
          },
          "beneficiaryId": {
            "type": "string"
          },
          "quoteId": {
            "type": "string"
          },
          "source": {
            "$ref": "#/components/schemas/Money"
          },
          "destination": {
            "$ref": "#/components/schemas/Money"
          },
          "rate": {
            "type": "string"
          },
          "fee": {
            "$ref": "#/components/schemas/Money"
          },
          "platformFee": {
            "$ref": "#/components/schemas/Money"
          },
          "total": {
            "$ref": "#/components/schemas/Money"
          },
          "legs": {
            "type": "integer",
            "minimum": 1
          },
          "failureCategory": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "technical_error",
              "recipient_details",
              "payment_not_approved",
              null
            ]
          },
          "failureCode": {
            "type": [
              "string",
              "null"
            ]
          },
          "returnStatus": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "pending",
              "returned",
              null
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PayoutBatch": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "clientRef": {
                  "$ref": "#/components/schemas/ClientRef"
                },
                "payoutId": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "error": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "TransferStatus": {
        "type": "string",
        "enum": [
          "pending",
          "completed",
          "failed",
          "held",
          "released",
          "refunded"
        ]
      },
      "TransferCreate": {
        "type": "object",
        "required": [
          "from",
          "to",
          "amount",
          "clientRef"
        ],
        "properties": {
          "from": {
            "$ref": "#/components/schemas/TransferParty"
          },
          "to": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TransferParty"
              },
              {
                "type": "object",
                "required": [
                  "payout"
                ],
                "description": "Cash-out through the normal payout path",
                "properties": {
                  "payout": {
                    "type": "object",
                    "required": [
                      "beneficiaryId",
                      "quoteId"
                    ],
                    "properties": {
                      "beneficiaryId": {
                        "type": "string"
                      },
                      "quoteId": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            ]
          },
          "amount": {
            "$ref": "#/components/schemas/Money"
          },
          "clientRef": {
            "$ref": "#/components/schemas/ClientRef"
          },
          "reference": {
            "type": "string"
          },
          "memo": {
            "type": "string"
          },
          "escrow": {
            "type": "object",
            "description": "Hold the money until you release or cancel it",
            "properties": {
              "holdUntil": {
                "type": "string",
                "format": "date-time",
                "description": "Automatic refund after this time (default 14 days",
                "at most 30)": null
              }
            }
          },
          "platformFee": {
            "$ref": "#/components/schemas/PlatformFeeOverride"
          }
        }
      },
      "TransferParty": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "const": "platform",
                "description": "Your own balance"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "accountId"
            ],
            "properties": {
              "accountId": {
                "type": "string",
                "description": "One of your account holders (acct_…)"
              }
            }
          }
        ]
      },
      "Transfer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "examples": [
              "tr_4H7Q2"
            ]
          },
          "clientRef": {
            "$ref": "#/components/schemas/ClientRef"
          },
          "kind": {
            "type": "string",
            "enum": [
              "settlement",
              "p2p",
              "cash_out",
              "refund"
            ]
          },
          "from": {
            "$ref": "#/components/schemas/TransferParty"
          },
          "to": {
            "type": "object",
            "additionalProperties": true
          },
          "amount": {
            "$ref": "#/components/schemas/Money"
          },
          "fee": {
            "$ref": "#/components/schemas/Money"
          },
          "platformFee": {
            "$ref": "#/components/schemas/Money"
          },
          "net": {
            "$ref": "#/components/schemas/Money"
          },
          "status": {
            "$ref": "#/components/schemas/TransferStatus"
          },
          "escrow": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "holdUntil": {
                "type": "string",
                "format": "date-time"
              },
              "releasedAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "refundedAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          },
          "cashOutPayoutId": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PlatformFeeOverride": {
        "type": "object",
        "properties": {
          "amount": {
            "$ref": "#/components/schemas/Amount"
          },
          "waive": {
            "type": "boolean"
          }
        }
      },
      "PlatformFeeRules": {
        "type": "object",
        "properties": {
          "version": {
            "type": "integer"
          },
          "rules": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "flow",
                "currency"
              ],
              "properties": {
                "flow": {
                  "type": "string",
                  "enum": [
                    "escrow_release",
                    "transfer",
                    "payout",
                    "collection"
                  ]
                },
                "currency": {
                  "$ref": "#/components/schemas/Currency"
                },
                "destinationCurrency": {
                  "$ref": "#/components/schemas/Currency"
                },
                "percent": {
                  "type": "string",
                  "description": "Decimal string, e.g. \"1.00\" for 1%; at most 5"
                },
                "fixed": {
                  "$ref": "#/components/schemas/Amount"
                },
                "min": {
                  "$ref": "#/components/schemas/Amount"
                },
                "max": {
                  "$ref": "#/components/schemas/Amount"
                }
              }
            }
          }
        }
      },
      "WebhookEndpoint": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "enabled": {
            "type": "boolean"
          },
          "secretLast4": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WebhookDelivery": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "eventId": {
            "type": "string"
          },
          "endpointId": {
            "type": "string"
          },
          "attempt": {
            "type": "integer",
            "minimum": 1,
            "maximum": 12
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "succeeded",
              "failed"
            ]
          },
          "httpStatus": {
            "type": [
              "integer",
              "null"
            ]
          },
          "durationMs": {
            "type": [
              "integer",
              "null"
            ]
          },
          "responseSnippet": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 512
          },
          "nextAttemptAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/Event"
          }
        }
      },
      "Event": {
        "type": "object",
        "required": [
          "id",
          "type",
          "createdAt",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "examples": [
              "evt_2N8K4"
            ]
          },
          "type": {
            "type": "string",
            "examples": [
              "payout.paid",
              "transfer.held",
              "transfer.released",
              "collection.credited",
              "virtual_account.kyc_updated",
              "account.activated",
              "webhook.test"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "apiVersion": {
            "type": "string"
          },
          "accountId": {
            "type": "string"
          },
          "test": {
            "type": "boolean"
          },
          "data": {
            "type": "object",
            "properties": {
              "object": {
                "type": "object",
                "additionalProperties": true,
                "description": "The resource as GET returns it",
                "without personal data": null
              }
            }
          }
        }
      },
      "Escrow": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "examples": [
              "hp_0123456789abcdef01234567"
            ]
          },
          "clientRef": {
            "$ref": "#/components/schemas/ClientRef"
          },
          "payerId": {
            "type": "string"
          },
          "sellerId": {
            "type": "string"
          },
          "amount": {
            "$ref": "#/components/schemas/Amount"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "fee": {
            "$ref": "#/components/schemas/Amount"
          },
          "total": {
            "$ref": "#/components/schemas/Amount"
          },
          "status": {
            "type": "string",
            "enum": [
              "held",
              "released",
              "refunded"
            ]
          },
          "holdUntil": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "releasedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "refundedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "EscrowCreate": {
        "type": "object",
        "required": [
          "clientRef",
          "amount",
          "currency",
          "to"
        ],
        "properties": {
          "clientRef": {
            "$ref": "#/components/schemas/ClientRef"
          },
          "amount": {
            "$ref": "#/components/schemas/Amount"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "to": {
            "type": "string",
            "description": "Seller account ID or verified seller email"
          },
          "description": {
            "type": "string"
          }
        }
      },
      "CashOut": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "examples": [
              "hp_0123456789abcdef01234567"
            ]
          },
          "clientRef": {
            "$ref": "#/components/schemas/ClientRef"
          },
          "amount": {
            "$ref": "#/components/schemas/Money"
          },
          "status": {
            "type": "string",
            "enum": [
              "completed",
              "processing"
            ]
          },
          "beneficiaryId": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CashOutCreate": {
        "type": "object",
        "required": [
          "clientRef",
          "amount"
        ],
        "properties": {
          "clientRef": {
            "$ref": "#/components/schemas/ClientRef"
          },
          "amount": {
            "$ref": "#/components/schemas/Money"
          },
          "beneficiaryId": {
            "type": "string"
          },
          "description": {
            "type": "string"
          }
        }
      }
    }
  },
  "webhooks": {
    "event": {
      "post": {
        "summary": "Every event we send to your endpoints",
        "parameters": [
          {
            "name": "Storspay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "t=<unix>,v1=<hex HMAC-SHA256(secret, t + \".\" + rawBody)>"
          },
          {
            "name": "Storspay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Storspay-Delivery-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx within 30 seconds counts as delivered"
          }
        }
      }
    }
  }
}
