{
  "openapi": "3.1.0",
  "info": {
    "title": "EZ Rails API",
    "version": "1",
    "description": "Payment and banking rails for Argentina and Chile: connect accounts, receive transfers, declare payment expectations, reconcile them automatically and (optionally) issue the matching electronic invoice. All amounts are decimal strings with exactly two decimals; never send floats."
  },
  "servers": [
    {
      "url": "https://api.ez-rails.huggian.com/rails",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "Health"
    },
    {
      "name": "Demo"
    },
    {
      "name": "Accounts"
    },
    {
      "name": "CBU / CVU"
    },
    {
      "name": "Virtual CVUs"
    },
    {
      "name": "Expectations"
    },
    {
      "name": "Movements"
    },
    {
      "name": "Reconciliations"
    },
    {
      "name": "Webhooks"
    },
    {
      "name": "Mercado Pago OAuth"
    },
    {
      "name": "Sandbox"
    },
    {
      "name": "Inbound provider webhooks"
    }
  ],
  "paths": {
    "/v1/health": {
      "get": {
        "tags": [
          "Health"
        ],
        "summary": "Liveness and database readiness (no API key, never rate limited).",
        "security": [],
        "responses": {
          "200": {
            "description": "status ok or degraded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          },
          "503": {
            "description": "database unreachable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/demo/match": {
      "post": {
        "tags": [
          "Demo"
        ],
        "summary": "Public stateless matching demo (no API key).",
        "description": "Runs the same deterministic matching engine as POST /v1/reconciliations/match without an API key, tenant, storage, or billing usage. Capped at 16 KiB body (413 payload_too_large), 20 movements and 20 expectations (422 demo_limit_exceeded), and 10 requests/minute per client IP (429 rate_limited with Retry-After).",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StatelessMatchRequest"
              },
              "example": {
                "movements": [
                  {
                    "movementId": "mov-001",
                    "direction": "credit",
                    "amount": "15000.00",
                    "currency": "ARS",
                    "externalReference": "ORD-2026-0001",
                    "occurredAt": "2026-11-23T15:05:00Z"
                  }
                ],
                "expectations": [
                  {
                    "expectationId": "exp-001",
                    "expectedAmount": "15000.00",
                    "amountTolerance": "0.00",
                    "currency": "ARS",
                    "expectedReference": "ORD-2026-0001",
                    "createdAt": "2026-11-23T15:00:00Z"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Match report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MatchBatchReport"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "413": {
            "$ref": "#/components/responses/E413"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/accounts": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "summary": "List the tenant rail accounts (credentials are never returned; account numbers are masked).",
        "x-required-scope": "rails:read",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "tenantId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tenant the API key is anchored to (also accepted as tenant_id). A tenant outside the key allowed_tenant_ids answers 404."
          }
        ],
        "responses": {
          "200": {
            "description": "Accounts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RailAccountSummary"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      },
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Create or update a rail account (Mercado Pago, banks, PSPs). Secrets are encrypted at rest and never echoed.",
        "x-required-scope": "rails:write",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          }
        ],
        "responses": {
          "201": {
            "description": "Account summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RailAccountSummary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertRailAccount"
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{account_id}/verify-connection": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Probe the provider credentials of an account.",
        "x-required-scope": "rails:write",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Connection verification result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerifyConnectionResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VerifyConnectionRequest"
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{account_id}/auto-listen": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Enable or disable automatic polling of incoming transfers.",
        "x-required-scope": "rails:write",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Updated account summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RailAccountSummary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetAccountAutoListenRequest"
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{account_id}/sync-now": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Poll the provider for new movements immediately.",
        "x-required-scope": "rails:write",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sync result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SyncAccountNowResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SyncAccountNowRequest"
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{account_id}/import-statement": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Import a bank statement (CSV/text) for a statement_cbu account. Body limit 4 MiB.",
        "x-required-scope": "rails:write",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Statement imported (or idempotent replay)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportStatementResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          },
          "201": {
            "description": "Statement imported",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportStatementResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportStatementRequest"
              }
            }
          }
        }
      }
    },
    "/v1/cbu-cvu/inspect": {
      "post": {
        "tags": [
          "CBU / CVU"
        ],
        "summary": "Validate a CBU/CVU/alias and identify its bank or PSP (no network call to the bank).",
        "x-required-scope": "rails:read",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          }
        ],
        "responses": {
          "200": {
            "description": "CBU/CVU inspection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ArAccountInspection"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InspectCbuCvuRequest"
              }
            }
          }
        }
      }
    },
    "/v1/cbu-ownership-challenges": {
      "get": {
        "tags": [
          "CBU / CVU"
        ],
        "summary": "List CBU ownership challenges.",
        "x-required-scope": "rails:read",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "tenantId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tenant the API key is anchored to (also accepted as tenant_id). A tenant outside the key allowed_tenant_ids answers 404."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "Maximum rows (default 100)."
          }
        ],
        "responses": {
          "200": {
            "description": "Challenges",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CbuOwnershipChallengeSummary"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      },
      "post": {
        "tags": [
          "CBU / CVU"
        ],
        "summary": "Start a micro-deposit ownership challenge for a CBU.",
        "x-required-scope": "rails:write",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Idempotent replay",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CbuOwnershipChallengeSummary"
                }
              }
            }
          },
          "201": {
            "description": "Challenge created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CbuOwnershipChallengeSummary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCbuChallengeRequest"
              }
            }
          }
        }
      }
    },
    "/v1/cbu-ownership-challenges/{challenge_id}": {
      "get": {
        "tags": [
          "CBU / CVU"
        ],
        "summary": "Read one ownership challenge.",
        "x-required-scope": "rails:read",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "challenge_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenantId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tenant the API key is anchored to (also accepted as tenant_id). A tenant outside the key allowed_tenant_ids answers 404."
          }
        ],
        "responses": {
          "200": {
            "description": "Challenge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CbuOwnershipChallengeSummary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/virtual-cvus": {
      "get": {
        "tags": [
          "Virtual CVUs"
        ],
        "summary": "List virtual CVUs.",
        "x-required-scope": "rails:read",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "tenantId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tenant the API key is anchored to (also accepted as tenant_id). A tenant outside the key allowed_tenant_ids answers 404."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "Maximum rows (default 100)."
          }
        ],
        "responses": {
          "200": {
            "description": "Virtual CVUs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/VirtualCvuSummary"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      },
      "post": {
        "tags": [
          "Virtual CVUs"
        ],
        "summary": "Provision a virtual CVU for collecting transfers.",
        "x-required-scope": "rails:write",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Idempotent replay",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProvisionedVirtualCvuResponse"
                }
              }
            }
          },
          "201": {
            "description": "Provisioned",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProvisionedVirtualCvuResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProvisionVirtualCvuRequest"
              }
            }
          }
        }
      }
    },
    "/v1/virtual-cvus/sweeps": {
      "get": {
        "tags": [
          "Virtual CVUs"
        ],
        "summary": "List sweep payouts from virtual CVUs.",
        "x-required-scope": "rails:read",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "tenantId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tenant the API key is anchored to (also accepted as tenant_id). A tenant outside the key allowed_tenant_ids answers 404."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "Maximum rows (default 100)."
          }
        ],
        "responses": {
          "200": {
            "description": "Sweeps",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/VirtualCvuSweepPayout"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/virtual-cvus/{cvu_id}/payment-instructions": {
      "get": {
        "tags": [
          "Virtual CVUs"
        ],
        "summary": "Payment instructions to show a payer.",
        "x-required-scope": "rails:read",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "cvu_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenantId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tenant the API key is anchored to (also accepted as tenant_id). A tenant outside the key allowed_tenant_ids answers 404."
          }
        ],
        "responses": {
          "200": {
            "description": "Payment instructions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VirtualCvuPaymentInstructionsResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/expectations": {
      "get": {
        "tags": [
          "Expectations"
        ],
        "summary": "List payment expectations.",
        "x-required-scope": "rails:read",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "tenantId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tenant the API key is anchored to (also accepted as tenant_id). A tenant outside the key allowed_tenant_ids answers 404."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "open | reconciled | expired | cancelled"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "Maximum rows (default 100)."
          }
        ],
        "responses": {
          "200": {
            "description": "Expectations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PaymentExpectation"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      },
      "post": {
        "tags": [
          "Expectations"
        ],
        "summary": "Declare an expected payment so an incoming transfer reconciles against it (optionally auto-invoicing).",
        "x-required-scope": "rails:write",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Idempotent replay of the first response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentExpectation"
                }
              }
            }
          },
          "201": {
            "description": "Expectation created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentExpectation"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateExpectation"
              }
            }
          }
        }
      }
    },
    "/v1/movements": {
      "get": {
        "tags": [
          "Movements"
        ],
        "summary": "List received or sent rail movements.",
        "x-required-scope": "rails:read",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "tenantId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tenant the API key is anchored to (also accepted as tenant_id). A tenant outside the key allowed_tenant_ids answers 404."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "Maximum rows (default 100)."
          }
        ],
        "responses": {
          "200": {
            "description": "Movements",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RailMovement"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/reconciliations": {
      "get": {
        "tags": [
          "Reconciliations"
        ],
        "summary": "List reconciliations (movement to expectation matches).",
        "x-required-scope": "rails:read",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "tenantId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tenant the API key is anchored to (also accepted as tenant_id). A tenant outside the key allowed_tenant_ids answers 404."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "Maximum rows (default 100)."
          }
        ],
        "responses": {
          "200": {
            "description": "Reconciliations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RailReconciliation"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/reconciliations/match": {
      "post": {
        "tags": [
          "Reconciliations"
        ],
        "summary": "Stateless matching: send movements and expectations, get the match report; nothing is stored.",
        "x-required-scope": "rails:write",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          }
        ],
        "responses": {
          "200": {
            "description": "Match report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MatchBatchReport"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StatelessMatchRequest"
              },
              "example": {
                "movements": [
                  {
                    "movementId": "mov-001",
                    "direction": "credit",
                    "amount": "15000.00",
                    "currency": "ARS",
                    "externalReference": "ORD-2026-0001",
                    "occurredAt": "2026-11-23T15:05:00Z"
                  }
                ],
                "expectations": [
                  {
                    "expectationId": "exp-001",
                    "expectedAmount": "15000.00",
                    "amountTolerance": "0.00",
                    "currency": "ARS",
                    "expectedReference": "ORD-2026-0001",
                    "createdAt": "2026-11-23T15:00:00Z"
                  }
                ]
              }
            }
          }
        }
      }
    },
    "/v1/pilot/accountant-overview": {
      "get": {
        "tags": [
          "Reconciliations"
        ],
        "summary": "Accountant summary of movements and reconciliations.",
        "x-required-scope": "rails:read",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "tenantId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tenant the API key is anchored to (also accepted as tenant_id). A tenant outside the key allowed_tenant_ids answers 404."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "Maximum rows (default 100)."
          }
        ],
        "responses": {
          "200": {
            "description": "Accountant overview",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountantOverviewResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/webhooks/endpoints": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List your webhook endpoints (secrets are never returned).",
        "x-required-scope": "rails:read",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "tenantId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tenant the API key is anchored to (also accepted as tenant_id). A tenant outside the key allowed_tenant_ids answers 404."
          }
        ],
        "responses": {
          "200": {
            "description": "Endpoints",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookEndpointSummary"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      },
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Register an HTTPS webhook endpoint. Only https on port 443 to public addresses is accepted.",
        "x-required-scope": "rails:webhooks",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          }
        ],
        "responses": {
          "201": {
            "description": "Endpoint created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpointSummary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebhookEndpoint"
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/deliveries": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List webhook deliveries and their attempts.",
        "x-required-scope": "rails:read",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "tenantId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tenant the API key is anchored to (also accepted as tenant_id). A tenant outside the key allowed_tenant_ids answers 404."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "Maximum rows (default 100)."
          }
        ],
        "responses": {
          "200": {
            "description": "Deliveries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookDeliverySummary"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/webhooks/deliveries/{delivery_id}/replay": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Replay a failed or dead-lettered delivery.",
        "x-required-scope": "rails:webhooks",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          },
          {
            "name": "delivery_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Delivery requeued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliverySummary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReplayWebhookDeliveryRequest"
              }
            }
          }
        }
      }
    },
    "/v1/oauth/mercadopago/authorize-url": {
      "post": {
        "tags": [
          "Mercado Pago OAuth"
        ],
        "summary": "Build the Mercado Pago authorization URL for an account.",
        "x-required-scope": "rails:write",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          }
        ],
        "responses": {
          "200": {
            "description": "Authorization URL",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MpOAuthAuthorizeUrlResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MpOAuthAuthorizeUrlRequest"
              }
            }
          }
        }
      }
    },
    "/v1/oauth/mercadopago/exchange": {
      "post": {
        "tags": [
          "Mercado Pago OAuth"
        ],
        "summary": "Exchange the OAuth code returned by Mercado Pago.",
        "x-required-scope": "rails:write",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          }
        ],
        "responses": {
          "200": {
            "description": "Connected account summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RailAccountSummary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MpOAuthExchangeRequest"
              }
            }
          }
        }
      }
    },
    "/v1/sandbox/simulate-transfer": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "summary": "Sandbox keys only: simulate an incoming transfer and run reconciliation inline.",
        "x-required-scope": "rails:write",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SourceApp"
          }
        ],
        "responses": {
          "200": {
            "description": "Simulated and processed inline",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SimulateTransferResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          },
          "202": {
            "description": "Accepted into sandbox inbox",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SimulateTransferResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SimulateTransfer"
              }
            }
          }
        }
      }
    },
    "/v1/inbound/{rail}/{account_id}": {
      "post": {
        "tags": [
          "Inbound provider webhooks"
        ],
        "summary": "Provider-to-EZ Rails notification URL for an account (configure it in the provider dashboard). Authenticated by the provider signature, not by an API key.",
        "security": [],
        "parameters": [
          {
            "name": "rail",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "mercadopago",
                "paddle",
                "stripe",
                "stripe_fc",
                "bind",
                "nave_galicia",
                "comafi",
                "khipu_cl",
                "fintoc_cl",
                "sandbox"
              ]
            }
          },
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Connectivity test acknowledged",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboundAcceptResponse"
                }
              }
            }
          },
          "202": {
            "description": "Accepted into the inbox",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboundAcceptResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/inbound/mercadopago-app": {
      "post": {
        "tags": [
          "Inbound provider webhooks"
        ],
        "summary": "Mercado Pago application-level notification URL (x-signature verified).",
        "security": [],
        "responses": {
          "202": {
            "description": "Accepted into the inbox",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboundAcceptResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "200": {
            "description": "Connectivity test acknowledged",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboundAcceptResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "event": {
      "post": {
        "summary": "Event delivered to your endpoint",
        "description": "EZ Rails POSTs JSON to every active endpoint whose events filter matches. Verify X-Huggian-Signature before trusting the body: compute hex(HMAC-SHA256(secret, timestamp + \".\" + raw_body)) with the endpoint secret and the X-Huggian-Timestamp header, compare in constant time, and reject timestamps more than 5 minutes away from your clock. During secret rotation X-Huggian-Signature-Secondary carries the signature made with the secondary secret. X-BBX-* headers are legacy duplicates. Deliveries are at-least-once: deduplicate on X-Huggian-Delivery-Id. Answer 2xx within the timeout; anything else is retried with backoff and finally dead-lettered (replayable).",
        "parameters": [
          {
            "name": "X-Huggian-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          },
          {
            "name": "X-Huggian-Signature-Secondary",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          },
          {
            "name": "X-Huggian-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Unix seconds"
          },
          {
            "name": "X-Huggian-Delivery-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "X-Huggian-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "transfer.received",
                "transfer.reconciled",
                "invoice.issued",
                "cbu.ownership_verified",
                "virtual_cvu.transfer_received",
                "virtual_cvu.sweep_settled"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Acknowledged"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "ezr_live_* keys operate on live data, ezr_test_* (sandbox plan) keys on sandbox data only; mixing returns 403. Each key carries scopes (rails:read, rails:write, rails:webhooks) and the tenants it may act on. Plan limits apply per key: requests per minute and per month (429 rate_limited when exceeded)."
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string",
          "minLength": 8,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9._~+/:-]{8,128}$"
        },
        "description": "Retry-safe creation. The first response is stored and replayed for the same key and payload. Reusing a key with a different payload answers 409 idempotency_key_conflict; a concurrent duplicate answers 409 idempotency_key_in_flight (retry shortly)."
      },
      "SourceApp": {
        "name": "X-Source-App",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string",
          "pattern": "^[a-z0-9_-]{1,64}$"
        },
        "description": "Your application name, recorded on created resources. Defaults to the key owner."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable message; do not branch on it."
          },
          "code": {
            "type": "string",
            "description": "Stable machine code: unauthorized, forbidden, not_found, rate_limited, service_unavailable, internal_error, invalid_query, idempotency_key_invalid, idempotency_key_conflict, idempotency_key_in_flight, validation_error, demo_limit_exceeded, payload_too_large, invalid_json, ssrf_blocked, malformed_webhook, unprocessable_event, unsupported_operation, rail_upstream_error, outcome_unknown, too_many_movements, too_many_expectations, candidate_pair_budget_exceeded, invalid_movement_amount, invalid_expectation_amount, invalid_tolerance_amount, invalid_identifier, invalid_match_config, invalid_source_app, invalid_utf8."
          },
          "not_attempted": {
            "type": "boolean",
            "description": "true when the request provably had no side effect, so retrying cannot duplicate anything."
          },
          "fallback_safe": {
            "type": "boolean"
          }
        }
      },
      "UpsertRailAccount": {
        "type": "object",
        "required": [
          "tenantId",
          "railId",
          "label"
        ],
        "properties": {
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "railId": {
            "type": "string",
            "enum": [
              "mercadopago",
              "paddle",
              "stripe",
              "sandbox",
              "bind",
              "interbanking",
              "nave_galicia",
              "comafi",
              "khipu_cl",
              "fintoc_cl",
              "stripe_fc",
              "statement_cbu"
            ]
          },
          "environment": {
            "type": "string",
            "enum": [
              "live",
              "sandbox"
            ]
          },
          "countryCode": {
            "type": "string",
            "example": "AR"
          },
          "label": {
            "type": "string",
            "maxLength": 80
          },
          "isDefault": {
            "type": "boolean"
          },
          "externalAccountId": {
            "type": "string"
          },
          "externalPosId": {
            "type": "string"
          },
          "accessToken": {
            "type": "string",
            "writeOnly": true
          },
          "webhookSecret": {
            "type": "string",
            "writeOnly": true
          },
          "secondaryWebhookSecret": {
            "type": "string",
            "writeOnly": true
          },
          "mtlsCertPem": {
            "type": "string",
            "writeOnly": true
          },
          "mtlsKeyPem": {
            "type": "string",
            "writeOnly": true
          },
          "gatewayMetadata": {
            "type": "object"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "disconnected",
              "inactive"
            ]
          }
        }
      },
      "CreateExpectation": {
        "type": "object",
        "required": [
          "tenantId",
          "expectedAmount",
          "currency"
        ],
        "properties": {
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "environment": {
            "type": "string",
            "enum": [
              "live",
              "sandbox"
            ]
          },
          "externalOrderId": {
            "type": "string",
            "maxLength": 128
          },
          "expectedAmount": {
            "type": "string",
            "example": "15000.00"
          },
          "amountTolerance": {
            "type": "string",
            "example": "0.00"
          },
          "currency": {
            "type": "string",
            "example": "ARS"
          },
          "expectedReference": {
            "type": "string",
            "maxLength": 128
          },
          "expectedPayerTaxId": {
            "type": "string",
            "maxLength": 32
          },
          "buyerName": {
            "type": "string"
          },
          "buyerDocTipo": {
            "type": "integer"
          },
          "buyerDocNro": {
            "type": "integer"
          },
          "buyerTaxCondition": {
            "type": "string"
          },
          "autoInvoiceEnabled": {
            "type": "boolean"
          },
          "fiscalProfileId": {
            "type": "string",
            "format": "uuid"
          },
          "fiscalPtoVta": {
            "type": "integer"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "invoiceConcepto": {
            "type": "integer",
            "enum": [
              1,
              2,
              3
            ]
          },
          "invoiceIvaRate": {
            "type": "string",
            "example": "21.00"
          },
          "invoiceDescription": {
            "type": "string",
            "maxLength": 120
          },
          "supersedeOpenByReference": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "CreateWebhookEndpoint": {
        "type": "object",
        "required": [
          "tenantId",
          "url",
          "secret",
          "events"
        ],
        "properties": {
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "environment": {
            "type": "string",
            "enum": [
              "live",
              "sandbox"
            ]
          },
          "url": {
            "type": "string",
            "format": "uri",
            "example": "https://hooks.example.com/ez-rails"
          },
          "secret": {
            "type": "string",
            "writeOnly": true
          },
          "secondarySecret": {
            "type": "string",
            "writeOnly": true
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "transfer.*",
              "invoice.issued"
            ]
          }
        }
      },
      "SimulateTransfer": {
        "type": "object",
        "required": [
          "tenantId",
          "railAccountId",
          "amount",
          "currency"
        ],
        "properties": {
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "railAccountId": {
            "type": "string",
            "format": "uuid"
          },
          "externalMovementId": {
            "type": "string"
          },
          "amount": {
            "type": "string",
            "example": "15000.00"
          },
          "currency": {
            "type": "string"
          },
          "externalReference": {
            "type": "string"
          },
          "payerTaxId": {
            "type": "string"
          },
          "payerName": {
            "type": "string"
          },
          "payerCbu": {
            "type": "string"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time"
          },
          "processInline": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "HealthResponse": {
        "type": "object",
        "required": [
          "status",
          "db"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "degraded",
              "unhealthy"
            ]
          },
          "db": {
            "type": "string",
            "enum": [
              "ok",
              "down"
            ]
          },
          "dead_letter_deliveries": {
            "type": "integer",
            "minimum": 0
          },
          "mp_https_only": {
            "type": "boolean"
          }
        }
      },
      "MatchMovementCandidate": {
        "type": "object",
        "required": [
          "movementId",
          "direction",
          "amount",
          "currency",
          "occurredAt"
        ],
        "properties": {
          "movementId": {
            "type": "string",
            "example": "mov-001"
          },
          "direction": {
            "type": "string",
            "enum": [
              "credit",
              "debit"
            ]
          },
          "amount": {
            "type": "string",
            "example": "15000.00"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "example": "ARS"
          },
          "externalReference": {
            "type": [
              "string",
              "null"
            ],
            "example": "ORD-2026-0001"
          },
          "payerTaxId": {
            "type": [
              "string",
              "null"
            ],
            "example": "20304050607"
          },
          "payerIsAccountOwner": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-23T15:05:00Z"
          }
        }
      },
      "MatchExpectationCandidate": {
        "type": "object",
        "required": [
          "expectationId",
          "expectedAmount",
          "currency",
          "createdAt"
        ],
        "properties": {
          "expectationId": {
            "type": "string",
            "example": "exp-001"
          },
          "expectedAmount": {
            "type": "string",
            "example": "15000.00"
          },
          "amountTolerance": {
            "type": "string",
            "default": "0.00",
            "example": "0.00"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "example": "ARS"
          },
          "expectedReference": {
            "type": [
              "string",
              "null"
            ],
            "example": "ORD-2026-0001"
          },
          "expectedPayerTaxId": {
            "type": [
              "string",
              "null"
            ],
            "example": "20304050607"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-23T15:00:00Z"
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "StatelessMatchRequest": {
        "type": "object",
        "required": [
          "movements",
          "expectations"
        ],
        "properties": {
          "tenantId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "movements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MatchMovementCandidate"
            }
          },
          "expectations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MatchExpectationCandidate"
            }
          },
          "earlyGraceSecs": {
            "type": [
              "integer",
              "null"
            ],
            "example": 300
          }
        }
      },
      "MatchReason": {
        "type": "string",
        "enum": [
          "exactReferenceAndAmount",
          "exactReferenceWithinTolerance",
          "exactTaxIdAndAmount",
          "exactTaxIdWithinTolerance",
          "exactAmountUniqueInWindow"
        ]
      },
      "MatchedPair": {
        "type": "object",
        "required": [
          "movementId",
          "expectationId",
          "reason",
          "confidenceBps",
          "amountDelta"
        ],
        "properties": {
          "movementId": {
            "type": "string"
          },
          "expectationId": {
            "type": "string"
          },
          "reason": {
            "$ref": "#/components/schemas/MatchReason"
          },
          "confidenceBps": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000,
            "example": 10000
          },
          "amountDelta": {
            "type": "string",
            "example": "0.00"
          }
        }
      },
      "AmbiguousMovement": {
        "type": "object",
        "required": [
          "movementId",
          "candidateExpectationIds"
        ],
        "properties": {
          "movementId": {
            "type": "string"
          },
          "candidateExpectationIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "MatchBatchReport": {
        "type": "object",
        "required": [
          "matched",
          "ambiguous",
          "unmatchedMovementIds",
          "unmatchedExpectationIds",
          "evaluatedPairs"
        ],
        "properties": {
          "matched": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MatchedPair"
            }
          },
          "ambiguous": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AmbiguousMovement"
            }
          },
          "unmatchedMovementIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "unmatchedExpectationIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "evaluatedPairs": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "RailAccountSummary": {
        "type": "object",
        "required": [
          "id",
          "tenantId",
          "sourceApp",
          "countryCode",
          "railId",
          "environment",
          "label",
          "isDefault",
          "hasAccessToken",
          "hasWebhookSecret",
          "hasSecondaryWebhookSecret",
          "hasRefreshToken",
          "hasMtlsIdentity",
          "gatewayMetadata",
          "autoListenTransfers",
          "status",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "sourceApp": {
            "type": "string"
          },
          "countryCode": {
            "type": "string",
            "example": "AR"
          },
          "railId": {
            "type": "string"
          },
          "environment": {
            "type": "string",
            "enum": [
              "live",
              "sandbox"
            ]
          },
          "label": {
            "type": "string"
          },
          "isDefault": {
            "type": "boolean"
          },
          "externalAccountId": {
            "type": [
              "string",
              "null"
            ]
          },
          "externalPosId": {
            "type": [
              "string",
              "null"
            ]
          },
          "hasAccessToken": {
            "type": "boolean"
          },
          "hasWebhookSecret": {
            "type": "boolean"
          },
          "hasSecondaryWebhookSecret": {
            "type": "boolean"
          },
          "hasRefreshToken": {
            "type": "boolean"
          },
          "hasMtlsIdentity": {
            "type": "boolean"
          },
          "gatewayMetadata": {
            "type": "object",
            "additionalProperties": true
          },
          "oauthTokenExpiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "autoListenTransfers": {
            "type": "boolean"
          },
          "lastPolledAt": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "disconnected",
              "inactive"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "VerifyConnectionRequest": {
        "type": "object",
        "required": [
          "tenantId"
        ],
        "properties": {
          "tenantId": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "VerifyConnectionResponse": {
        "type": "object",
        "required": [
          "accountId",
          "railId",
          "verified",
          "liveApiCapable",
          "mode"
        ],
        "properties": {
          "accountId": {
            "type": "string",
            "format": "uuid"
          },
          "railId": {
            "type": "string"
          },
          "verified": {
            "type": "boolean"
          },
          "liveApiCapable": {
            "type": "boolean"
          },
          "mode": {
            "type": "string"
          },
          "upstreamAccountId": {
            "type": "string"
          },
          "matchedExternalAccount": {
            "type": "boolean"
          },
          "discoveredAccountsCount": {
            "type": "integer",
            "minimum": 0
          },
          "cbuInspection": {
            "$ref": "#/components/schemas/ArAccountInspection"
          }
        }
      },
      "SetAccountAutoListenRequest": {
        "type": "object",
        "required": [
          "tenantId",
          "enabled"
        ],
        "properties": {
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "enabled": {
            "type": "boolean"
          }
        }
      },
      "SyncAccountNowRequest": {
        "type": "object",
        "required": [
          "tenantId"
        ],
        "properties": {
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "lookbackMinutes": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 1440
          }
        }
      },
      "SyncAccountNowResponse": {
        "type": "object",
        "required": [
          "accountId",
          "railId",
          "polledEvents",
          "processedMovements",
          "syncedAt"
        ],
        "properties": {
          "accountId": {
            "type": "string",
            "format": "uuid"
          },
          "railId": {
            "type": "string"
          },
          "polledEvents": {
            "type": "integer",
            "minimum": 0
          },
          "processedMovements": {
            "type": "integer",
            "minimum": 0
          },
          "syncedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "StatementFormat": {
        "type": "string",
        "enum": [
          "auto",
          "csv",
          "brubank_pdf"
        ]
      },
      "ImportStatementRequest": {
        "type": "object",
        "required": [
          "tenantId"
        ],
        "properties": {
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "format": {
            "$ref": "#/components/schemas/StatementFormat"
          },
          "contentBase64": {
            "type": [
              "string",
              "null"
            ]
          },
          "contentText": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "ImportStatementResponse": {
        "type": "object",
        "required": [
          "accountId",
          "detectedFormat",
          "statementSha256",
          "parsedRows",
          "enqueuedNew",
          "duplicateRows",
          "processedInline"
        ],
        "properties": {
          "accountId": {
            "type": "string",
            "format": "uuid"
          },
          "detectedFormat": {
            "$ref": "#/components/schemas/StatementFormat"
          },
          "statementSha256": {
            "type": "string"
          },
          "parsedRows": {
            "type": "integer",
            "minimum": 0
          },
          "enqueuedNew": {
            "type": "integer",
            "minimum": 0
          },
          "duplicateRows": {
            "type": "integer",
            "minimum": 0
          },
          "processedInline": {
            "type": "boolean"
          }
        }
      },
      "InspectCbuCvuRequest": {
        "type": "object",
        "required": [
          "cbuOrCvu"
        ],
        "properties": {
          "cbuOrCvu": {
            "type": "string",
            "example": "0070000920000000000018"
          }
        }
      },
      "ArAccountInspection": {
        "type": "object",
        "required": [
          "maskedDigits",
          "kind",
          "entityCode",
          "entityName",
          "connectionMode",
          "directPushWebhooks",
          "interbankingCorporatePull",
          "pennyOwnershipChallengeSupported",
          "statementImportSupported",
          "compatibleRails",
          "guidance"
        ],
        "properties": {
          "maskedDigits": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "bank_cbu",
              "psp_cvu"
            ]
          },
          "entityCode": {
            "type": "string"
          },
          "entityName": {
            "type": [
              "string",
              "null"
            ]
          },
          "connectionMode": {
            "type": "string",
            "enum": [
              "direct_rail_supported",
              "corporate_interbanking_only",
              "closed_retail_bank",
              "psp_without_direct_adapter",
              "unknown_entity"
            ]
          },
          "directPushWebhooks": {
            "type": "boolean"
          },
          "interbankingCorporatePull": {
            "type": "boolean"
          },
          "pennyOwnershipChallengeSupported": {
            "type": "boolean"
          },
          "statementImportSupported": {
            "type": "boolean"
          },
          "compatibleRails": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "guidance": {
            "type": "string"
          }
        }
      },
      "CreateCbuChallengeRequest": {
        "type": "object",
        "required": [
          "tenantId",
          "cbuOrCvu",
          "expectedOwnerCuit",
          "collectorRailAccountId"
        ],
        "properties": {
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "environment": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "live",
              "sandbox",
              null
            ]
          },
          "cbuOrCvu": {
            "type": "string"
          },
          "expectedOwnerCuit": {
            "type": "string",
            "example": "20304050607"
          },
          "collectorRailAccountId": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "CbuOwnershipChallengeSummary": {
        "type": "object",
        "required": [
          "id",
          "tenantId",
          "environment",
          "maskedCbu",
          "entityCode",
          "entityName",
          "expectedOwnerCuit",
          "collectorRailAccountId",
          "challengeAmount",
          "currency",
          "status",
          "verificationLevel",
          "cbuCryptographicallyVerified",
          "verifiedMovementId",
          "clearingNetworkId",
          "expiresAt",
          "verifiedAt",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "environment": {
            "type": "string",
            "enum": [
              "live",
              "sandbox"
            ]
          },
          "maskedCbu": {
            "type": "string"
          },
          "entityCode": {
            "type": "string"
          },
          "entityName": {
            "type": [
              "string",
              "null"
            ]
          },
          "expectedOwnerCuit": {
            "type": "string"
          },
          "collectorRailAccountId": {
            "type": "string",
            "format": "uuid"
          },
          "challengeAmount": {
            "type": "string",
            "example": "1.37"
          },
          "currency": {
            "type": "string",
            "example": "ARS"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "verified",
              "expired"
            ]
          },
          "verificationLevel": {
            "type": [
              "string",
              "null"
            ]
          },
          "cbuCryptographicallyVerified": {
            "type": "boolean"
          },
          "verifiedMovementId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "clearingNetworkId": {
            "type": [
              "string",
              "null"
            ]
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "verifiedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ProvisionVirtualCvuRequest": {
        "type": "object",
        "required": [
          "tenantId",
          "collectorRailAccountId",
          "displayName"
        ],
        "properties": {
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "environment": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "live",
              "sandbox",
              null
            ]
          },
          "collectorRailAccountId": {
            "type": "string",
            "format": "uuid"
          },
          "custodyMode": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "self_collection",
              "tenant_direct",
              "platform_sponsored",
              null
            ]
          },
          "displayName": {
            "type": "string"
          },
          "desiredAlias": {
            "type": [
              "string",
              "null"
            ]
          },
          "externalReference": {
            "type": [
              "string",
              "null"
            ]
          },
          "payoutChallengeId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          }
        }
      },
      "ProvisionedVirtualCvuResponse": {
        "type": "object",
        "required": [
          "id",
          "tenantId",
          "environment",
          "collectorRailAccountId",
          "railId",
          "custodyMode",
          "externalCvuId",
          "cvu",
          "maskedCvu",
          "alias",
          "displayName",
          "beneficiaryCuit",
          "externalReference",
          "payoutChallengeId",
          "status",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "environment": {
            "type": "string",
            "enum": [
              "live",
              "sandbox"
            ]
          },
          "collectorRailAccountId": {
            "type": "string",
            "format": "uuid"
          },
          "railId": {
            "type": "string"
          },
          "custodyMode": {
            "type": "string"
          },
          "externalCvuId": {
            "type": "string"
          },
          "cvu": {
            "type": "string"
          },
          "maskedCvu": {
            "type": "string"
          },
          "alias": {
            "type": [
              "string",
              "null"
            ]
          },
          "displayName": {
            "type": "string"
          },
          "beneficiaryCuit": {
            "type": [
              "string",
              "null"
            ]
          },
          "externalReference": {
            "type": [
              "string",
              "null"
            ]
          },
          "payoutChallengeId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "status": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "VirtualCvuSummary": {
        "type": "object",
        "required": [
          "id",
          "tenantId",
          "environment",
          "collectorRailAccountId",
          "railId",
          "custodyMode",
          "externalCvuId",
          "maskedCvu",
          "alias",
          "displayName",
          "externalReference",
          "payoutChallengeId",
          "status",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "environment": {
            "type": "string",
            "enum": [
              "live",
              "sandbox"
            ]
          },
          "collectorRailAccountId": {
            "type": "string",
            "format": "uuid"
          },
          "railId": {
            "type": "string"
          },
          "custodyMode": {
            "type": "string"
          },
          "externalCvuId": {
            "type": "string"
          },
          "maskedCvu": {
            "type": "string"
          },
          "alias": {
            "type": [
              "string",
              "null"
            ]
          },
          "displayName": {
            "type": "string"
          },
          "externalReference": {
            "type": [
              "string",
              "null"
            ]
          },
          "payoutChallengeId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "status": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "VirtualCvuPaymentInstructionsResponse": {
        "type": "object",
        "required": [
          "id",
          "tenantId",
          "cvu",
          "maskedCvu",
          "alias",
          "displayName",
          "beneficiaryCuit",
          "externalReference",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "cvu": {
            "type": "string"
          },
          "maskedCvu": {
            "type": "string"
          },
          "alias": {
            "type": [
              "string",
              "null"
            ]
          },
          "displayName": {
            "type": "string"
          },
          "beneficiaryCuit": {
            "type": [
              "string",
              "null"
            ]
          },
          "externalReference": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string"
          }
        }
      },
      "VirtualCvuSweepPayout": {
        "type": "object",
        "required": [
          "id",
          "tenantId",
          "environment",
          "virtualCvuId",
          "sourceMovementId",
          "payoutChallengeId",
          "amount",
          "feeAmount",
          "netPayoutAmount",
          "currency",
          "status",
          "providerTransferId",
          "clearingNetworkId",
          "idempotencyKey",
          "attempts",
          "eligibleAt",
          "lastError",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "environment": {
            "type": "string",
            "enum": [
              "live",
              "sandbox"
            ]
          },
          "virtualCvuId": {
            "type": "string",
            "format": "uuid"
          },
          "sourceMovementId": {
            "type": "string",
            "format": "uuid"
          },
          "payoutChallengeId": {
            "type": "string",
            "format": "uuid"
          },
          "amount": {
            "type": "string",
            "example": "15000.00"
          },
          "feeAmount": {
            "type": "string",
            "example": "0.00"
          },
          "netPayoutAmount": {
            "type": "string",
            "example": "15000.00"
          },
          "currency": {
            "type": "string",
            "example": "ARS"
          },
          "status": {
            "type": "string"
          },
          "providerTransferId": {
            "type": [
              "string",
              "null"
            ]
          },
          "clearingNetworkId": {
            "type": [
              "string",
              "null"
            ]
          },
          "idempotencyKey": {
            "type": "string"
          },
          "attempts": {
            "type": "integer",
            "minimum": 0
          },
          "eligibleAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PaymentExpectation": {
        "type": "object",
        "required": [
          "id",
          "tenantId",
          "sourceApp",
          "environment",
          "externalOrderId",
          "expectedAmount",
          "amountTolerance",
          "currency",
          "expectedReference",
          "expectedPayerTaxId",
          "buyerName",
          "buyerDocTipo",
          "buyerDocNro",
          "buyerTaxCondition",
          "autoInvoiceEnabled",
          "fiscalProfileId",
          "fiscalPtoVta",
          "invoiceConcepto",
          "invoiceIvaRate",
          "invoiceDescription",
          "status",
          "expiresAt",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "sourceApp": {
            "type": "string"
          },
          "environment": {
            "type": "string",
            "enum": [
              "live",
              "sandbox"
            ]
          },
          "externalOrderId": {
            "type": [
              "string",
              "null"
            ]
          },
          "expectedAmount": {
            "type": "string",
            "example": "15000.00"
          },
          "amountTolerance": {
            "type": "string",
            "example": "0.00"
          },
          "currency": {
            "type": "string",
            "example": "ARS"
          },
          "expectedReference": {
            "type": [
              "string",
              "null"
            ]
          },
          "expectedPayerTaxId": {
            "type": [
              "string",
              "null"
            ]
          },
          "buyerName": {
            "type": [
              "string",
              "null"
            ]
          },
          "buyerDocTipo": {
            "type": [
              "integer",
              "null"
            ]
          },
          "buyerDocNro": {
            "type": [
              "integer",
              "null"
            ]
          },
          "buyerTaxCondition": {
            "type": [
              "string",
              "null"
            ]
          },
          "autoInvoiceEnabled": {
            "type": "boolean"
          },
          "fiscalProfileId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "fiscalPtoVta": {
            "type": [
              "integer",
              "null"
            ]
          },
          "invoiceConcepto": {
            "type": "integer",
            "enum": [
              1,
              2,
              3
            ]
          },
          "invoiceIvaRate": {
            "type": "string",
            "example": "21.00"
          },
          "invoiceDescription": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "reconciled",
              "expired",
              "cancelled"
            ]
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "RailMovement": {
        "type": "object",
        "required": [
          "id",
          "tenantId",
          "railAccountId",
          "railId",
          "externalMovementId",
          "direction",
          "amount",
          "feeAmount",
          "netAmount",
          "currency",
          "externalReference",
          "payerDocType",
          "payerDoc",
          "payerName",
          "payerIsAccountOwner",
          "clearingNetworkId",
          "occurredAt",
          "rawFacts",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "railAccountId": {
            "type": "string",
            "format": "uuid"
          },
          "railId": {
            "type": "string"
          },
          "externalMovementId": {
            "type": "string"
          },
          "direction": {
            "type": "string",
            "enum": [
              "credit",
              "debit"
            ]
          },
          "amount": {
            "type": "string",
            "example": "15000.00"
          },
          "feeAmount": {
            "type": [
              "string",
              "null"
            ],
            "example": "0.00"
          },
          "netAmount": {
            "type": [
              "string",
              "null"
            ],
            "example": "15000.00"
          },
          "currency": {
            "type": "string",
            "example": "ARS"
          },
          "externalReference": {
            "type": [
              "string",
              "null"
            ]
          },
          "payerDocType": {
            "type": [
              "string",
              "null"
            ]
          },
          "payerDoc": {
            "type": [
              "string",
              "null"
            ]
          },
          "payerName": {
            "type": [
              "string",
              "null"
            ]
          },
          "payerIsAccountOwner": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "clearingNetworkId": {
            "type": [
              "string",
              "null"
            ]
          },
          "virtualCvuId": {
            "type": "string",
            "format": "uuid"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time"
          },
          "rawFacts": {
            "type": "object",
            "additionalProperties": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "RailReconciliation": {
        "type": "object",
        "required": [
          "id",
          "tenantId",
          "environment",
          "movementId",
          "expectationId",
          "matchReason",
          "confidenceBps",
          "amountDelta",
          "autoInvoiceStatus",
          "fiscalIssuanceId",
          "lastError",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "environment": {
            "type": "string",
            "enum": [
              "live",
              "sandbox"
            ]
          },
          "movementId": {
            "type": "string",
            "format": "uuid"
          },
          "expectationId": {
            "type": "string",
            "format": "uuid"
          },
          "matchReason": {
            "type": "string"
          },
          "confidenceBps": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000
          },
          "amountDelta": {
            "type": "string",
            "example": "0.00"
          },
          "autoInvoiceStatus": {
            "type": "string"
          },
          "fiscalIssuanceId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AccountantMovementSummary": {
        "type": "object",
        "required": [
          "creditCount",
          "creditTotalByCurrency",
          "unmatchedCreditCount"
        ],
        "properties": {
          "creditCount": {
            "type": "integer",
            "minimum": 0
          },
          "creditTotalByCurrency": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "example": {
              "ARS": "15000.00"
            }
          },
          "unmatchedCreditCount": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "AccountantReconciliationSummary": {
        "type": "object",
        "required": [
          "totalReconciled",
          "autoInvoicedCount",
          "outcomeUnknownCount"
        ],
        "properties": {
          "totalReconciled": {
            "type": "integer",
            "minimum": 0
          },
          "autoInvoicedCount": {
            "type": "integer",
            "minimum": 0
          },
          "outcomeUnknownCount": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "AccountantFiscalProfileSummary": {
        "type": "object",
        "required": [
          "id",
          "cuit",
          "countryCode",
          "afipEnvironment",
          "taxCondition",
          "arcaEnabled",
          "executionMode",
          "certStatus",
          "certNotAfter"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "cuit": {
            "type": "string"
          },
          "countryCode": {
            "type": "string"
          },
          "afipEnvironment": {
            "type": "string"
          },
          "taxCondition": {
            "type": "string"
          },
          "arcaEnabled": {
            "type": "boolean"
          },
          "executionMode": {
            "type": "string"
          },
          "certStatus": {
            "type": "string"
          },
          "certNotAfter": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "AccountantOverviewResponse": {
        "type": "object",
        "required": [
          "tenantId",
          "environment",
          "movementSummary",
          "reconciliationSummary",
          "fiscalProfiles"
        ],
        "properties": {
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "environment": {
            "type": "string",
            "enum": [
              "live",
              "sandbox"
            ]
          },
          "movementSummary": {
            "$ref": "#/components/schemas/AccountantMovementSummary"
          },
          "reconciliationSummary": {
            "$ref": "#/components/schemas/AccountantReconciliationSummary"
          },
          "fiscalProfiles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountantFiscalProfileSummary"
            }
          }
        }
      },
      "WebhookEndpointSummary": {
        "type": "object",
        "required": [
          "id",
          "tenantId",
          "sourceApp",
          "environment",
          "kind",
          "url",
          "hasSecondarySecret",
          "events",
          "isActive",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenantId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "sourceApp": {
            "type": "string"
          },
          "environment": {
            "type": "string",
            "enum": [
              "live",
              "sandbox"
            ]
          },
          "kind": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "hasSecondarySecret": {
            "type": "boolean"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "isActive": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WebhookDeliverySummary": {
        "type": "object",
        "required": [
          "id",
          "endpointId",
          "tenantId",
          "eventType",
          "payload",
          "status",
          "attempts",
          "eligibleAt",
          "lastResponseCode",
          "lastError",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "endpointId": {
            "type": "string",
            "format": "uuid"
          },
          "tenantId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "eventType": {
            "type": "string"
          },
          "payload": {
            "type": "object",
            "additionalProperties": true
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "claimed",
              "delivered",
              "dead_letter"
            ]
          },
          "attempts": {
            "type": "integer",
            "minimum": 0
          },
          "eligibleAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastResponseCode": {
            "type": [
              "integer",
              "null"
            ]
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ReplayWebhookDeliveryRequest": {
        "type": "object",
        "required": [
          "tenantId"
        ],
        "properties": {
          "tenantId": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "MpOAuthAuthorizeUrlRequest": {
        "type": "object",
        "required": [
          "tenantId",
          "railAccountId",
          "redirectUri"
        ],
        "properties": {
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "railAccountId": {
            "type": "string",
            "format": "uuid"
          },
          "redirectUri": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "MpOAuthAuthorizeUrlResponse": {
        "type": "object",
        "required": [
          "authorizeUrl",
          "state",
          "expiresAt"
        ],
        "properties": {
          "authorizeUrl": {
            "type": "string",
            "format": "uri"
          },
          "state": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MpOAuthExchangeRequest": {
        "type": "object",
        "required": [
          "tenantId",
          "state",
          "code"
        ],
        "properties": {
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "state": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "writeOnly": true
          }
        }
      },
      "SimulateTransferResponse": {
        "type": "object",
        "required": [
          "accepted",
          "duplicate",
          "inboxId",
          "processedInline",
          "movementId",
          "reconciliationId",
          "autoInvoiceStatus",
          "fiscalIssuanceId"
        ],
        "properties": {
          "accepted": {
            "type": "boolean"
          },
          "duplicate": {
            "type": "boolean"
          },
          "inboxId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "processedInline": {
            "type": "boolean"
          },
          "movementId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "reconciliationId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "autoInvoiceStatus": {
            "type": [
              "string",
              "null"
            ]
          },
          "fiscalIssuanceId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          }
        }
      },
      "InboundAcceptResponse": {
        "type": "object",
        "required": [
          "accepted",
          "duplicate"
        ],
        "properties": {
          "accepted": {
            "type": "boolean"
          },
          "duplicate": {
            "type": "boolean"
          },
          "inboxId": {
            "type": "string",
            "format": "uuid"
          },
          "connectivityTest": {
            "type": "boolean"
          }
        }
      }
    },
    "responses": {
      "E400": {
        "description": "Malformed request or invalid header",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E401": {
        "description": "Missing or invalid X-API-Key (or provider signature)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E403": {
        "description": "Key lacks the required scope, or live/sandbox mismatch",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E404": {
        "description": "Resource not found or not visible to this key",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E409": {
        "description": "Conflict (idempotency or state)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E422": {
        "description": "Validation failed",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E429": {
        "description": "Rate limit or monthly quota exceeded",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E502": {
        "description": "Upstream provider error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E503": {
        "description": "Temporarily unavailable",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E413": {
        "description": "Request body exceeds route size limit",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
