{
  "openapi": "3.0.3",
  "info": {
    "title": "RISITECH ADQ API HUB — Adquirência Multiadquirente v1",
    "version": "1.0.0-sandbox",
    "description": "Contrato público das 6 famílias de APIs de adquirência RISITECH para empresas com CORE financeiro próprio. Independente do CMPR administrativo. Nunca expõe custos de provedor, spread RISITECH, credenciais da adquirente ou arquivos EDI brutos. Ambiente Sandbox/HML isolado; liberação LIVE depende de homologação técnica externa."
  },
  "servers": [
    {
      "url": "https://api.doc.risitech.com.br",
      "description": "SANDBOX — Ambiente oficial de documentação e homologação isolada (publicação sujeita à autorização de DNS)"
    },
    {
      "url": "http://127.0.0.1:3180",
      "description": "SANDBOX local isolado (desenvolvimento)"
    }
  ],
  "tags": [
    {
      "name": "Merchants",
      "description": "API 01 — Credenciamento de lojistas PF/PJ, documentação e status"
    },
    {
      "name": "Transactions",
      "description": "API 02 — Consulta de transações de adquirência confirmadas"
    },
    {
      "name": "Receivables",
      "description": "API 03 — Agenda de recebíveis D1/D30 confirmados"
    },
    {
      "name": "Settlements",
      "description": "API 04 — Liquidações financeiras confirmadas"
    },
    {
      "name": "Reconciliation",
      "description": "API 05 — Conciliação EDI, divergências, ajustes/chargebacks e reprocessamento"
    },
    {
      "name": "Pricing",
      "description": "API 06 — Tabelas comerciais contratadas (D1 e D30 separadas, sem custo/spread)"
    }
  ],
  "security": [
    {
      "clientCredentials": []
    }
  ],
  "paths": {
    "/v1/merchants": {
      "get": {
        "tags": [
          "Merchants"
        ],
        "summary": "Listar lojistas vinculados ao cliente autenticado",
        "security": [
          {
            "clientCredentials": [
              "merchants:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "DRAFT",
                "IN_REVIEW",
                "APPROVED",
                "SUSPENDED"
              ]
            }
          },
          {
            "name": "external_reference",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "name": "tax_document",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 18
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Lista paginada de lojistas",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MerchantPage"
                }
              }
            }
          },
          "400": {
            "description": "Filtro inválido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credencial ausente/inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo ou carteira não permitidos",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Limite de requisições excedido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacidade não habilitada/homologada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Merchants"
        ],
        "summary": "Solicitar credenciamento de lojista PF/PJ (idempotente; aprovação RISITECH e adquirente são fluxos separados)",
        "security": [
          {
            "clientCredentials": [
              "merchants:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MerchantCreate"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Solicitação recebida; aguardando aprovação RISITECH e credenciamento no adquirente",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Merchant"
                }
              }
            }
          },
          "400": {
            "description": "Dados cadastrais ou documento inválidos",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credencial ausente/inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo ou carteira não permitidos",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflito de idempotência ou lojista duplicado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Limite de requisições excedido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacidade não habilitada/homologada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/merchants/{merchant_id}": {
      "get": {
        "tags": [
          "Merchants"
        ],
        "summary": "Consultar detalhes, status de credenciamento e MID (quando ativo) do lojista",
        "security": [
          {
            "clientCredentials": [
              "merchants:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "merchant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Consulta autorizada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Merchant"
                }
              }
            }
          },
          "401": {
            "description": "Credencial ausente/inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo ou carteira não permitidos",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Lojista não encontrado no escopo do cliente",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacidade não habilitada/homologada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/merchants/{merchant_id}/documents": {
      "get": {
        "tags": [
          "Merchants"
        ],
        "summary": "Consultar documentação KYC/KYB enviada para o lojista",
        "security": [
          {
            "clientCredentials": [
              "merchants:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "merchant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Lista de documentos",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MerchantDocumentList"
                }
              }
            }
          },
          "401": {
            "description": "Credencial ausente/inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo não permitido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Lojista não encontrado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacidade indisponível",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Merchants"
        ],
        "summary": "Enviar referência e checksum SHA-256 de documento cadastral KYC/KYB (idempotente)",
        "security": [
          {
            "clientCredentials": [
              "merchants:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "merchant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MerchantDocumentCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Documento registrado para análise",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MerchantDocument"
                }
              }
            }
          },
          "400": {
            "description": "Payload inválido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credencial ausente/inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo não permitido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflito de idempotência",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacidade indisponível",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/transactions": {
      "get": {
        "tags": [
          "Transactions"
        ],
        "summary": "Consultar vendas confirmadas por período, lojista, bandeira, modalidade, NSU e status",
        "security": [
          {
            "clientCredentials": [
              "transactions:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "APPROVED",
                "DECLINED",
                "CANCELLED",
                "REFUNDED",
                "CHARGEBACK"
              ]
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "card_network",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "payment_method",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "nsu",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página de transações",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page"
                }
              }
            }
          },
          "401": {
            "description": "Credencial ausente/inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo não permitido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacidade não habilitada/homologada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/transactions/{transaction_id}": {
      "get": {
        "tags": [
          "Transactions"
        ],
        "summary": "Consultar detalhes de uma transação específica da carteira do cliente",
        "security": [
          {
            "clientCredentials": [
              "transactions:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "transaction_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transação encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Transaction"
                }
              }
            }
          },
          "401": {
            "description": "Credencial ausente/inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo não permitido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Transação não encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacidade indisponível",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/receivables": {
      "get": {
        "tags": [
          "Receivables"
        ],
        "summary": "Consultar agenda financeira de recebíveis confirmados (D1 e D30)",
        "security": [
          {
            "clientCredentials": [
              "receivables:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "FORECAST",
                "REGISTERED",
                "ENCUMBERED",
                "SETTLED",
                "CANCELLED"
              ]
            }
          },
          {
            "name": "due_from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "due_to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "settlement_mode",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "D1",
                "D30"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página de recebíveis",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page"
                }
              }
            }
          },
          "401": {
            "description": "Credencial ausente/inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo não permitido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacidade não habilitada/homologada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/settlements": {
      "get": {
        "tags": [
          "Settlements"
        ],
        "summary": "Consultar liquidações financeiras confirmadas",
        "security": [
          {
            "clientCredentials": [
              "settlements:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "PENDING",
                "CONFIRMED",
                "REVERSED",
                "FAILED"
              ]
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página de liquidações",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page"
                }
              }
            }
          },
          "401": {
            "description": "Credencial ausente/inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo não permitido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacidade não habilitada/homologada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/reconciliation": {
      "get": {
        "tags": [
          "Reconciliation"
        ],
        "summary": "Consultar resultados de conciliação da carteira (sem expor arquivos EDI brutos)",
        "security": [
          {
            "clientCredentials": [
              "reconciliation:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "MATCHED",
                "UNMATCHED",
                "PENDING",
                "RECONCILED",
                "DIVERGENT"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 150
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resultados de conciliação",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page"
                }
              }
            }
          },
          "401": {
            "description": "Credencial ausente/inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo não permitido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacidade não habilitada/homologada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/reconciliation/divergences": {
      "get": {
        "tags": [
          "Reconciliation"
        ],
        "summary": "Consultar divergências financeiras identificadas na conciliação",
        "security": [
          {
            "clientCredentials": [
              "reconciliation:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "entity_kind",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "TRANSACTION",
                "RECEIVABLE",
                "SETTLEMENT"
              ]
            }
          },
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "DIVERGENT",
                "MISSING_INTERNAL",
                "MISSING_PROVIDER"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Divergências financeiras",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page"
                }
              }
            }
          },
          "401": {
            "description": "Credencial ausente/inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo não permitido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacidade indisponível",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/reconciliation/adjustments": {
      "get": {
        "tags": [
          "Reconciliation"
        ],
        "summary": "Consultar ajustes financeiros e chargebacks da carteira",
        "security": [
          {
            "clientCredentials": [
              "reconciliation:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "CHARGEBACK",
                "FEE",
                "REVERSAL",
                "CORRECTION",
                "OTHER"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "PENDING",
                "CONFIRMED",
                "REVERSED"
              ]
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Lista de ajustes e chargebacks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page"
                }
              }
            }
          },
          "401": {
            "description": "Credencial ausente/inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo não permitido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacidade indisponível",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/reconciliation/reports": {
      "get": {
        "tags": [
          "Reconciliation"
        ],
        "summary": "Relatório consolidado de conciliação por lojista",
        "security": [
          {
            "clientCredentials": [
              "reconciliation:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Relatório consolidado por lojista",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Credencial ausente/inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo não permitido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacidade indisponível",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/reconciliation/reprocess": {
      "post": {
        "tags": [
          "Reconciliation"
        ],
        "summary": "Solicitar reprocessamento idempotente de conciliação para um período",
        "security": [
          {
            "clientCredentials": [
              "reconciliation:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReconciliationReprocessRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Solicitação de reprocessamento enfileirada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReconciliationJob"
                }
              }
            }
          },
          "401": {
            "description": "Credencial ausente/inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo não permitido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflito de idempotência",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacidade indisponível",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pricing": {
      "get": {
        "tags": [
          "Pricing"
        ],
        "summary": "Consultar exclusivamente a tabela comercial contratada pelo cliente (D1 ou D30), sem custo do adquirente nem spread RISITECH",
        "security": [
          {
            "clientCredentials": [
              "pricing:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "settlement_mode",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "D1",
                "D30"
              ]
            },
            "description": "Tabelas D1 e D30 são versionadas e consultadas separadamente"
          },
          {
            "name": "merchant_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Opcional: retorna tabela comercial específica do lojista, se houver"
          }
        ],
        "responses": {
          "200": {
            "description": "Tabela comercial vigente",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Pricing"
                }
              }
            }
          },
          "401": {
            "description": "Credencial ausente/inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo não permitido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Tabela não publicada para o prazo informado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacidade não habilitada/homologada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pricing/history": {
      "get": {
        "tags": [
          "Pricing"
        ],
        "summary": "Consultar histórico de versões das tabelas comerciais publicadas para o cliente",
        "security": [
          {
            "clientCredentials": [
              "pricing:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "settlement_mode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "D1",
                "D30"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Histórico comercial",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PricingHistory"
                }
              }
            }
          },
          "401": {
            "description": "Credencial ausente/inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo não permitido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacidade indisponível",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "clientCredentials": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "/oauth/token",
            "scopes": {
              "merchants:read": "Consultar lojistas próprios e documentação",
              "merchants:write": "Solicitar cadastro de lojistas e enviar documentação",
              "transactions:read": "Consultar transações próprias confirmadas",
              "receivables:read": "Consultar agenda de recebíveis própria",
              "settlements:read": "Consultar liquidações próprias confirmadas",
              "reconciliation:read": "Consultar conciliação, divergências, ajustes e relatórios da própria carteira",
              "reconciliation:write": "Solicitar reprocessamento idempotente de conciliação",
              "pricing:read": "Consultar tabela comercial própria e histórico de versões"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "request_id"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "request_id": {
                "type": "string",
                "format": "uuid"
              }
            }
          }
        }
      },
      "Page": {
        "type": "object",
        "required": [
          "items",
          "next_cursor"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "MerchantPage": {
        "type": "object",
        "required": [
          "items",
          "next_cursor"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Merchant"
            }
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "MerchantCreate": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "legal_name",
          "display_name",
          "tax_document"
        ],
        "properties": {
          "legal_name": {
            "type": "string",
            "minLength": 2,
            "maxLength": 200
          },
          "display_name": {
            "type": "string",
            "minLength": 2,
            "maxLength": 200
          },
          "tax_document": {
            "type": "string",
            "minLength": 11,
            "maxLength": 18
          },
          "external_reference": {
            "type": "string",
            "maxLength": 120
          },
          "settlement_mode": {
            "type": "string",
            "enum": [
              "D1",
              "D30"
            ],
            "default": "D30"
          }
        }
      },
      "Merchant": {
        "type": "object",
        "required": [
          "id",
          "status",
          "legal_name",
          "display_name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "DRAFT",
              "IN_REVIEW",
              "APPROVED",
              "SUSPENDED"
            ]
          },
          "risitech_approval_status": {
            "type": "string",
            "enum": [
              "PENDING",
              "IN_REVIEW",
              "APPROVED",
              "REJECTED",
              "SUSPENDED"
            ]
          },
          "acquirer_status": {
            "type": "string"
          },
          "mid": {
            "type": "string",
            "nullable": true
          },
          "legal_name": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "tax_document": {
            "type": "string",
            "nullable": true
          },
          "settlement_mode": {
            "type": "string",
            "enum": [
              "D1",
              "D30"
            ]
          },
          "external_reference": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "MerchantDocumentCreate": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "document_type",
          "file_name",
          "mime_type",
          "size_bytes",
          "sha256",
          "storage_ref"
        ],
        "properties": {
          "document_type": {
            "type": "string",
            "enum": [
              "SOCIAL_CONTRACT",
              "CNPJ_CARD",
              "ID_DOCUMENT",
              "PROOF_OF_ADDRESS",
              "BANK_ACCOUNT_PROOF",
              "SELFIE_KYC",
              "OTHER"
            ]
          },
          "file_name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "mime_type": {
            "type": "string",
            "enum": [
              "application/pdf",
              "image/jpeg",
              "image/png"
            ]
          },
          "size_bytes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10485760
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "storage_ref": {
            "type": "string",
            "minLength": 3,
            "maxLength": 256
          }
        }
      },
      "MerchantDocument": {
        "type": "object",
        "required": [
          "id",
          "merchant_id",
          "document_type",
          "verification_status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "merchant_id": {
            "type": "string",
            "format": "uuid"
          },
          "document_type": {
            "type": "string"
          },
          "file_name": {
            "type": "string"
          },
          "mime_type": {
            "type": "string"
          },
          "size_bytes": {
            "type": "integer"
          },
          "sha256": {
            "type": "string"
          },
          "verification_status": {
            "type": "string",
            "enum": [
              "SUBMITTED",
              "IN_REVIEW",
              "APPROVED",
              "REJECTED"
            ]
          }
        }
      },
      "MerchantDocumentList": {
        "type": "object",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MerchantDocument"
            }
          }
        }
      },
      "Transaction": {
        "type": "object",
        "required": [
          "id",
          "merchant_id",
          "amount_minor",
          "status",
          "occurred_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "merchant_id": {
            "type": "string",
            "format": "uuid"
          },
          "external_transaction_id": {
            "type": "string"
          },
          "nsu": {
            "type": "string",
            "nullable": true
          },
          "authorization_code": {
            "type": "string",
            "nullable": true
          },
          "amount_minor": {
            "type": "string"
          },
          "gross_amount_minor": {
            "type": "string"
          },
          "net_amount_minor": {
            "type": "string",
            "nullable": true
          },
          "currency": {
            "type": "string"
          },
          "card_network": {
            "type": "string",
            "nullable": true
          },
          "payment_method": {
            "type": "string"
          },
          "installments": {
            "type": "integer"
          },
          "status": {
            "type": "string"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time"
          },
          "data_origin": {
            "type": "string"
          }
        }
      },
      "ReconciliationReprocessRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "period_from",
          "period_to"
        ],
        "properties": {
          "merchant_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "period_from": {
            "type": "string",
            "format": "date"
          },
          "period_to": {
            "type": "string",
            "format": "date"
          }
        }
      },
      "ReconciliationJob": {
        "type": "object",
        "required": [
          "id",
          "period_from",
          "period_to",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "merchant_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "period_from": {
            "type": "string",
            "format": "date"
          },
          "period_to": {
            "type": "string",
            "format": "date"
          },
          "status": {
            "type": "string",
            "enum": [
              "QUEUED",
              "PROCESSING",
              "COMPLETED",
              "FAILED"
            ]
          },
          "requested_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Pricing": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "table_id",
          "version",
          "valid_from",
          "rates"
        ],
        "properties": {
          "table_id": {
            "type": "string",
            "format": "uuid"
          },
          "version": {
            "type": "integer",
            "minimum": 1
          },
          "valid_from": {
            "type": "string",
            "format": "date"
          },
          "rates": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "brand",
                "method",
                "installments_min",
                "installments_max",
                "mdr_bps",
                "settlement_mode"
              ],
              "properties": {
                "brand": {
                  "type": "string"
                },
                "method": {
                  "type": "string"
                },
                "installments_min": {
                  "type": "integer",
                  "minimum": 1
                },
                "installments_max": {
                  "type": "integer",
                  "minimum": 1
                },
                "mdr_bps": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 10000
                },
                "settlement_mode": {
                  "type": "string",
                  "enum": [
                    "D1",
                    "D30"
                  ]
                }
              }
            }
          }
        }
      },
      "PricingHistory": {
        "type": "object",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "table_id",
                "version",
                "valid_from",
                "settlement_mode",
                "status"
              ],
              "properties": {
                "table_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "merchant_id": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": true
                },
                "version": {
                  "type": "integer"
                },
                "valid_from": {
                  "type": "string",
                  "format": "date"
                },
                "settlement_mode": {
                  "type": "string",
                  "enum": [
                    "D1",
                    "D30"
                  ]
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "PUBLISHED",
                    "SUPERSEDED"
                  ]
                },
                "published_at": {
                  "type": "string",
                  "format": "date-time",
                  "nullable": true
                },
                "change_summary": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          }
        }
      }
    }
  }
}