{
  "openapi": "3.1.0",
  "info": {
    "title": "KodaCash Provider Integration Kit",
    "version": "v1",
    "description": "ARS (Argentina) merchant integration. Check QR and terms, explicitly confirm, then poll order status. Account permissions and route readiness determine availability."
  },
  "servers": [
    {
      "url": "https://kodacash.app/integrations",
      "description": "KodaCash Integrations"
    }
  ],
  "security": [
    {
      "PartnerBearer": []
    }
  ],
  "paths": {
    "/v1/capabilities": {
      "get": {
        "operationId": "getCapabilities",
        "summary": "Discover enabled currency and payment profiles",
        "responses": {
          "200": {
            "description": "Available capabilities for the merchant and requested mode",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Capabilities"
                }
              }
            }
          },
          "401": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "400": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account role or execution mode is forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Merchant automation policy does not permit this live route.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request rejected; inspect error.code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "description": "Returns payment-ready routes currently available to the authenticated merchant in the selected mode; merchant automation, account/profile scope and limits still apply.",
        "parameters": [
          {
            "name": "mode",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "sandbox",
                "live"
              ],
              "default": "sandbox"
            }
          }
        ]
      }
    },
    "/v1/orders": {
      "post": {
        "operationId": "createOrder",
        "summary": "Accept one idempotent order",
        "description": "Create a sandbox instruction. Live uses the payment-check confirmation flow and returns 409 preparation_required here. HTTP 202 acknowledges persistence. Exact replay returns 200 and changed immutable content returns 409. The default execution mode is sandbox.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateOrder"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Existing order replay",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "202": {
            "description": "New order persisted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "400": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, expired/changed quote, limits, or merchant automation admission denied. Inspect error.code; merchant_automation_required, merchant_automation_disabled and merchant_route_not_allowed are explicit policy failures.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account role or execution mode is forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/orders/{order_id}": {
      "get": {
        "operationId": "getOrder",
        "parameters": [
          {
            "name": "order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "summary": "Read an owned order without triggering payment",
        "responses": {
          "200": {
            "description": "Order state and distinct settlement state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "401": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Request rejected; inspect error.code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request rejected; inspect error.code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "description": "Read the saved payment status and settlement. For live orders, KodaCash reconciles missing final rates and ledger debits in the background. Poll the same order until the required fields are populated."
      }
    },
    "/v1/orders/{order_id}/events": {
      "get": {
        "operationId": "getOrderEvents",
        "parameters": [
          {
            "name": "order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "summary": "Read durable events for an owned order in status_version order",
        "description": "Saved events ordered by order.status_version, without pagination. Deduplicate by event_id. Polling: start at five seconds, back off to 15-30 seconds. Outbound webhooks are not supported.",
        "responses": {
          "200": {
            "description": "Durable ordered events",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Events"
                }
              }
            }
          },
          "401": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Request rejected; inspect error.code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request rejected; inspect error.code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/payment-checks": {
      "post": {
        "operationId": "createPaymentCheck",
        "summary": "Check QR and obtain terms",
        "description": "Submit the QR and amount. For the default ARS pricing policy, KodaCash returns a Bitso estimate in USDT before contacting the payment provider. Read check.status, can_confirm and expires_at. Reusing the same idempotency_key and request returns the saved check.",
        "responses": {
          "201": {
            "description": "Saved check, which can be ready, checking, failed or confirmed. Inspect status, can_confirm and failure_code before confirmation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentCheckEnvelope"
                }
              }
            }
          },
          "400": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, expired/changed quote, limits, or merchant automation admission denied. Inspect error.code; merchant_automation_required, merchant_automation_disabled and merchant_route_not_allowed are explicit policy failures.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePaymentCheck"
              }
            }
          }
        }
      }
    },
    "/v1/payment-checks/{check_id}": {
      "get": {
        "operationId": "readPaymentCheck",
        "summary": "Read a saved payment check",
        "description": "Read saved terms and current eligibility. After 409 quote_changed, use this endpoint to retrieve the updated terms and fingerprint for the same check.",
        "responses": {
          "200": {
            "description": "Saved check, which can be ready, checking, failed or confirmed. Inspect status, can_confirm and failure_code before confirmation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentCheckEnvelope"
                }
              }
            }
          },
          "400": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "check_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/v1/payment-checks/{check_id}/refresh": {
      "post": {
        "operationId": "refreshPaymentCheck",
        "summary": "Refresh terms before confirmation",
        "description": "Send {} to request a fresh estimate on an unexpired check. Review the returned terms and fingerprint. For an expired check, create a new check with a new idempotency_key.",
        "responses": {
          "200": {
            "description": "Saved check, which can be ready, checking, failed or confirmed. Inspect status, can_confirm and failure_code before confirmation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentCheckEnvelope"
                }
              }
            }
          },
          "400": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmptyObject"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "check_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/v1/payment-checks/{check_id}/confirm": {
      "post": {
        "operationId": "confirmPaymentCheck",
        "summary": "Confirm the displayed quote and create one order",
        "description": "Submit the fingerprint accepted by the merchant. For a Bitso estimate, KodaCash now checks the provider terms. A higher estimated debit or a different or newly resolved recipient requires fresh consent. Read the same check after 409 quote_changed and confirm the updated fingerprint only after approval. If the pricing policy changed, refresh the check first. Live execution requires an enabled route, merchant automation, permissions and available limits.",
        "responses": {
          "202": {
            "description": "Order accepted. Exact replay returns the same order_id. Poll GET /v1/orders/{order_id} for the result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConfirmPaymentResponse"
                }
              }
            }
          },
          "400": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error.code. quote_changed requires a new review of the saved terms. rate_policy_changed requires a refresh.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "quote_changed"
                  }
                }
              }
            }
          },
          "413": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error.code and integration guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConfirmPaymentCheck"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "check_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "PartnerBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "KodaCash-issued server-side API key, scoped to its merchant, permissions and permitted modes. Separate from cabinet credentials and upstream provider credentials."
      }
    },
    "schemas": {
      "CreateOrder": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "external_order_id",
          "currency",
          "amount",
          "payment_method",
          "payment_data",
          "expires_at"
        ],
        "properties": {
          "external_order_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
          },
          "currency": {
            "type": "string",
            "description": "This integration documents ARS (Argentina). Verify account access through GET /v1/capabilities for the requested mode."
          },
          "amount": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,17})(\\.[0-9]{1,8})?$",
            "description": "Positive decimal string in currency units. Fractional digits must not exceed amount_scale; amount * 10^amount_scale must not exceed 9000000000000000000. Use decimal arithmetic."
          },
          "payment_method": {
            "type": "string",
            "enum": [
              "qr"
            ]
          },
          "payment_data": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "qr_payload"
            ],
            "properties": {
              "qr_payload": {
                "type": "string",
                "minLength": 1,
                "description": "Nonempty QR text. Maximum 4096 UTF-8 bytes in live and 8192 in sandbox. Sandbox accepts KODA-SANDBOX:<currency>:<scenario> (success, reject, pending or timeout). Routes advertising emv_ars also accept Argentine EMV QR text for local simulation. Live additionally applies the configured provider QR constraints. Direct live orders are not accepted."
              }
            }
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "Future, timezone-qualified expiry. A replay returns the existing order even after expiry."
          },
          "execution_mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ],
            "default": "sandbox",
            "description": "Defaults to sandbox. Live requires the payment-check confirmation flow."
          }
        }
      },
      "Order": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "order_id",
          "external_order_id",
          "currency",
          "amount",
          "payment_method",
          "status",
          "status_version",
          "executor_reference",
          "failure_code",
          "expires_at",
          "created_at",
          "updated_at",
          "execution_mode",
          "settlement"
        ],
        "properties": {
          "order_id": {
            "type": "string",
            "format": "uuid"
          },
          "external_order_id": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "amount": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,17})(\\.[0-9]{1,8})?$",
            "description": "Exact decimal string. Positive amount; allowed precision comes from /v1/capabilities."
          },
          "payment_method": {
            "type": "string",
            "enum": [
              "qr"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "accepted",
              "processing",
              "pending_reconciliation",
              "succeeded",
              "failed",
              "expired"
            ]
          },
          "status_version": {
            "type": "integer",
            "minimum": 1,
            "description": "Increases on saved status, reference, failure or settlement changes."
          },
          "executor_reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "Executor operation reference; treat as opaque."
          },
          "failure_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "execution_mode": {
            "type": "string",
            "enum": [
              "simulated",
              "live"
            ],
            "description": "simulated never denotes a real payment. live is reserved for a separately activated real execution service."
          },
          "settlement": {
            "$ref": "#/components/schemas/Settlement"
          },
          "pricing": {
            "$ref": "#/components/schemas/Pricing"
          }
        }
      },
      "Pricing": {
        "type": "object",
        "additionalProperties": false,
        "description": "Pricing terms captured by the payment check. The order retains the original estimate and records the final provider rate when it becomes available. Settlement separately records provider ledger evidence. Pricing may be absent on older records and unpriced flows.",
        "required": [
          "source",
          "version",
          "rate",
          "estimated_rate",
          "rate_base",
          "rate_quote",
          "estimated_amount",
          "koda_fee_amount",
          "koda_fee_currency",
          "rate_status"
        ],
        "properties": {
          "source": {
            "type": "string",
            "enum": [
              "provider",
              "fixed",
              "bitso"
            ],
            "description": "Source of the displayed estimate. Provider uses the provider quote, fixed uses the merchant's configured rate, and bitso uses the Bitso market estimate for ARS/USDT. On orders priced with a variable estimate, the confirmed rate comes from provider settlement."
          },
          "version": {
            "type": "integer",
            "minimum": 0,
            "description": "Pricing configuration version captured by the payment check."
          },
          "rate": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^(0|[1-9][0-9]{0,23})(\\.[0-9]{1,18})?$",
            "description": "Rate in units of rate_quote per unit of rate_base. Use rate_status to distinguish an estimated, fixed or confirmed rate. For provider and Bitso pricing, an order has a null rate until provider settlement confirms the rate."
          },
          "estimated_rate": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^(0|[1-9][0-9]{0,23})(\\.[0-9]{1,18})?$",
            "description": "Rate captured at the payment check, retained when the provider confirms a final rate."
          },
          "initial_source": {
            "type": "string",
            "const": "bitso",
            "description": "Source of the initial estimate retained when updated provider terms required new confirmation."
          },
          "initial_rate": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,23})(\\.[0-9]{1,18})?$",
            "description": "Original Bitso rate retained after updated provider terms required new confirmation."
          },
          "initial_estimated_amount": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,23})(\\.[0-9]{1,18})?$",
            "description": "Original Bitso estimate in rate_quote retained after updated provider terms required new confirmation."
          },
          "final_rate_source": {
            "type": "string",
            "const": "provider",
            "description": "Source of the confirmed order rate for quotes that originated with a Bitso estimate."
          },
          "rate_base": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "description": "Payment currency."
          },
          "rate_quote": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[A-Z0-9][A-Z0-9._:-]{0,31}$",
            "description": "Asset in which the rate expresses one unit of the payment currency."
          },
          "estimated_amount": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^(0|[1-9][0-9]{0,23})(\\.[0-9]{1,18})?$",
            "description": "Indicative debit in rate_quote. Confirmation approves this estimate. The provider may settle a different amount."
          },
          "koda_fee_amount": {
            "type": "string",
            "const": "0",
            "description": "KodaCash fee amount."
          },
          "koda_fee_currency": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[A-Z0-9][A-Z0-9._:-]{0,31}$",
            "description": "Asset of the KodaCash fee when available."
          },
          "rate_status": {
            "type": "string",
            "enum": [
              "estimated",
              "confirmed",
              "fixed",
              "unavailable"
            ]
          }
        }
      },
      "Settlement": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "status",
          "asset",
          "estimated_amount",
          "actual_debit",
          "rate",
          "rate_base",
          "rate_quote",
          "fee_amount",
          "fee_currency"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "unknown",
              "confirmed"
            ]
          },
          "asset": {
            "type": [
              "string",
              "null"
            ]
          },
          "estimated_amount": {
            "type": [
              "string",
              "null"
            ]
          },
          "actual_debit": {
            "type": [
              "string",
              "null"
            ],
            "description": "Posted debit in asset, as a decimal string. May be higher or lower than the approved estimate. Null until reconciled."
          },
          "rate": {
            "type": [
              "string",
              "null"
            ],
            "description": "Finalized operation rate; null before finalization. Direction is rate_base to rate_quote."
          },
          "rate_base": {
            "type": [
              "string",
              "null"
            ]
          },
          "rate_quote": {
            "type": [
              "string",
              "null"
            ]
          },
          "fee_amount": {
            "type": [
              "string",
              "null"
            ]
          },
          "fee_currency": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "description": "Provider settlement and payment status are recorded separately. The final rate and actual debit can arrive independently. ARS sandbox orders confirmed from a Bitso estimate use simulated settlement values."
      },
      "Error": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code"
            ],
            "properties": {
              "code": {
                "type": "string"
              }
            },
            "additionalProperties": false
          }
        }
      },
      "Event": {
        "type": "object",
        "required": [
          "event_id",
          "type",
          "created_at",
          "order"
        ],
        "additionalProperties": false,
        "properties": {
          "event_id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "type": "string",
            "const": "order.updated"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "order": {
            "$ref": "#/components/schemas/Order"
          }
        }
      },
      "Events": {
        "type": "object",
        "required": [
          "events"
        ],
        "additionalProperties": false,
        "properties": {
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Event"
            }
          }
        }
      },
      "Capabilities": {
        "type": "object",
        "required": [
          "api_version",
          "environment",
          "execution_mode",
          "routes"
        ],
        "properties": {
          "api_version": {
            "type": "string",
            "const": "v1"
          },
          "environment": {
            "type": "string",
            "enum": [
              "sandbox",
              "production"
            ]
          },
          "execution_mode": {
            "type": "string",
            "enum": [
              "simulated",
              "live"
            ]
          },
          "routes": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "id",
                "currency",
                "amount_scale",
                "payment_method",
                "qr_formats",
                "settlement_assets",
                "availability"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "currency": {
                  "type": "string"
                },
                "amount_scale": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 8
                },
                "payment_method": {
                  "type": "string",
                  "const": "qr"
                },
                "qr_formats": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "settlement_assets": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "availability": {
                  "type": "string",
                  "enum": [
                    "sandbox_only",
                    "active",
                    "disabled"
                  ]
                }
              }
            }
          }
        }
      },
      "Routing": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "route_id",
          "direction_id",
          "provider_id",
          "merchant_id",
          "mode"
        ],
        "properties": {
          "route_id": {
            "type": "string"
          },
          "direction_id": {
            "type": "string"
          },
          "provider_id": {
            "type": "string"
          },
          "merchant_id": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ]
          }
        }
      },
      "CreatePaymentCheck": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "merchant_id",
          "external_order_id",
          "currency",
          "amount",
          "payment_method",
          "payment_data",
          "idempotency_key"
        ],
        "properties": {
          "merchant_id": {
            "type": "string",
            "description": "Your assigned merchant ID. Bearer access remains tenant-scoped for all roles.",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
          },
          "external_order_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
          },
          "currency": {
            "type": "string",
            "description": "This integration documents ARS (Argentina). Verify account access through GET /v1/capabilities for the requested mode."
          },
          "amount": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,17})(\\.[0-9]{1,8})?$",
            "description": "Positive decimal string in currency units. Fractional digits must not exceed amount_scale; amount * 10^amount_scale must not exceed 9000000000000000000. Use decimal arithmetic."
          },
          "payment_method": {
            "type": "string",
            "enum": [
              "qr"
            ]
          },
          "payment_data": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "qr_payload"
            ],
            "properties": {
              "qr_payload": {
                "type": "string",
                "minLength": 1,
                "description": "Nonempty QR text. Maximum 4096 UTF-8 bytes in live and 8192 in sandbox. Sandbox accepts KODA-SANDBOX:<currency>:<scenario> (success, reject, pending or timeout). Routes advertising emv_ars also accept Argentine EMV QR text for local simulation. Live additionally applies the configured provider QR constraints. Direct live orders are not accepted."
              }
            }
          },
          "idempotency_key": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
          },
          "execution_mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ],
            "default": "sandbox"
          }
        },
        "example": {
          "merchant_id": "your-merchant-id",
          "external_order_id": "ars-order-001",
          "idempotency_key": "check-ars-001",
          "currency": "ARS",
          "amount": "3000.00",
          "payment_method": "qr",
          "payment_data": {
            "qr_payload": "KODA-SANDBOX:ARS:success"
          },
          "execution_mode": "sandbox"
        }
      },
      "CheckSettlement": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "asset",
          "estimated_amount",
          "rate",
          "rate_base",
          "rate_quote",
          "fee_amount",
          "fee_currency"
        ],
        "properties": {
          "asset": {
            "type": [
              "string",
              "null"
            ]
          },
          "estimated_amount": {
            "type": [
              "string",
              "null"
            ]
          },
          "rate": {
            "type": [
              "string",
              "null"
            ]
          },
          "rate_base": {
            "type": [
              "string",
              "null"
            ]
          },
          "rate_quote": {
            "type": [
              "string",
              "null"
            ]
          },
          "fee_amount": {
            "type": [
              "string",
              "null"
            ]
          },
          "fee_currency": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "description": "Indicative terms. The initial Bitso check mirrors the market estimate here. After a provider requote these fields reflect provider terms. Rates are in rate_quote per unit of rate_base."
      },
      "CheckLimits": {
        "type": "object",
        "required": [
          "allowed",
          "violations",
          "usage"
        ],
        "properties": {
          "allowed": {
            "type": "boolean"
          },
          "violations": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "usage": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        },
        "description": "Current merchant and provider policy checks. Policy changes and concurrent reservations are rechecked atomically on confirmation."
      },
      "PaymentCheck": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "check_id",
          "status",
          "execution_mode",
          "merchant_id",
          "currency",
          "amount",
          "payee",
          "settlement",
          "expires_at",
          "routing",
          "limits",
          "can_confirm",
          "quote_fingerprint",
          "order_id",
          "failure_code",
          "confirmation_enabled"
        ],
        "properties": {
          "check_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "checking",
              "ready",
              "failed",
              "confirmed"
            ]
          },
          "execution_mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ]
          },
          "merchant_id": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "amount": {
            "type": "string"
          },
          "payee": {
            "type": [
              "string",
              "null"
            ],
            "description": "Recipient when available. On a Bitso estimate before the provider check, the recipient can come from the QR and has not been verified by the provider."
          },
          "payee_verified": {
            "type": "boolean",
            "description": "Present as false on the preliminary Bitso check. The payee may be a name extracted from the QR or null."
          },
          "rate_observed_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the Bitso market rate was observed."
          },
          "settlement": {
            "$ref": "#/components/schemas/CheckSettlement"
          },
          "pricing": {
            "$ref": "#/components/schemas/Pricing"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "Expiry of the current terms. Use the timestamp returned with the latest quote."
          },
          "routing": {
            "$ref": "#/components/schemas/Routing"
          },
          "limits": {
            "$ref": "#/components/schemas/CheckLimits"
          },
          "can_confirm": {
            "type": "boolean",
            "description": "Confirmation requires a fresh quote with current pricing terms, a payment-ready route, account permission, limits and approval by the applicable merchant automation policy."
          },
          "quote_fingerprint": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[0-9a-f]{64}$",
            "description": "Fingerprint of the displayed quote and captured pricing terms. Use the fingerprint returned by the latest check read or refresh."
          },
          "order_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "failure_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "Preparation and pricing errors appear here with status=failed and can_confirm=false. Examples include bitso_rate_unavailable, invalid_provider_quote, provider_check_unavailable, rate_quote_mismatch and rate_amount_out_of_range. Creation returns HTTP 201 and refresh/read returns HTTP 200 for saved failures."
          },
          "confirmation_enabled": {
            "type": "boolean",
            "description": "Whether the pinned route currently permits payment. can_confirm additionally requires fresh terms, effective account/profile permissions, limits and the merchant automation policy."
          }
        }
      },
      "PaymentCheckEnvelope": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "check"
        ],
        "properties": {
          "check": {
            "$ref": "#/components/schemas/PaymentCheck"
          }
        }
      },
      "ConfirmPaymentCheck": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "confirm",
          "quote_fingerprint"
        ],
        "properties": {
          "confirm": {
            "type": "boolean",
            "const": true
          },
          "quote_fingerprint": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        }
      },
      "ConfirmPaymentResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "order",
          "check"
        ],
        "properties": {
          "order": {
            "$ref": "#/components/schemas/ConfirmedOrder"
          },
          "check": {
            "$ref": "#/components/schemas/PaymentCheck"
          }
        }
      },
      "EmptyObject": {
        "type": "object",
        "additionalProperties": false,
        "required": [],
        "properties": {}
      },
      "ConfirmedOrder": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "order_id",
          "external_order_id",
          "currency",
          "amount",
          "payment_method",
          "status",
          "status_version",
          "executor_reference",
          "failure_code",
          "expires_at",
          "created_at",
          "updated_at",
          "execution_mode",
          "settlement",
          "partner_id",
          "routing"
        ],
        "properties": {
          "order_id": {
            "type": "string",
            "format": "uuid"
          },
          "external_order_id": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "amount": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,17})(\\.[0-9]{1,8})?$",
            "description": "Exact decimal string. Positive amount; allowed precision comes from /v1/capabilities."
          },
          "payment_method": {
            "type": "string",
            "enum": [
              "qr"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "accepted",
              "processing",
              "pending_reconciliation",
              "succeeded",
              "failed",
              "expired"
            ]
          },
          "status_version": {
            "type": "integer",
            "minimum": 1
          },
          "executor_reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "failure_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "execution_mode": {
            "type": "string",
            "enum": [
              "simulated",
              "live"
            ],
            "description": "simulated never denotes a real payment. live is reserved for a separately activated real execution service."
          },
          "settlement": {
            "$ref": "#/components/schemas/Settlement"
          },
          "pricing": {
            "$ref": "#/components/schemas/Pricing"
          },
          "partner_id": {
            "type": "string"
          },
          "routing": {
            "$ref": "#/components/schemas/Routing"
          }
        }
      }
    }
  }
}
