{
  "openapi": "3.0.3",
  "info": {
    "title": "AvalonPay API",
    "version": "1.0.0",
    "description": "API REST AvalonPay para autenticação, saldo, Pix, checkout de cartão, boleto, saques e pagamentos por QR Code. Use HTTPS e mantenha as credenciais no backend da sua aplicação. A especificação contém operações disponíveis no serviço. Inclui pagamentos Pix em lote com importação, revisão, agendamento e retorno ERP.\n\nInclui a API Cripto v1 para BNB Smart Chain, Ethereum Mainnet e TRON: catálogo, carteiras, saldos, depósitos, saques, swaps e webhooks. Saques usam a política financeira e o ledger da conta. Swaps same-chain suportam BNB→token BEP-20 aprovado na BSC e TRX→USDT TRC20 na TRON, com origem nativa. Swaps cross-chain via 1Click podem usar BNB ou token BEP-20 aprovado como origem na BSC, ou TRX nativo ou USDT TRC20 na TRON, quando houver rota disponível. A cotação é dry-run; POST /swaps cria a ordem real e a conclusão exige confirmação do ativo na rede de destino. O modo público adiciona 25 bps (0,25%) à estimativa de saída. Conversão livre de BRL para cripto não faz parte da API cripto OAuth. A compra gerenciada de USDT TRON em BRL está disponível separadamente em /api/v1/crypto/usdt-tron, autenticada com JWT da conta e cotada por Binance Spot USDTBRL best ask + spread AvalonPay configurado. Esta especificação lista o contrato público AvalonPay; rotas internas de integração não fazem parte do contrato para clientes. A disponibilidade de depósitos e saques depende dos campos *_enabled do catálogo.\n\nWebhooks de pagamentos: configure um destino HTTPS fixo por conta na página Credenciais API ou por /api/webhooks com o escopo webhooks.manage. Os eventos são assinados com HMAC-SHA256 e enviados somente ao destino ativo. clientCallbackUrl é legado e ignorado.\n\nMED manual do Compliance: casos com source=compliance ficam disponíveis em GET /api/infractions. A defesa é somente texto e é registrada na AvalonPay para acompanhamento do Compliance, sem chamada ao provedor. Com webhook ativo e eventos MED selecionados, a API recebe med.received, med.balance_changed, med.defense_submitted, med.updated e med.resolved.\n\nVenda de USDT TRON por Pix (API JWT de conta aprovada): a cotação usa Binance Spot USDTBRL best bid, spread da AvalonPay e tarifas globais de cripto; o cliente comprova controle da carteira com assinatura TronLink e informa o hash da transferência TRC20. Só uma transferência solidificada, exata e dentro da validade segue para processamento do pagamento. A conclusão é registrada após conciliação do Pix. Consulte #usdt-tron-sale na documentação.\n\n\nAPI JWT de cartões virtuais: GET /api/v1/cards, POST /api/v1/cards/quote, POST /api/v1/cards/confirm, POST /api/v1/cards/{id}/otp (PIN e 2FA quando configurado) e GET /api/v1/cards/operations/{id}. Valores de entrada e débito em BRL; cotação sem débito; confirmação idempotente com PIN e consulta do mesmo pedido após timeout. Tarifas padrão: emissão R$ 4,99, KYC R$ 3,99, recarga R$ 2,99 + 5%, mensalidade R$ 1,99 por cartão ativo, autorização aprovada R$ 1,99, FX 2% apenas para moeda diferente de USD e compra internacional 0,50% somente com país do estabelecimento e do cartão confirmados. Tarifas sem saldo ficam pendentes e são tentadas novamente sem saldo negativo. A cotação mostra os valores aplicados à conta.",
    "x-last-updated": "2026-11-22"
  },
  "servers": [
    {
      "url": "https://api.avalonpay.com.br",
      "description": "Produção"
    }
  ],
  "tags": [
    {
      "name": "Autenticação"
    },
    {
      "name": "Conta"
    },
    {
      "name": "Pagamentos"
    },
    {
      "name": "Saques"
    },
    {
      "name": "Pagamentos em lote",
      "description": "Importar, autorizar e conciliar pagamentos Pix em lote."
    },
    {
      "name": "Criptomoedas · OAuth"
    },
    {
      "name": "Criptomoedas · Catálogo"
    },
    {
      "name": "Criptomoedas · Carteiras"
    },
    {
      "name": "Criptomoedas · Saldos"
    },
    {
      "name": "Criptomoedas · Extrato"
    },
    {
      "name": "Criptomoedas · Depósitos"
    },
    {
      "name": "Criptomoedas · Envios"
    },
    {
      "name": "Criptomoedas · Swaps"
    },
    {
      "name": "Criptomoedas · Webhooks"
    },
    {
      "name": "Webhooks de pagamentos",
      "description": "Destino único por conta para eventos Pix, QR Code Pix, boleto, cartão e MED. As entregas são assinadas com HMAC-SHA256 sobre timestamp + ponto + corpo HTTP bruto. Use timestamp recente, compare a assinatura em tempo constante e deduplique pelo event.id. Entregas sem HTTP 2xx recebem até oito tentativas; para MED manual do Compliance, configure os eventos med.* no destino da conta."
    },
    {
      "name": "Criptomoedas · Compra USDT TRON",
      "description": "Compra gerenciada de USDT TRC20 com pagamento em BRL, JWT da conta e confirmação de PIN. Cotação Binance Spot USDTBRL best ask + spread AvalonPay."
    },
    {
      "name": "Criptomoedas · Venda USDT TRON",
      "description": "Venda de USDT TRC-20 com cotação BRL, prova da carteira, verificação on-chain, Pix e webhooks."
    },
    {
      "name": "Criptomoedas · Compra BNB",
      "description": "Compra gerenciada de BNB nativo pela API JWT AvalonPay."
    },
    {
      "name": "Cartões virtuais",
      "description": "Consulta, cotação em BRL, emissão e recarga de cartões virtuais."
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "cryptoClientBasic": {
        "type": "http",
        "scheme": "basic",
        "description": "Client ID e Client Secret cripto usados somente em POST /api/crypto/v1/oauth/token."
      },
      "cryptoBearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "AvalonPay access token",
        "description": "Token OAuth cripto com validade de 900 segundos e scopes limitados à credencial."
      },
      "avalonUserJwt": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "JWT válido da conta AvalonPay aprovada, enviado em Authorization: Bearer."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "request_id": {
            "type": "string"
          }
        }
      },
      "Payer": {
        "type": "object",
        "required": [
          "name",
          "email",
          "document"
        ],
        "properties": {
          "name": {
            "type": "string",
            "example": "João da Silva"
          },
          "email": {
            "type": "string",
            "format": "email",
            "example": "joao@exemplo.com"
          },
          "document": {
            "type": "string",
            "description": "CPF ou CNPJ do pagador.",
            "example": "12345678901"
          }
        }
      },
      "BoletoAddress": {
        "type": "object",
        "required": [
          "street_name",
          "street_number",
          "neighborhood",
          "city",
          "state",
          "zip_code"
        ],
        "properties": {
          "street_name": {
            "type": "string"
          },
          "street_number": {
            "type": "string"
          },
          "neighborhood": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2,
            "example": "SC"
          },
          "zip_code": {
            "type": "string",
            "pattern": "^\\d{8}$",
            "example": "88010000"
          }
        }
      },
      "LoginRequest": {
        "type": "object",
        "required": [
          "client_id",
          "client_secret"
        ],
        "properties": {
          "client_id": {
            "type": "string"
          },
          "client_secret": {
            "type": "string",
            "writeOnly": true
          }
        }
      },
      "LoginResponse": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "token": {
            "type": "string"
          },
          "user": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "email": {
                "type": "string",
                "format": "email"
              },
              "client_id": {
                "type": "string"
              }
            }
          }
        }
      },
      "BalanceResponse": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "total_balance": {
            "type": "number",
            "format": "double"
          },
          "balance": {
            "type": "number",
            "format": "double",
            "description": "Saldo disponível."
          },
          "balance_block": {
            "type": "number",
            "format": "double",
            "description": "Saldo bloqueado."
          }
        }
      },
      "PixDepositRequest": {
        "type": "object",
        "required": [
          "amount",
          "external_id",
          "payer"
        ],
        "properties": {
          "amount": {
            "type": "number",
            "format": "double",
            "minimum": 0.01
          },
          "external_id": {
            "type": "string",
            "description": "Referência externa única para a operação."
          },
          "clientCallbackUrl": {
            "type": "string",
            "format": "uri",
            "description": "Campo legado ignorado. Configure o destino fixo em Credenciais API; eventos são enviados somente para esse endpoint.",
            "deprecated": true
          },
          "payer": {
            "$ref": "#/components/schemas/PixPayer"
          }
        }
      },
      "PixDepositResponse": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "qrCodeResponse": {
            "type": "object",
            "properties": {
              "transactionId": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "example": "PENDING"
              },
              "qrcode": {
                "type": "string",
                "description": "Código Pix copia e cola."
              },
              "amount": {
                "type": "string",
                "example": "25.90"
              }
            }
          }
        }
      },
      "CheckoutRequest": {
        "type": "object",
        "required": [
          "amount",
          "external_id",
          "payer",
          "payment_method"
        ],
        "properties": {
          "amount": {
            "type": "number",
            "format": "double",
            "minimum": 1,
            "maximum": 99999999.99
          },
          "external_id": {
            "type": "string",
            "maxLength": 100
          },
          "clientCallbackUrl": {
            "type": "string",
            "format": "uri",
            "deprecated": true,
            "description": "Campo legado ignorado. Configure o destino fixo em Credenciais API; eventos são enviados somente para esse endpoint."
          },
          "payment_method": {
            "type": "string",
            "enum": [
              "card",
              "boleto"
            ]
          },
          "description": {
            "type": "string"
          },
          "return_url": {
            "type": "string",
            "format": "uri",
            "description": "Opcional; deve usar HTTPS."
          },
          "payer": {
            "type": "object",
            "required": [
              "email"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "email": {
                "type": "string",
                "format": "email"
              },
              "document": {
                "type": "string"
              }
            }
          }
        }
      },
      "CheckoutResponse": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "paymentResponse": {
            "type": "object",
            "properties": {
              "transactionId": {
                "type": "string"
              },
              "status": {
                "type": "string"
              },
              "amount": {
                "type": "string"
              },
              "payment_method": {
                "type": "string",
                "enum": [
                  "card",
                  "boleto"
                ]
              },
              "checkoutUrl": {
                "type": "string",
                "format": "uri"
              },
              "preferenceId": {
                "type": "string"
              }
            }
          }
        }
      },
      "BoletoRequest": {
        "type": "object",
        "required": [
          "amount",
          "external_id",
          "payer"
        ],
        "properties": {
          "amount": {
            "type": "number",
            "format": "double",
            "minimum": 1,
            "maximum": 99999999.99
          },
          "external_id": {
            "type": "string",
            "maxLength": 100
          },
          "description": {
            "type": "string",
            "maxLength": 120
          },
          "payer": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Payer"
              },
              {
                "type": "object",
                "required": [
                  "address"
                ],
                "properties": {
                  "address": {
                    "$ref": "#/components/schemas/BoletoAddress"
                  }
                }
              }
            ]
          }
        }
      },
      "BoletoResponse": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "paymentResponse": {
            "type": "object",
            "properties": {
              "transactionId": {
                "type": "string"
              },
              "external_id": {
                "type": "string"
              },
              "status": {
                "type": "string"
              },
              "amount": {
                "type": "string"
              },
              "payment_method": {
                "type": "string",
                "example": "boleto"
              },
              "boleto": {
                "type": "object",
                "properties": {
                  "barcode_content": {
                    "type": "string",
                    "nullable": true
                  },
                  "digitable_line": {
                    "type": "string"
                  },
                  "expiration_date": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "WithdrawalRequest": {
        "type": "object",
        "required": [
          "amount",
          "external_id",
          "pix_key",
          "key_type"
        ],
        "properties": {
          "amount": {
            "type": "number",
            "format": "double"
          },
          "external_id": {
            "type": "string"
          },
          "pix_key": {
            "type": "string"
          },
          "key_type": {
            "type": "string",
            "description": "Tipo da chave Pix aceito para a conta."
          },
          "name": {
            "type": "string"
          },
          "taxId": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "clientCallbackUrl": {
            "type": "string",
            "format": "uri",
            "deprecated": true,
            "description": "Campo legado ignorado. Configure o destino fixo em Credenciais API; eventos são enviados somente para esse endpoint."
          }
        }
      },
      "WithdrawalResponse": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "withdrawal": {
            "type": "object",
            "properties": {
              "transaction_id": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": [
                  "PROCESSING",
                  "COMPLETED",
                  "FAILED"
                ]
              },
              "amount": {
                "type": "number"
              },
              "type": {
                "type": "string",
                "example": "Withdrawal"
              }
            }
          }
        }
      },
      "QrQuoteRequest": {
        "type": "object",
        "required": [
          "qr_code"
        ],
        "properties": {
          "qr_code": {
            "type": "string",
            "maxLength": 4096
          },
          "amount": {
            "type": "number",
            "description": "Necessário quando o QR não informa o valor."
          }
        }
      },
      "QrPaymentRequest": {
        "type": "object",
        "required": [
          "qr_code",
          "external_id",
          "expected_total"
        ],
        "properties": {
          "qr_code": {
            "type": "string",
            "maxLength": 4096
          },
          "external_id": {
            "type": "string",
            "minLength": 16,
            "maxLength": 191,
            "pattern": "^[A-Za-z0-9_-]+$"
          },
          "expected_total": {
            "type": "number",
            "description": "Total da cotação calculada pela rota quote."
          },
          "amount": {
            "type": "number",
            "description": "Necessário quando o QR não informa o valor."
          }
        }
      },
      "PixBatchResponse": {
        "type": "object",
        "properties": {
          "lote_id": {
            "type": "string",
            "format": "uuid"
          },
          "referencia_lote": {
            "type": "string"
          },
          "perfil": {
            "type": "string",
            "enum": [
              "SIMPLE",
              "ERP"
            ]
          },
          "status": {
            "type": "string"
          },
          "versao_importacao": {
            "type": "integer"
          },
          "hash_conteudo": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "quantidade": {
            "type": "integer"
          },
          "principal_centavos": {
            "type": "integer",
            "format": "int64"
          },
          "tarifas_centavos": {
            "type": "integer",
            "format": "int64"
          },
          "reserva_centavos": {
            "type": "integer",
            "format": "int64"
          },
          "quantidade_com_erros": {
            "type": "integer"
          },
          "despacho_habilitado": {
            "type": "boolean"
          },
          "validacao": {
            "type": "string",
            "enum": [
              "VALIDO",
              "COM_ERROS",
              "COTACAO_INDISPONIVEL",
              "AUTORIZADO"
            ]
          },
          "erros": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PixBatchError"
            }
          },
          "tarifa": {
            "type": "object",
            "nullable": true,
            "properties": {
              "hash_cotacao": {
                "type": "string"
              },
              "tarifas_centavos": {
                "type": "integer"
              },
              "reserva_centavos": {
                "type": "integer"
              }
            }
          }
        }
      },
      "PixBatchError": {
        "type": "object",
        "properties": {
          "line": {
            "type": "integer",
            "nullable": true
          },
          "field": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "PixBatchDraftEdit": {
        "type": "object",
        "required": [
          "versao_importacao"
        ],
        "properties": {
          "versao_importacao": {
            "type": "integer"
          },
          "resolucoes_chave": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "enum": [
                "CPF",
                "TELEFONE"
              ]
            }
          },
          "resolucoes_duplicidade": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "minLength": 8,
              "maxLength": 500
            }
          }
        }
      },
      "PixBatchConfirm": {
        "type": "object",
        "required": [
          "versao_importacao",
          "hash_conteudo",
          "politica_atraso"
        ],
        "properties": {
          "versao_importacao": {
            "type": "integer"
          },
          "hash_conteudo": {
            "type": "string"
          },
          "hash_cotacao": {
            "type": "string"
          },
          "politica_atraso": {
            "type": "object",
            "required": [
              "maximo_minutos"
            ],
            "properties": {
              "maximo_minutos": {
                "type": "integer",
                "minimum": 1,
                "maximum": 240
              }
            }
          }
        }
      },
      "PixBatchReprogram": {
        "type": "object",
        "required": [
          "versao_esperada",
          "motivo",
          "agendado_para"
        ],
        "properties": {
          "versao_esperada": {
            "type": "integer"
          },
          "motivo": {
            "type": "string",
            "minLength": 8,
            "maxLength": 500
          },
          "agendado_para": {
            "type": "string",
            "example": "25/10/2026:13:00"
          },
          "politica_atraso": {
            "$ref": "#/components/schemas/PixBatchConfirm/properties/politica_atraso"
          }
        }
      },
      "PixBatchReauthorize": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PixBatchReprogram"
          },
          {
            "type": "object",
            "required": [
              "hash_cotacao"
            ],
            "properties": {
              "hash_cotacao": {
                "type": "string"
              },
              "tipo_chave_pix": {
                "type": "string",
                "enum": [
                  "CPF",
                  "CNPJ",
                  "EMAIL",
                  "TELEFONE",
                  "CHAVE_ALEATORIA"
                ]
              },
              "chave_pix": {
                "type": "string"
              }
            }
          }
        ]
      },
      "PixBatchApiError": {
        "type": "object",
        "required": [
          "erro"
        ],
        "properties": {
          "erro": {
            "type": "object",
            "required": [
              "codigo",
              "mensagem"
            ],
            "properties": {
              "codigo": {
                "type": "string"
              },
              "mensagem": {
                "type": "string"
              },
              "detalhes": {
                "type": "object",
                "nullable": true
              }
            }
          },
          "request_id": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PixBatchListResponse": {
        "type": "object",
        "required": [
          "lotes",
          "limit",
          "offset"
        ],
        "properties": {
          "lotes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "lote_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "referencia_lote": {
                  "type": "string"
                },
                "perfil": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                },
                "quantidade": {
                  "type": "integer"
                },
                "principal_centavos": {
                  "type": "integer"
                },
                "tarifas_centavos": {
                  "type": "integer"
                },
                "reserva_centavos": {
                  "type": "integer"
                }
              }
            }
          },
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          }
        }
      },
      "PixBatchItemsPage": {
        "type": "object",
        "required": [
          "lote_id",
          "page",
          "limit",
          "total",
          "total_paginas",
          "itens"
        ],
        "properties": {
          "lote_id": {
            "type": "string",
            "format": "uuid"
          },
          "page": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "total_paginas": {
            "type": "integer"
          },
          "ordenacao": {
            "type": "string"
          },
          "itens": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "pagamento_id": {
                  "type": "string",
                  "nullable": true
                },
                "referencia": {
                  "type": "string"
                },
                "linha_origem": {
                  "type": "integer"
                },
                "nome": {
                  "type": "string"
                },
                "valor_centavos": {
                  "type": "integer",
                  "nullable": true
                },
                "chave_pix": {
                  "type": "string",
                  "nullable": true,
                  "description": "Valor mascarado."
                },
                "tipo_chave_pix": {
                  "type": "string",
                  "nullable": true
                },
                "agendado_para": {
                  "type": "string",
                  "format": "date-time",
                  "nullable": true
                },
                "revisao": {
                  "type": "integer"
                },
                "status": {
                  "type": "string"
                },
                "erros": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PixBatchError"
                  }
                }
              }
            }
          }
        }
      },
      "PixBatchReturnCreated": {
        "type": "object",
        "required": [
          "lote_id",
          "export_id",
          "fase",
          "hash_conteudo",
          "quantidade",
          "url"
        ],
        "properties": {
          "lote_id": {
            "type": "string",
            "format": "uuid"
          },
          "export_id": {
            "type": "string"
          },
          "fase": {
            "type": "string",
            "enum": [
              "PARCIAL",
              "FINAL"
            ]
          },
          "hash_conteudo": {
            "type": "string"
          },
          "quantidade": {
            "type": "integer"
          },
          "url": {
            "type": "string"
          }
        }
      },
      "PixBatchReauthorizationQuote": {
        "type": "object",
        "required": [
          "pagamento_id",
          "revisao_esperada",
          "tarifa"
        ],
        "properties": {
          "pagamento_id": {
            "type": "string"
          },
          "revisao_esperada": {
            "type": "integer"
          },
          "tarifa": {
            "type": "object",
            "required": [
              "hash_cotacao",
              "tarifas_centavos",
              "reserva_centavos"
            ],
            "properties": {
              "hash_cotacao": {
                "type": "string"
              },
              "tarifas_centavos": {
                "type": "integer"
              },
              "reserva_centavos": {
                "type": "integer"
              },
              "politica": {
                "type": "object"
              }
            }
          }
        }
      },
      "CryptoError": {
        "type": "object",
        "required": [
          "error",
          "request_id"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "request_id",
              "retryable"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "request_id": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid"
              },
              "operation_id": {
                "type": "string",
                "format": "uuid"
              },
              "retryable": {
                "type": "boolean"
              }
            }
          },
          "request_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          }
        }
      },
      "CryptoToken": {
        "type": "object",
        "required": [
          "access_token",
          "token_type",
          "expires_in",
          "scope"
        ],
        "properties": {
          "access_token": {
            "type": "string",
            "pattern": "^apct_"
          },
          "token_type": {
            "type": "string",
            "enum": [
              "Bearer"
            ]
          },
          "expires_in": {
            "type": "integer",
            "example": 900
          },
          "scope": {
            "type": "string",
            "example": "crypto.read crypto.webhooks"
          }
        }
      },
      "CryptoNetwork": {
        "type": "object",
        "required": [
          "code",
          "name",
          "chain_id",
          "native_asset",
          "address_format"
        ],
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "BSC",
              "TRON"
            ]
          },
          "name": {
            "type": "string"
          },
          "chain_id": {
            "type": "string"
          },
          "native_asset": {
            "type": "string"
          },
          "address_format": {
            "type": "string",
            "enum": [
              "EVM",
              "TRON_BASE58"
            ]
          }
        }
      },
      "CryptoAsset": {
        "type": "object",
        "required": [
          "id",
          "code",
          "symbol",
          "name",
          "network",
          "contract_address",
          "decimals",
          "token_standard",
          "status",
          "deposits_enabled",
          "withdrawals_enabled",
          "swaps_enabled",
          "swap_source_enabled",
          "swap_cross_chain_source_enabled",
          "swap_destination_enabled",
          "swap_quotes_enabled",
          "conversions_enabled"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "BSC:0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c"
          },
          "code": {
            "type": "string"
          },
          "symbol": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "network": {
            "type": "string",
            "enum": [
              "BSC",
              "TRON"
            ]
          },
          "contract_address": {
            "type": [
              "string",
              "null"
            ]
          },
          "decimals": {
            "type": "integer",
            "minimum": 0,
            "maximum": 36
          },
          "token_standard": {
            "type": "string",
            "enum": [
              "NATIVE",
              "BEP20",
              "TRC20"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "ACTIVE",
              "PENDING_VALIDATION"
            ]
          },
          "availability_reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "deposits_enabled": {
            "type": "boolean"
          },
          "withdrawals_enabled": {
            "type": "boolean"
          },
          "swaps_enabled": {
            "type": "boolean"
          },
          "swap_source_enabled": {
            "type": "boolean",
            "description": "Indica se o ativo pode ser usado como origem de um swap executável nesta rede."
          },
          "swap_destination_enabled": {
            "type": "boolean",
            "description": "Indica se o ativo pode ser recebido como destino de um swap executável nesta rede."
          },
          "swap_quotes_enabled": {
            "type": "boolean",
            "description": "Indica se a API pode consultar cotações para o ativo; uma cotação não garante rota executável."
          },
          "conversions_enabled": {
            "type": "boolean"
          },
          "price_id": {
            "type": "string"
          },
          "validation_source": {
            "type": "string",
            "format": "uri"
          },
          "represented_asset": {
            "type": [
              "string",
              "null"
            ]
          },
          "swap_cross_chain_source_enabled": {
            "type": "boolean",
            "description": "Indica se o ativo pode iniciar um swap cross-chain. Na BSC, tokens BEP-20 aprovados podem ser origem e o BNB deve cobrir o gás. Na TRON, TRX nativo e USDT TRC20 podem iniciar swaps cross-chain."
          }
        }
      },
      "CryptoWallet": {
        "type": "object",
        "required": [
          "wallet_id",
          "user_id",
          "network",
          "chain_id",
          "address",
          "status"
        ],
        "properties": {
          "wallet_id": {
            "type": "string",
            "format": "uuid"
          },
          "user_id": {
            "type": "integer"
          },
          "network": {
            "type": "string",
            "enum": [
              "BSC",
              "ETHEREUM",
              "TRON"
            ]
          },
          "chain_id": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "monitor_from_block": {
            "type": [
              "integer",
              "string"
            ]
          },
          "status": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CryptoBalance": {
        "type": "object",
        "required": [
          "asset_id",
          "asset",
          "network",
          "decimals",
          "available_units",
          "available",
          "reserved_units",
          "reserved",
          "pending_units",
          "pending",
          "balance_source"
        ],
        "properties": {
          "asset_id": {
            "type": "string"
          },
          "asset": {
            "type": "string"
          },
          "network": {
            "type": "string"
          },
          "decimals": {
            "type": "integer"
          },
          "available_units": {
            "type": "string",
            "pattern": "^[0-9]+$"
          },
          "available": {
            "type": "string"
          },
          "reserved_units": {
            "type": "string",
            "pattern": "^[0-9]+$"
          },
          "reserved": {
            "type": "string"
          },
          "pending_units": {
            "type": "string",
            "pattern": "^[0-9]+$"
          },
          "pending": {
            "type": "string"
          },
          "balance_source": {
            "type": "string",
            "enum": [
              "avalon_ledger"
            ]
          }
        }
      },
      "CryptoOperation": {
        "type": "object",
        "required": [
          "id",
          "type",
          "network",
          "asset",
          "asset_id",
          "amount",
          "fee",
          "network_fee",
          "protocol_fee",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "type": "string"
          },
          "network": {
            "type": "string"
          },
          "asset": {
            "type": "string"
          },
          "asset_id": {
            "type": "string"
          },
          "amount": {
            "type": "string"
          },
          "gross_amount": {
            "type": [
              "string",
              "null"
            ]
          },
          "fee": {
            "type": "string"
          },
          "network_fee": {
            "type": "string"
          },
          "protocol_fee": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "transaction_hash": {
            "type": [
              "string",
              "null"
            ]
          },
          "destination_address": {
            "type": [
              "string",
              "null"
            ]
          },
          "error_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "CryptoDeposit": {
        "type": "object",
        "required": [
          "id",
          "network",
          "asset",
          "asset_id",
          "amount",
          "transaction_hash",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "network": {
            "type": "string"
          },
          "asset": {
            "type": "string"
          },
          "asset_id": {
            "type": "string"
          },
          "amount": {
            "type": "string"
          },
          "gross_amount": {
            "type": [
              "string",
              "null"
            ]
          },
          "credited_amount": {
            "type": [
              "string",
              "null"
            ]
          },
          "fee": {
            "type": "string"
          },
          "transaction_hash": {
            "type": "string"
          },
          "block_number": {
            "type": "string"
          },
          "confirmations": {
            "type": "integer"
          },
          "status": {
            "type": "string"
          },
          "confirmed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "wallet_id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "CryptoWebhookEndpoint": {
        "type": "object",
        "required": [
          "id",
          "credential_id",
          "environment",
          "name",
          "url",
          "events",
          "status",
          "version"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "credential_id": {
            "type": "string",
            "format": "uuid"
          },
          "environment": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "ACTIVE",
              "INACTIVE"
            ]
          },
          "version": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CryptoWebhookDelivery": {
        "type": "object",
        "properties": {
          "delivery_id": {
            "type": "string",
            "format": "uuid"
          },
          "event_id": {
            "type": "string",
            "format": "uuid"
          },
          "endpoint_id": {
            "type": "string",
            "format": "uuid"
          },
          "state": {
            "type": "string"
          },
          "attempts": {
            "type": "integer"
          },
          "last_http_status": {
            "type": [
              "integer",
              "null"
            ]
          },
          "last_error_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CryptoPageInfo": {
        "type": "object",
        "properties": {
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "has_more": {
            "type": "boolean"
          }
        }
      },
      "PaymentWebhookEvent": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "id",
              "type",
              "created_at",
              "data"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "description": "ID estável do evento; use como chave única para deduplicar entregas repetidas."
              },
              "type": {
                "type": "string",
                "enum": [
                  "pix.in.created",
                  "pix.in.completed",
                  "pix.in.failed",
                  "pix.out.created",
                  "pix.out.processing",
                  "pix.out.completed",
                  "pix.out.failed",
                  "pix.qr_pay.created",
                  "pix.qr_pay.processing",
                  "pix.qr_pay.completed",
                  "pix.qr_pay.failed",
                  "boleto.created",
                  "boleto.paid",
                  "boleto.failed",
                  "card.payment.created",
                  "card.payment.paid",
                  "card.payment.failed",
                  "webhook.test"
                ]
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              },
              "data": {
                "type": "object",
                "properties": {
                  "transaction_id": {
                    "type": "string"
                  },
                  "external_id": {
                    "type": "string",
                    "nullable": true
                  },
                  "status": {
                    "type": "string"
                  },
                  "payment_method": {
                    "type": "string",
                    "enum": [
                      "pix",
                      "pix_out",
                      "pix_qr_pay",
                      "boleto",
                      "card"
                    ]
                  },
                  "amount": {
                    "type": "string",
                    "description": "Valor BRL em formato decimal, sem conversão para ponto flutuante."
                  },
                  "currency": {
                    "type": "string",
                    "enum": [
                      "BRL"
                    ]
                  },
                  "created_at": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": true
                  },
                  "updated_at": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "additionalProperties": true
              }
            }
          },
          {
            "type": "object",
            "required": [
              "id",
              "type",
              "created_at",
              "data"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "description": "ID estável do evento; use como chave única para deduplicar entregas repetidas."
              },
              "type": {
                "type": "string",
                "enum": [
                  "med.received",
                  "med.updated",
                  "med.defense_submitted",
                  "med.resolved"
                ]
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              },
              "data": {
                "$ref": "#/components/schemas/MedWebhookData"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "id",
              "type",
              "created_at",
              "data"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "description": "ID estável do evento; use como chave única para deduplicar entregas repetidas."
              },
              "type": {
                "type": "string",
                "enum": [
                  "med.balance_changed"
                ]
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              },
              "data": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/MedWebhookData"
                  },
                  {
                    "type": "object",
                    "required": [
                      "movements"
                    ],
                    "properties": {
                      "movements": {
                        "type": "array",
                        "minItems": 1,
                        "items": {
                          "type": "object",
                          "required": [
                            "stage",
                            "available_delta_cents",
                            "blocked_delta_cents"
                          ],
                          "properties": {
                            "stage": {
                              "type": "string",
                              "enum": [
                                "held",
                                "released",
                                "forfeited"
                              ]
                            },
                            "available_delta_cents": {
                              "type": "integer",
                              "description": "Variação do saldo disponível, em centavos."
                            },
                            "blocked_delta_cents": {
                              "type": "integer",
                              "description": "Variação do saldo bloqueado, em centavos."
                            }
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        ]
      },
      "PaymentWebhookEndpoint": {
        "type": "object",
        "required": [
          "id",
          "url",
          "events",
          "status",
          "secret_version"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "pix.in.created",
                "pix.in.completed",
                "pix.in.failed",
                "pix.out.created",
                "pix.out.processing",
                "pix.out.completed",
                "pix.out.failed",
                "pix.qr_pay.created",
                "pix.qr_pay.processing",
                "pix.qr_pay.completed",
                "pix.qr_pay.failed",
                "boleto.created",
                "boleto.paid",
                "boleto.failed",
                "card.payment.created",
                "card.payment.paid",
                "card.payment.failed",
                "med.received",
                "med.updated",
                "med.balance_changed",
                "med.defense_submitted",
                "med.resolved"
              ]
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "ACTIVE",
              "DISABLED"
            ]
          },
          "secret_version": {
            "type": "integer",
            "minimum": 1
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PaymentWebhookDelivery": {
        "type": "object",
        "required": [
          "delivery_id",
          "event_id",
          "event_type",
          "state",
          "attempts",
          "created_at"
        ],
        "properties": {
          "delivery_id": {
            "type": "string",
            "format": "uuid",
            "description": "Mantém o mesmo valor entre as tentativas de um envio."
          },
          "event_id": {
            "type": "string",
            "format": "uuid",
            "description": "Use para deduplicar o evento na sua aplicação."
          },
          "event_type": {
            "type": "string",
            "enum": [
              "pix.in.created",
              "pix.in.completed",
              "pix.in.failed",
              "pix.out.created",
              "pix.out.processing",
              "pix.out.completed",
              "pix.out.failed",
              "pix.qr_pay.created",
              "pix.qr_pay.processing",
              "pix.qr_pay.completed",
              "pix.qr_pay.failed",
              "boleto.created",
              "boleto.paid",
              "boleto.failed",
              "card.payment.created",
              "card.payment.paid",
              "card.payment.failed",
              "webhook.test",
              "med.received",
              "med.updated",
              "med.balance_changed",
              "med.defense_submitted",
              "med.resolved"
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "PENDING",
              "RETRYING",
              "DELIVERING",
              "DELIVERED",
              "FAILED",
              "CANCELLED"
            ]
          },
          "attempts": {
            "type": "integer",
            "minimum": 0
          },
          "last_http_status": {
            "type": "integer",
            "nullable": true
          },
          "last_error_code": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "delivered_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "PixPayer": {
        "type": "object",
        "required": [
          "name",
          "document"
        ],
        "properties": {
          "name": {
            "type": "string",
            "example": "João da Silva",
            "description": "Nome do pagador. Necessário no processamento atual das cobranças Pix."
          },
          "email": {
            "type": "string",
            "format": "email",
            "example": "joao@exemplo.com",
            "description": "Opcional para cobranças Pix. Quando informado, envie um e-mail válido."
          },
          "document": {
            "type": "string",
            "description": "CPF ou CNPJ do pagador.",
            "example": "12345678901"
          }
        }
      },
      "MedInfraction": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "end_to_end_id": {
            "type": "string",
            "nullable": true
          },
          "reason": {
            "type": "string",
            "nullable": true
          },
          "analysis": {
            "type": "string",
            "nullable": true
          },
          "defense": {
            "type": "string",
            "nullable": true,
            "description": "Justificativa enviada pela conta, quando houver."
          },
          "defense_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "opened_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "amount_cents": {
            "type": "integer",
            "nullable": true
          },
          "blocked_cents": {
            "type": "integer"
          },
          "currency": {
            "type": "string",
            "enum": [
              "BRL"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "under_review",
              "won",
              "lost",
              "cancelled"
            ]
          },
          "can_defend": {
            "type": "boolean"
          },
          "evidence_mode": {
            "type": "string",
            "enum": [
              "links",
              "files",
              "none"
            ]
          },
          "defense_status": {
            "type": "string",
            "enum": [
              "none",
              "sending",
              "sent",
              "pending",
              "failed",
              "manual_received",
              "manual_forwarded"
            ]
          },
          "source": {
            "type": "string",
            "enum": [
              "provider",
              "compliance"
            ],
            "description": "Origem do caso: liquidante ou abertura acompanhada pelo Compliance."
          },
          "history": {
            "type": "array",
            "description": "Histórico do caso e da defesa; os registros não expõem identificadores internos de operadores.",
            "items": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "string",
                  "enum": [
                    "open",
                    "under_review",
                    "won",
                    "lost",
                    "cancelled",
                    "manual_received",
                    "manual_forwarded"
                  ]
                },
                "date": {
                  "type": "string",
                  "format": "date-time",
                  "nullable": true
                },
                "text": {
                  "type": "string"
                },
                "attachments": {
                  "type": "integer"
                }
              }
            }
          }
        }
      },
      "MedWebhookData": {
        "type": "object",
        "required": [
          "infraction_id",
          "transaction_id",
          "status",
          "end_to_end_id",
          "defense_status",
          "currency",
          "amount_cents",
          "blocked_cents",
          "opened_at"
        ],
        "properties": {
          "infraction_id": {
            "type": "string",
            "format": "uuid"
          },
          "transaction_id": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "under_review",
              "won",
              "lost",
              "cancelled"
            ]
          },
          "end_to_end_id": {
            "type": "string",
            "nullable": true
          },
          "defense_status": {
            "type": "string",
            "enum": [
              "none",
              "sending",
              "sent",
              "pending",
              "failed",
              "manual_received",
              "manual_forwarded"
            ]
          },
          "currency": {
            "type": "string",
            "enum": [
              "BRL"
            ]
          },
          "amount_cents": {
            "type": "integer",
            "nullable": true
          },
          "blocked_cents": {
            "type": "integer"
          },
          "opened_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "source": {
            "type": "string",
            "enum": [
              "provider",
              "compliance"
            ],
            "description": "Origem do caso."
          },
          "defense_text": {
            "type": "string",
            "nullable": true,
            "description": "Justificativa recebida. Presente em med.defense_submitted."
          },
          "defense_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Data da justificativa em UTC. Presente em med.defense_submitted."
          }
        }
      },
      "CryptoUsdtTronOrder": {
        "type": "object",
        "required": [
          "order_id",
          "status",
          "status_label",
          "amount_brl",
          "avalon_fee_brl",
          "total_debit_brl",
          "net_usdt",
          "usdt_price_brl",
          "effective_usdt_price_brl",
          "spread_bps",
          "spread_percent",
          "market_source",
          "network",
          "quote_expires_at"
        ],
        "properties": {
          "order_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "QUOTE_READY",
              "PROCESSING",
              "UNDER_REVIEW",
              "COMPLETED",
              "FAILED",
              "EXPIRED"
            ]
          },
          "status_label": {
            "type": "string"
          },
          "amount_brl": {
            "type": "string",
            "description": "Valor em BRL solicitado na cotação."
          },
          "avalon_fee_brl": {
            "type": "string",
            "description": "Tarifa AvalonPay informada na cotação."
          },
          "total_debit_brl": {
            "type": "string",
            "description": "Débito total estimado; use esse valor sem recomputar taxas."
          },
          "net_usdt": {
            "type": "string",
            "description": "USDT TRC20 líquido estimado após spread e custos considerados na cotação."
          },
          "usdt_price_brl": {
            "type": "string",
            "description": "Preço Binance Spot USDTBRL best ask."
          },
          "effective_usdt_price_brl": {
            "type": "string",
            "description": "Preço efetivo após aplicação do spread configurado."
          },
          "spread_bps": {
            "type": "integer"
          },
          "spread_percent": {
            "type": "string"
          },
          "market_source": {
            "type": "string",
            "example": "Binance Spot · USDTBRL best ask"
          },
          "network": {
            "type": "string",
            "enum": [
              "TRON · TRC20"
            ]
          },
          "quote_expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "available_balance_brl": {
            "type": "string",
            "description": "Presente na resposta da cotação."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "CryptoBnbPurchaseOrder": {
        "type": "object",
        "required": [
          "order_id",
          "status",
          "status_label",
          "amount_brl",
          "avalon_fee_brl",
          "total_debit_brl",
          "asset_code",
          "asset_symbol",
          "asset_network",
          "asset_amount",
          "asset_price_brl",
          "effective_asset_price_brl",
          "market_pair",
          "asset_decimals",
          "spread_bps",
          "spread_percent",
          "market_source",
          "network",
          "quote_expires_at"
        ],
        "properties": {
          "order_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "QUOTE_READY",
              "PROCESSING",
              "UNDER_REVIEW",
              "COMPLETED",
              "FAILED",
              "EXPIRED"
            ]
          },
          "status_label": {
            "type": "string"
          },
          "amount_brl": {
            "type": "string",
            "description": "Valor total em BRL solicitado na cotação."
          },
          "avalon_fee_brl": {
            "type": "string",
            "description": "Tarifa AvalonPay retornada na cotação."
          },
          "total_debit_brl": {
            "type": "string",
            "description": "Débito total estimado; use o valor devolvido sem recomputar tarifas."
          },
          "asset_code": {
            "type": "string",
            "enum": [
              "BNB_BSC"
            ]
          },
          "asset_symbol": {
            "type": "string",
            "enum": [
              "BNB"
            ]
          },
          "asset_network": {
            "type": "string",
            "enum": [
              "BSC"
            ]
          },
          "asset_amount": {
            "type": "string",
            "description": "Quantidade estimada de BNB nativo com até 8 casas decimais."
          },
          "asset_price_brl": {
            "type": "string",
            "description": "Binance Spot BNBBRL best ask antes do spread."
          },
          "effective_asset_price_brl": {
            "type": "string",
            "description": "Preço estimado por BNB depois do spread configurado."
          },
          "market_pair": {
            "type": "string",
            "enum": [
              "BNBBRL"
            ]
          },
          "asset_decimals": {
            "type": "integer",
            "example": 8
          },
          "spread_bps": {
            "type": "integer"
          },
          "spread_percent": {
            "type": "string"
          },
          "market_source": {
            "type": "string",
            "example": "Binance Spot · BNBBRL best ask"
          },
          "network": {
            "type": "string",
            "enum": [
              "BNB Chain · BNB nativo"
            ]
          },
          "quote_expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "available_balance_brl": {
            "type": "string",
            "description": "Presente na resposta da cotação."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      }
    }
  },
  "paths": {
    "/api/auth/login": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Autenticar credenciais da API",
        "description": "Retorna um token JWT válido por uma hora.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token emitido.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoginResponse"
                }
              }
            }
          },
          "400": {
            "description": "Corpo inválido.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credenciais inválidas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Conta indisponível para operações de API.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Limite de autenticação atingido."
          }
        }
      }
    },
    "/api/accounts/balance": {
      "get": {
        "tags": [
          "Conta"
        ],
        "summary": "Consultar saldo",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Saldo da conta.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BalanceResponse"
                }
              }
            }
          },
          "401": {
            "description": "Token ausente ou inválido."
          },
          "404": {
            "description": "Carteira não encontrada."
          }
        }
      }
    },
    "/api/payments/deposit": {
      "post": {
        "tags": [
          "Pagamentos"
        ],
        "summary": "Criar cobrança Pix",
        "description": "Retorna o código Pix copia e cola. O valor mínimo é definido para a conta. Use uma referência externa única e confira o extrato antes de repetir após timeout. A API admite até 100 solicitações de criação por segundo por conta. Ao receber HTTP 429, respeite Retry-After e mantenha o external_id original.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PixDepositRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Cobrança criada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixDepositResponse"
                }
              }
            }
          },
          "202": {
            "description": "Solicitação aceita. Se qrCodeResponse.pix_status=generating, a cobrança já existe e o QR está sendo preparado: consulte status_url com o mesmo JWT. Não gere outro external_id. Sem qrCodeResponse, repita a mesma solicitação com o mesmo external_id após aguardar."
          },
          "400": {
            "description": "Campo ausente ou inválido."
          },
          "401": {
            "description": "Token ausente ou inválido."
          },
          "429": {
            "description": "Limite de criações atingido."
          },
          "500": {
            "description": "Configuração da conta ou serviço indisponível."
          }
        }
      }
    },
    "/api/payments/checkout": {
      "post": {
        "tags": [
          "Pagamentos"
        ],
        "summary": "Criar checkout hospedado",
        "description": "Aceita payment_method card ou boleto. Repetições com a mesma referência e dados recuperam o checkout existente; alterações retornam conflito.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckoutRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Checkout criado ou recuperado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutResponse"
                }
              }
            }
          },
          "400": {
            "description": "Dados inválidos."
          },
          "401": {
            "description": "Token ausente ou inválido."
          },
          "409": {
            "description": "Referência já usada com dados diferentes."
          },
          "429": {
            "description": "Limite de criações atingido."
          },
          "502": {
            "description": "Checkout hospedado indisponível."
          }
        }
      }
    },
    "/api/payments/boleto": {
      "post": {
        "tags": [
          "Pagamentos"
        ],
        "summary": "Emitir boleto",
        "description": "Emite boleto para adicionar saldo ou cobrar um cliente. O mesmo external_id e valor recuperam a cobrança existente.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BoletoRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Boleto criado ou recuperado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BoletoResponse"
                }
              }
            }
          },
          "400": {
            "description": "Dados do pagador ou valor inválidos."
          },
          "401": {
            "description": "Token ausente ou inválido."
          },
          "409": {
            "description": "Referência reutilizada com valor ou método diferente."
          },
          "429": {
            "description": "Limite de criações atingido."
          },
          "502": {
            "description": "Não foi possível emitir o boleto."
          }
        }
      }
    },
    "/api/payments/boleto/{external_id}/status": {
      "get": {
        "tags": [
          "Pagamentos"
        ],
        "summary": "Consultar e sincronizar status do boleto",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "external_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Estado e dados atuais do boleto.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BoletoResponse"
                }
              }
            }
          },
          "401": {
            "description": "Token ausente ou inválido."
          },
          "404": {
            "description": "Boleto não encontrado."
          },
          "409": {
            "description": "Dados do pagamento não conferem."
          },
          "429": {
            "description": "Limite de consultas atingido."
          },
          "502": {
            "description": "Não foi possível consultar o boleto."
          }
        }
      }
    },
    "/api/withdrawals/withdraw": {
      "post": {
        "tags": [
          "Saques"
        ],
        "summary": "Enviar Pix para uma chave",
        "description": "Debita o valor e as tarifas configuradas. A conta precisa ter IP autorizado. Uma referência já usada não pode ser repetida.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WithdrawalRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Solicitação processada; o status pode estar PROCESSING.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WithdrawalResponse"
                }
              }
            }
          },
          "400": {
            "description": "Dados inválidos, saldo insuficiente, referência duplicada ou operação recusada."
          },
          "401": {
            "description": "Token ausente ou inválido."
          },
          "403": {
            "description": "IP não autorizado."
          },
          "429": {
            "description": "Limite ou operação anterior em andamento."
          }
        }
      }
    },
    "/api/withdrawals/withdraw/qrcode/quote": {
      "post": {
        "tags": [
          "Saques"
        ],
        "summary": "Calcular pagamento por QR Code Pix",
        "description": "Calcula o valor e as tarifas sem debitar saldo. Se o QR não tiver valor, informe amount.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QrQuoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Cotação calculada ou pedido de valor adicional."
          },
          "401": {
            "description": "Token ausente ou inválido."
          },
          "422": {
            "description": "QR Code inválido."
          },
          "503": {
            "description": "Pagamento por QR Code indisponível para a conta."
          }
        }
      }
    },
    "/api/withdrawals/withdraw/qrcode": {
      "post": {
        "tags": [
          "Saques"
        ],
        "summary": "Confirmar pagamento por QR Code Pix",
        "description": "Confirme com o total exato retornado pela cotação. Uma resposta 202 indica que a confirmação ainda está em andamento; confira o extrato antes de tentar novamente.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QrPaymentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Pagamento concluído."
          },
          "202": {
            "description": "Pagamento em confirmação."
          },
          "400": {
            "description": "Saldo insuficiente ou pagamento recusado."
          },
          "401": {
            "description": "Token ausente ou inválido."
          },
          "403": {
            "description": "IP não autorizado."
          },
          "409": {
            "description": "Referência já pertence a outra operação ou cotação mudou."
          },
          "422": {
            "description": "QR Code ou solicitação inválida."
          },
          "429": {
            "description": "Operação anterior em andamento ou limite atingido."
          },
          "503": {
            "description": "Pagamento por QR Code indisponível."
          }
        }
      }
    },
    "/v1/pix/lotes/importar": {
      "post": {
        "tags": [
          "Pagamentos em lote"
        ],
        "summary": "Importar arquivo TXT para um rascunho",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "description": "Chave única por intenção financeira. Reuso com outro conteúdo retorna 409."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "arquivo"
                ],
                "properties": {
                  "arquivo": {
                    "type": "string",
                    "format": "binary"
                  },
                  "referencia_lote": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "fuso": {
                    "type": "string",
                    "enum": [
                      "America/Sao_Paulo"
                    ],
                    "default": "America/Sao_Paulo"
                  },
                  "tipos_chave": {
                    "type": "string",
                    "description": "Objeto JSON opcional com linha física → CPF ou TELEFONE."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Importação existente recuperada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "201": {
            "description": "Rascunho criado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "409": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "413": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "422": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pix/lotes": {
      "get": {
        "tags": [
          "Pagamentos em lote"
        ],
        "summary": "Listar lotes da empresa",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Lotes paginados.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchListResponse"
                }
              }
            }
          },
          "401": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "403": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pix/lotes/{lote_id}": {
      "get": {
        "tags": [
          "Pagamentos em lote"
        ],
        "summary": "Consultar lote",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "lote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resumo do lote.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "404": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pix/lotes/{lote_id}/itens": {
      "get": {
        "tags": [
          "Pagamentos em lote"
        ],
        "summary": "Listar itens paginados",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "lote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 100
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Itens paginados.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchItemsPage"
                }
              }
            }
          },
          "404": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pix/lotes/{lote_id}/rascunho": {
      "put": {
        "tags": [
          "Pagamentos em lote"
        ],
        "summary": "Editar resoluções do rascunho",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "lote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "description": "Chave única por intenção financeira. Reuso com outro conteúdo retorna 409."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PixBatchDraftEdit"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operação processada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "202": {
            "description": "Agendamento autorizado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "409": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "422": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "503": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pix/lotes/{lote_id}/confirmar": {
      "post": {
        "tags": [
          "Pagamentos em lote"
        ],
        "summary": "Validar, reservar saldo e autorizar o agendamento",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "lote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "description": "Chave única por intenção financeira. Reuso com outro conteúdo retorna 409."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PixBatchConfirm"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operação processada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "202": {
            "description": "Agendamento autorizado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "409": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "422": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "503": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pix/lotes/{lote_id}/pausar": {
      "post": {
        "tags": [
          "Pagamentos em lote"
        ],
        "summary": "Pausar lote",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "lote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "description": "Chave única por intenção financeira. Reuso com outro conteúdo retorna 409."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operação processada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "202": {
            "description": "Agendamento autorizado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "409": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "422": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "503": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pix/lotes/{lote_id}/retomar": {
      "post": {
        "tags": [
          "Pagamentos em lote"
        ],
        "summary": "Retomar lote",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "lote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "description": "Chave única por intenção financeira. Reuso com outro conteúdo retorna 409."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operação processada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "202": {
            "description": "Agendamento autorizado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "409": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "422": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "503": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pix/lotes/{lote_id}/cancelar": {
      "post": {
        "tags": [
          "Pagamentos em lote"
        ],
        "summary": "Cancelar lote",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "lote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "description": "Chave única por intenção financeira. Reuso com outro conteúdo retorna 409."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operação processada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "202": {
            "description": "Agendamento autorizado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "409": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "422": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "503": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pix/lotes/{lote_id}/itens/{pagamento_id}/reprogramar": {
      "post": {
        "tags": [
          "Pagamentos em lote"
        ],
        "summary": "Reprogramar um pagamento",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "lote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "pagamento_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "description": "Chave única por intenção financeira. Reuso com outro conteúdo retorna 409."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PixBatchReprogram"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Pagamento atualizado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "202": {
            "description": "Nova ordem autorizada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "404": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "409": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "422": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pix/lotes/{lote_id}/itens/{pagamento_id}/reautorizar": {
      "post": {
        "tags": [
          "Pagamentos em lote"
        ],
        "summary": "Reautorizar um pagamento",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "lote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "pagamento_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "description": "Chave única por intenção financeira. Reuso com outro conteúdo retorna 409."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PixBatchReauthorize"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Pagamento atualizado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "202": {
            "description": "Nova ordem autorizada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchResponse"
                }
              }
            }
          },
          "404": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "409": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "422": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pix/lotes/{lote_id}/retornos": {
      "post": {
        "tags": [
          "Pagamentos em lote"
        ],
        "summary": "Criar snapshot imutável para conciliação",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "lote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "description": "Chave única por intenção financeira. Reuso com outro conteúdo retorna 409."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Retorno criado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchReturnCreated"
                }
              }
            }
          },
          "404": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "409": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pix/lotes/{lote_id}/retornos/{export_id}": {
      "get": {
        "tags": [
          "Pagamentos em lote"
        ],
        "summary": "Baixar retorno TXT",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "lote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "export_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "TXT UTF-8 com CSV delimitado por ponto e vírgula.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pix/lotes/{lote_id}/itens/{pagamento_id}/cotacao-reautorizacao": {
      "get": {
        "tags": [
          "Pagamentos em lote"
        ],
        "summary": "Consultar cotação para uma rejeição definitiva",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "lote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "pagamento_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cotação vigente.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchReauthorizationQuote"
                }
              }
            }
          },
          "404": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          },
          "409": {
            "description": "Erro com código estável.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixBatchApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/crypto/v1/oauth/token": {
      "post": {
        "tags": [
          "Criptomoedas · OAuth"
        ],
        "operationId": "cryptoCreateAccessToken",
        "summary": "Emitir token OAuth cripto",
        "description": "Use HTTP Basic com client_id/client_secret cripto. O segredo não pode ser enviado em query string. O token dura 900 segundos e não tem refresh token.",
        "security": [
          {
            "cryptoClientBasic": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "grant_type"
                ],
                "properties": {
                  "grant_type": {
                    "type": "string",
                    "enum": [
                      "client_credentials"
                    ]
                  },
                  "scope": {
                    "type": "string",
                    "example": "crypto.read crypto.webhooks"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token emitido.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "example": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoToken"
                }
              }
            }
          },
          "400": {
            "description": "Grant type ou scopes inválidos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          },
          "401": {
            "description": "Credencial cripto inválida ou revogada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          },
          "415": {
            "description": "O corpo deve ser application/x-www-form-urlencoded."
          }
        }
      }
    },
    "/api/crypto/v1/networks": {
      "get": {
        "tags": [
          "Criptomoedas · Catálogo"
        ],
        "operationId": "cryptoListNetworks",
        "summary": "Listar redes",
        "security": [
          {
            "cryptoBearer": [
              "crypto.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Redes suportadas.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "networks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CryptoNetwork"
                      }
                    },
                    "checked_at": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Token ausente ou inválido.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          }
        }
      }
    },
    "/api/crypto/v1/assets": {
      "get": {
        "tags": [
          "Criptomoedas · Catálogo"
        ],
        "operationId": "cryptoListAssets",
        "summary": "Listar ativos e capacidades",
        "description": "A disponibilidade efetiva é informada individualmente por status e pelos campos *_enabled. Ativos pendentes não devem receber fundos.",
        "security": [
          {
            "cryptoBearer": [
              "crypto.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Catálogo verificado.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "assets": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CryptoAsset"
                      }
                    },
                    "checked_at": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Token ausente ou inválido.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          }
        }
      }
    },
    "/api/crypto/v1/wallets": {
      "get": {
        "tags": [
          "Criptomoedas · Carteiras"
        ],
        "operationId": "cryptoListWallets",
        "summary": "Listar carteiras da conta",
        "security": [
          {
            "cryptoBearer": [
              "crypto.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Carteiras vinculadas ao titular autenticado.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "wallets": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CryptoWallet"
                      }
                    },
                    "networks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CryptoNetwork"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Conta não aprovada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          },
          "503": {
            "description": "Provisionamento ou assinador indisponível.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Criptomoedas · Carteiras"
        ],
        "operationId": "cryptoCreateAdditionalWallet",
        "summary": "Criar uma carteira adicional",
        "description": "Uma chave por endereço e por conta. A repetição com a mesma rede recupera a mesma carteira. Use somente redes de depósito habilitadas.",
        "security": [
          {
            "cryptoBearer": [
              "crypto.wallets.create"
            ]
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:-]{8,100}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "network"
                ],
                "properties": {
                  "network": {
                    "type": "string",
                    "enum": [
                      "BSC",
                      "ETHEREUM"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Carteira já criada.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "wallet": {
                      "$ref": "#/components/schemas/CryptoWallet"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Carteira pronta.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "wallet": {
                      "$ref": "#/components/schemas/CryptoWallet"
                    },
                    "submitted_transaction_hash": {
                      "type": "string",
                      "nullable": true,
                      "description": "Hash informado pelo cliente, ainda não necessariamente validado."
                    },
                    "submitted_explorer_url": {
                      "type": "string",
                      "nullable": true,
                      "format": "uri",
                      "description": "Link do hash informado; não representa confirmação."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Chave ausente ou inválida."
          },
          "401": {
            "description": "Token inválido."
          },
          "403": {
            "description": "Conta ou escopo indisponível."
          },
          "409": {
            "description": "Chave reutilizada em outra rede."
          },
          "422": {
            "description": "Rede sem carteiras adicionais."
          },
          "503": {
            "description": "Tente novamente com a mesma chave."
          }
        }
      }
    },
    "/api/crypto/v1/wallets/{walletId}": {
      "get": {
        "tags": [
          "Criptomoedas · Carteiras"
        ],
        "operationId": "cryptoGetWallet",
        "summary": "Consultar carteira do titular",
        "security": [
          {
            "cryptoBearer": [
              "crypto.read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "walletId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Carteira consultada.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "wallet": {
                      "$ref": "#/components/schemas/CryptoWallet"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Carteira não encontrada para o titular.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          }
        }
      }
    },
    "/api/crypto/v1/balances": {
      "get": {
        "tags": [
          "Criptomoedas · Saldos"
        ],
        "operationId": "cryptoListBalances",
        "summary": "Consultar saldos disponível, reservado e pendente",
        "security": [
          {
            "cryptoBearer": [
              "crypto.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Saldos da conta autenticada. Valores decimais são strings; *_units são inteiros da unidade mínima.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "balances": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CryptoBalance"
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Carteira ou rede indisponível.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          }
        }
      }
    },
    "/api/crypto/v1/transactions": {
      "get": {
        "tags": [
          "Criptomoedas · Extrato"
        ],
        "operationId": "cryptoListTransactions",
        "summary": "Listar operações",
        "security": [
          {
            "cryptoBearer": [
              "crypto.read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página do extrato.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transactions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CryptoOperation"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Cursor inválido.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          }
        }
      }
    },
    "/api/crypto/v1/transactions/{operationId}": {
      "get": {
        "tags": [
          "Criptomoedas · Extrato"
        ],
        "operationId": "cryptoGetTransaction",
        "summary": "Consultar operação",
        "security": [
          {
            "cryptoBearer": [
              "crypto.read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Operação pertencente ao titular autenticado.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transaction": {
                      "$ref": "#/components/schemas/CryptoOperation"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Operação não encontrada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          }
        }
      }
    },
    "/api/crypto/v1/deposits": {
      "get": {
        "tags": [
          "Criptomoedas · Depósitos"
        ],
        "operationId": "cryptoListDeposits",
        "summary": "Listar depósitos observados",
        "description": "Um depósito é creditado pelo monitor depois das confirmações configuradas. O cliente não pode marcar um depósito como pago.",
        "security": [
          {
            "cryptoBearer": [
              "crypto.read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página de depósitos.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deposits": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CryptoDeposit"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/crypto/v1/deposits/{depositId}": {
      "get": {
        "tags": [
          "Criptomoedas · Depósitos"
        ],
        "operationId": "cryptoGetDeposit",
        "summary": "Consultar depósito",
        "security": [
          {
            "cryptoBearer": [
              "crypto.read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "depositId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Depósito pertencente ao titular autenticado.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deposit": {
                      "$ref": "#/components/schemas/CryptoDeposit"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Depósito não encontrado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          }
        }
      }
    },
    "/api/crypto/v1/withdrawals/quote": {
      "post": {
        "tags": [
          "Criptomoedas · Envios"
        ],
        "operationId": "cryptoQuoteWithdrawal",
        "summary": "Solicitar cotação de envio",
        "description": "Gera uma cotação sem transmitir transação. Envie network, asset, amount e destination_address com Idempotency-Key. O valor que o destinatário recebe deve equivaler a pelo menos US$ 5 pela cotação vigente; a tarifa é cobrada à parte. A cotação aplica as taxas percentuais e fixas da conta, valida o ativo, estima gás e verifica o saldo do ativo e do ativo nativo usado na rede. quote_ref expira em 60 segundos. Ativos e redes precisam estar habilitados no catálogo. source_wallet_id é o UUID opcional de uma carteira própria na rede. O padrão é a principal.",
        "security": [
          {
            "cryptoBearer": [
              "crypto.withdrawals"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Cotação calculada e válida por até 60 segundos; inclui quote_ref, tarifas, rede e expiração.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quote_ref": {
                      "type": "string"
                    },
                    "operation_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "network": {
                      "type": "string",
                      "enum": [
                        "BSC",
                        "TRON"
                      ]
                    },
                    "asset": {
                      "type": "string",
                      "enum": [
                        "USDT"
                      ]
                    },
                    "amount_units": {
                      "type": "string"
                    },
                    "total_debit_units": {
                      "type": "string"
                    },
                    "total_fee_units": {
                      "type": "string"
                    },
                    "platform_fee_units": {
                      "type": "string"
                    },
                    "network_fee_units": {
                      "type": "string"
                    },
                    "network_fee_asset": {
                      "type": "string",
                      "enum": [
                        "BNB",
                        "TRX"
                      ]
                    },
                    "expires_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Provedor, preço de referência ou configuração financeira indisponível; nenhum envio foi transmitido.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "network",
                  "asset",
                  "amount",
                  "destination_address"
                ],
                "properties": {
                  "network": {
                    "type": "string"
                  },
                  "asset": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "string"
                  },
                  "destination_address": {
                    "type": "string"
                  },
                  "source_wallet_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9._:-]{8,100}$"
            },
            "description": "Use uma chave única por intenção e preserve a mesma chave ao repetir o mesmo pedido."
          }
        ]
      }
    },
    "/api/crypto/v1/withdrawals": {
      "post": {
        "tags": [
          "Criptomoedas · Envios"
        ],
        "operationId": "cryptoCreateWithdrawal",
        "summary": "Solicitar envio",
        "description": "Confirma uma cotação válida por quote_ref e Idempotency-Key. A autorização do Laravel aplica taxas e limites e reserva o saldo antes de enfileirar a assinatura. HTTP 202 indica aceite durável; consulte a operação pelo operation_id. Em timeout ou resposta ambígua, consulte o estado ou repita com a mesma chave; não crie outra operação.",
        "security": [
          {
            "cryptoBearer": [
              "crypto.withdrawals"
            ]
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resposta de uma solicitação idempotente já conhecida."
          },
          "202": {
            "description": "Envio persistido e enfileirado para execução; acompanhe o operation_id."
          },
          "503": {
            "description": "Autorização indisponível ou resultado ainda em reconciliação; consulte o estado antes de tentar novamente.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          }
        }
      }
    },
    "/api/crypto/v1/withdrawals/{operationId}": {
      "get": {
        "tags": [
          "Criptomoedas · Envios"
        ],
        "operationId": "cryptoGetWithdrawal",
        "summary": "Consultar envio",
        "security": [
          {
            "cryptoBearer": [
              "crypto.withdrawals"
            ]
          }
        ],
        "parameters": [
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Estado do envio pertencente ao titular."
          },
          "404": {
            "description": "Envio não encontrado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          }
        }
      }
    },
    "/api/crypto/v1/swaps/quote": {
      "post": {
        "tags": [
          "Criptomoedas · Swaps"
        ],
        "operationId": "cryptoQuoteSwap",
        "summary": "Solicitar cotação de swap",
        "description": "Retorna uma cotação e os custos para pares na BSC ou TRON e prévias cross-chain via 1Click. O modo público acrescenta 25 bps (0,25%) do provedor à estimativa de saída e expõe esse valor em provider_access_fee, separado da taxa AvalonPay. A cotação usa dry-run e não cria ordem nem movimenta fundos. Same-chain aceita BNB ou token BEP-20 aprovado na BSC e TRX ou token TRC-20 aprovado na TRON. Para origem TRC-20, a API prepara aprovação de valor exato e assinatura Permit2 com prazo limitado; o swap só avança após confirmação solidificada da aprovação. Cross-chain pode aceitar BNB ou token BEP-20 aprovado como origem na BSC, e TRX ou token TRC-20 aprovado na TRON, se houver rota real no provedor; a disponibilidade pode variar por direção e por par. Ao enviar token como origem, o saldo do ativo e o gás nativo da rede são reservados separadamente. Confira execution_enabled; execution_ready=false significa que a ordem e a transação de origem ainda serão materializadas em POST /swaps. A rota pode deixar de estar disponível antes da confirmação. Cotações expiram em 45 segundos. ATENÇÃO: a cotação valida o saldo. A conta precisa ter saldo disponível do ativo de origem para cobrir a quantidade, a taxa AvalonPay e a taxa de rede; sem saldo a resposta é 422 INSUFFICIENT_BALANCE. Os valores *_units vêm na menor unidade do ativo (ex.: 18 casas para BNB e para os tokens BEP-20 da BSC; 6 casas para TRX e USDT na TRON). Envie o cabeçalho Idempotency-Key. Para só consultar preço sem executar, use esta rota e não chame POST /swaps.",
        "security": [
          {
            "cryptoBearer": [
              "crypto.swaps"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Cotação persistida. A resposta mostra separadamente a taxa AvalonPay e o adicional público da 1Click, quando aplicável. execution_enabled indica que a cotação está apta a ser enviada para confirmação; execution_ready indica que ordem e transação de origem já foram preparadas.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quote_ref": {
                      "type": "string"
                    },
                    "operation_id": {
                      "type": "string"
                    },
                    "network": {
                      "type": "string"
                    },
                    "network_in": {
                      "type": "string"
                    },
                    "network_out": {
                      "type": "string"
                    },
                    "asset_in": {
                      "type": "string"
                    },
                    "asset_out": {
                      "type": "string"
                    },
                    "amount_in_units": {
                      "type": "string"
                    },
                    "total_debit_units": {
                      "type": "string"
                    },
                    "expected_amount_out_units": {
                      "type": "string"
                    },
                    "minimum_amount_out_units": {
                      "type": "string"
                    },
                    "provider_access_fee": {
                      "type": "object",
                      "nullable": true,
                      "description": "Taxa da 1Click no modo de acesso público; incluída na saída estimada e não debitada separadamente.",
                      "properties": {
                        "provider": {
                          "type": "string",
                          "example": "NEAR_INTENTS_1CLICK"
                        },
                        "rate_bps": {
                          "type": "integer",
                          "example": 25
                        },
                        "rate_percent": {
                          "type": "string",
                          "example": "0.25"
                        },
                        "included_in_expected_output": {
                          "type": "boolean",
                          "example": true
                        },
                        "charged_separately": {
                          "type": "boolean",
                          "example": false
                        }
                      }
                    },
                    "avalonpay_fee": {
                      "type": "object",
                      "description": "Taxa própria da AvalonPay, calculada conforme a política da conta.",
                      "properties": {
                        "rate_bps": {
                          "type": "integer"
                        },
                        "rate_percent": {
                          "type": "string"
                        },
                        "amount_units": {
                          "type": "string"
                        },
                        "fixed_brl": {
                          "type": "string"
                        }
                      }
                    },
                    "execution_enabled": {
                      "type": "boolean",
                      "description": "Indica que a cotação vigente pode ser submetida para confirmação. Não significa que a ordem já foi criada ou transmitida."
                    },
                    "execution_ready": {
                      "type": "boolean",
                      "description": "Indica que os dados de execução já estão preparados. Em cotações cross-chain, fica false até a criação da ordem no provedor."
                    },
                    "execution_blocked_reason": {
                      "type": "string",
                      "nullable": true
                    },
                    "expires_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "slippage_bps": {
                      "type": "integer",
                      "description": "Tolerância de preço aplicada, em pontos-base."
                    },
                    "price_impact": {
                      "type": "string",
                      "nullable": true,
                      "description": "Impacto de preço estimado, quando a rota informa."
                    },
                    "route": {
                      "type": "object",
                      "description": "Rota usada na cotação (provedor, tokens e faixas de taxa)."
                    },
                    "limit_amount_brl": {
                      "type": "string",
                      "description": "Valor-limite da operação em reais usado no cálculo da taxa."
                    },
                    "network_fee": {
                      "type": "object",
                      "description": "Estimativa máxima da taxa de rede: amount_units, asset e kind."
                    },
                    "approval_required": {
                      "type": "boolean"
                    },
                    "approval_steps": {
                      "type": "integer"
                    }
                  }
                },
                "example": {
                  "quote_ref": "00000000-0000-4000-8000-000000000001",
                  "operation_id": "00000000-0000-4000-8000-000000000002",
                  "network": "BSC",
                  "network_in": "BSC",
                  "network_out": "BSC",
                  "asset_in": "BNB",
                  "asset_out": "USDT",
                  "amount_in_units": "1000000000000000",
                  "total_debit_units": "1155006133759459",
                  "expected_amount_out_units": "582446580256926788",
                  "minimum_amount_out_units": "579534347355642154",
                  "slippage_bps": 50,
                  "price_impact": null,
                  "route": {
                    "provider": "PANCAKESWAP_V3",
                    "fee_tiers": [
                      100
                    ],
                    "estimated_gas": "92234"
                  },
                  "provider_access_fee": null,
                  "avalonpay_fee": {
                    "rate_bps": 100,
                    "rate_percent": "1.00",
                    "amount_units": "155006133759459",
                    "percentage_units": "10000000000000",
                    "fixed_brl": "0.50",
                    "fixed_amount_units": "145006133759459"
                  },
                  "limit_amount_brl": "3.99",
                  "network_fee": {
                    "amount_units": "9911650000000",
                    "asset": "BNB",
                    "kind": "maximum_estimate"
                  },
                  "approval_required": false,
                  "approval_steps": 0,
                  "execution_enabled": true,
                  "execution_ready": true,
                  "execution_blocked_reason": null,
                  "expires_at": "2026-11-20T00:19:21.258Z"
                }
              }
            }
          },
          "400": {
            "description": "IDEMPOTENCY_KEY_REQUIRED: o cabeçalho Idempotency-Key está ausente ou fora do padrão.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          },
          "401": {
            "description": "Token ausente, inválido ou expirado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          },
          "403": {
            "description": "A credencial não tem a permissão crypto.swaps.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          },
          "422": {
            "description": "Pedido recusado: NETWORK_UNSUPPORTED (rede sem cotação), SWAP_PAIR_INVALID (ativos iguais ou inválidos), SWAP_AMOUNT_INVALID (quantidade), SLIPPAGE_INVALID (1 a 2000), UNSUPPORTED_ASSET (ativo não habilitado na rede) ou INSUFFICIENT_BALANCE (saldo disponível não cobre a quantidade, a taxa AvalonPay e a taxa de rede).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          },
          "503": {
            "description": "Provedor de preço ou rede indisponível; nenhuma troca foi iniciada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Chave única da cotação (8 a 100 caracteres: letras, números, ponto, hífen, dois-pontos e sublinhado). Repetir a mesma chave com o mesmo corpo devolve a mesma cotação.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:-]{8,100}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "asset_in",
                  "asset_out",
                  "amount"
                ],
                "properties": {
                  "network": {
                    "type": "string",
                    "enum": [
                      "BSC",
                      "TRON"
                    ],
                    "description": "Rede do swap na mesma rede. Use no lugar de network_in/network_out quando origem e destino estão na mesma rede."
                  },
                  "network_in": {
                    "type": "string",
                    "enum": [
                      "BSC",
                      "TRON"
                    ],
                    "description": "Rede de origem (cross-chain). Sem network_in, vale network."
                  },
                  "network_out": {
                    "type": "string",
                    "enum": [
                      "BSC",
                      "TRON"
                    ],
                    "description": "Rede de destino (cross-chain). Sem network_out, vale network."
                  },
                  "asset_in": {
                    "type": "string",
                    "description": "Código do ativo de origem na rede. BSC: BNB, BTCB, CAKE, DOGE, ETH, LINK, SOL, USDC, USDT, XRP, ADA, DOT, LTC, BCH, UNI, XVS, WBNB. TRON: TRX, USDT."
                  },
                  "asset_out": {
                    "type": "string",
                    "description": "Código do ativo de destino, na rede de destino. Precisa ser diferente do ativo de origem na mesma rede."
                  },
                  "amount": {
                    "type": "string",
                    "pattern": "^(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?$",
                    "description": "Quantidade do ativo de origem em unidades inteiras do ativo, como texto decimal com ponto (ex.: \"0.001\" BNB). Não use vírgula."
                  },
                  "slippage_bps": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 2000,
                    "default": 50,
                    "description": "Tolerância de preço em pontos-base (50 = 0,50%). Opcional; padrão 50, máximo 2000 (20%)."
                  }
                }
              },
              "example": {
                "network": "BSC",
                "asset_in": "BNB",
                "asset_out": "USDT",
                "amount": "0.001",
                "slippage_bps": 50
              }
            }
          }
        }
      }
    },
    "/api/crypto/v1/swaps": {
      "post": {
        "tags": [
          "Criptomoedas · Swaps"
        ],
        "operationId": "cryptoCreateSwap",
        "summary": "Solicitar swap",
        "description": "Confirma uma cotação vigente com execution_enabled=true e Idempotency-Key. O Laravel aplica taxas, limites e reserva os saldos. Em cross-chain, a API cria uma ordem real no provedor e, para origem por token na BSC ou TRON, reserva o token e o ativo nativo de gás separadamente antes de transmitir a transferência exata para o endereço da ordem. HTTP 202 indica aceite durável. A operação só fica concluída após confirmação do ativo final na rede de destino.",
        "security": [
          {
            "cryptoBearer": [
              "crypto.swaps"
            ]
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resposta de uma solicitação idempotente já conhecida."
          },
          "202": {
            "description": "Swap persistido e enfileirado para execução; acompanhe o operation_id."
          },
          "503": {
            "description": "Autorização indisponível ou resultado ainda em reconciliação; consulte o estado antes de tentar novamente.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          }
        }
      }
    },
    "/api/crypto/v1/swaps/{operationId}": {
      "get": {
        "tags": [
          "Criptomoedas · Swaps"
        ],
        "operationId": "cryptoGetSwap",
        "summary": "Consultar swap",
        "security": [
          {
            "cryptoBearer": [
              "crypto.swaps"
            ]
          }
        ],
        "parameters": [
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Estado do swap pertencente ao titular."
          },
          "404": {
            "description": "Swap não encontrado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          }
        }
      }
    },
    "/api/crypto/v1/webhook-endpoints": {
      "get": {
        "tags": [
          "Criptomoedas · Webhooks"
        ],
        "operationId": "cryptoListWebhookEndpoints",
        "summary": "Listar callbacks cripto",
        "security": [
          {
            "cryptoBearer": [
              "crypto.webhooks"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Callbacks da credencial autenticada.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "endpoints": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CryptoWebhookEndpoint"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Criptomoedas · Webhooks"
        ],
        "operationId": "cryptoCreateWebhookEndpoint",
        "summary": "Cadastrar callback",
        "description": "Aceita somente HTTPS público. O signing_secret é exibido uma única vez.",
        "security": [
          {
            "cryptoBearer": [
              "crypto.webhooks"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "url",
                  "events"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 96
                  },
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Callback criado. Armazene o segredo exibido agora.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "example": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "endpoint": {
                      "$ref": "#/components/schemas/CryptoWebhookEndpoint"
                    },
                    "signing_secret": {
                      "type": "string",
                      "pattern": "^apwhsec_"
                    },
                    "submitted_transaction_hash": {
                      "type": "string",
                      "nullable": true,
                      "description": "Hash informado pelo cliente, ainda não necessariamente validado."
                    },
                    "submitted_explorer_url": {
                      "type": "string",
                      "nullable": true,
                      "format": "uri",
                      "description": "Link do hash informado; não representa confirmação."
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "URL, eventos ou dados inválidos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoError"
                }
              }
            }
          }
        }
      }
    },
    "/api/crypto/v1/webhook-endpoints/{endpointId}": {
      "get": {
        "tags": [
          "Criptomoedas · Webhooks"
        ],
        "operationId": "cryptoGetWebhookEndpoint",
        "summary": "Consultar callback",
        "security": [
          {
            "cryptoBearer": [
              "crypto.webhooks"
            ]
          }
        ],
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Callback da credencial autenticada."
          },
          "404": {
            "description": "Callback não encontrado."
          }
        }
      },
      "patch": {
        "tags": [
          "Criptomoedas · Webhooks"
        ],
        "operationId": "cryptoUpdateWebhookEndpoint",
        "summary": "Editar callback",
        "description": "Alterações criam uma nova versão; entregas pendentes mantêm o snapshot original.",
        "security": [
          {
            "cryptoBearer": [
              "crypto.webhooks"
            ]
          }
        ],
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Callback atualizado."
          },
          "404": {
            "description": "Callback não encontrado."
          },
          "422": {
            "description": "Alteração inválida."
          }
        }
      },
      "delete": {
        "tags": [
          "Criptomoedas · Webhooks"
        ],
        "operationId": "cryptoDeleteWebhookEndpoint",
        "summary": "Desativar callback",
        "security": [
          {
            "cryptoBearer": [
              "crypto.webhooks"
            ]
          }
        ],
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Callback desativado."
          },
          "404": {
            "description": "Callback não encontrado."
          }
        }
      }
    },
    "/api/crypto/v1/webhook-endpoints/{endpointId}/test": {
      "post": {
        "tags": [
          "Criptomoedas · Webhooks"
        ],
        "operationId": "cryptoTestWebhookEndpoint",
        "summary": "Enfileirar evento de teste",
        "description": "Cria webhook.test sem IDs ou confirmações financeiras reais. Entrega ocorre em worker assíncrono.",
        "security": [
          {
            "cryptoBearer": [
              "crypto.webhooks"
            ]
          }
        ],
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Teste persistido para entrega."
          },
          "404": {
            "description": "Callback não encontrado."
          }
        }
      }
    },
    "/api/crypto/v1/webhook-endpoints/{endpointId}/rotate-secret": {
      "post": {
        "tags": [
          "Criptomoedas · Webhooks"
        ],
        "operationId": "cryptoRotateWebhookSecret",
        "summary": "Rotacionar signing secret",
        "description": "O segredo novo aparece uma vez. As novas entregas usam a versão atualizada.",
        "security": [
          {
            "cryptoBearer": [
              "crypto.webhooks"
            ]
          }
        ],
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Segredo rotacionado.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "example": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "endpoint": {
                      "$ref": "#/components/schemas/CryptoWebhookEndpoint"
                    },
                    "signing_secret": {
                      "type": "string",
                      "pattern": "^apwhsec_"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Callback não encontrado."
          }
        }
      }
    },
    "/api/crypto/v1/webhook-deliveries": {
      "get": {
        "tags": [
          "Criptomoedas · Webhooks"
        ],
        "operationId": "cryptoListWebhookDeliveries",
        "summary": "Listar entregas",
        "security": [
          {
            "cryptoBearer": [
              "crypto.webhooks"
            ]
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Histórico paginado da credencial autenticada."
          }
        }
      }
    },
    "/api/crypto/v1/webhook-deliveries/{deliveryId}/retry": {
      "post": {
        "tags": [
          "Criptomoedas · Webhooks"
        ],
        "operationId": "cryptoRetryWebhookDelivery",
        "summary": "Solicitar nova entrega",
        "description": "Reenvia o mesmo event_id e conteúdo; cada tentativa recebe delivery_id, timestamp e assinatura novos.",
        "security": [
          {
            "cryptoBearer": [
              "crypto.webhooks"
            ]
          }
        ],
        "parameters": [
          {
            "name": "deliveryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Reenvio persistido para o worker."
          },
          "404": {
            "description": "Entrega não encontrada."
          }
        }
      }
    },
    "/api/webhooks": {
      "get": {
        "tags": [
          "Webhooks de pagamentos"
        ],
        "summary": "Consultar a configuração e entregas recentes",
        "description": "O segredo de assinatura nunca é retornado. A resposta é privada e não cacheável.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Configuração da conta e histórico recente.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "endpoint": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/PaymentWebhookEndpoint"
                        }
                      ],
                      "nullable": true
                    },
                    "events": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "pix.in.created",
                          "pix.in.completed",
                          "pix.in.failed",
                          "pix.out.created",
                          "pix.out.processing",
                          "pix.out.completed",
                          "pix.out.failed",
                          "pix.qr_pay.created",
                          "pix.qr_pay.processing",
                          "pix.qr_pay.completed",
                          "pix.qr_pay.failed",
                          "boleto.created",
                          "boleto.paid",
                          "boleto.failed",
                          "card.payment.created",
                          "card.payment.paid",
                          "card.payment.failed",
                          "med.received",
                          "med.updated",
                          "med.balance_changed",
                          "med.defense_submitted",
                          "med.resolved"
                        ]
                      }
                    },
                    "deliveries": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PaymentWebhookDelivery"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Token ausente ou inválido."
          },
          "403": {
            "description": "Credencial sem webhooks.manage."
          }
        }
      },
      "put": {
        "tags": [
          "Webhooks de pagamentos"
        ],
        "summary": "Configurar o destino fixo de pagamentos",
        "description": "Há um único endpoint por conta. A primeira ativação ou reativação retorna o signing_secret uma única vez. Alterações de URL/eventos mantêm o segredo atual. A URL deve usar HTTPS na porta 443 e resolver apenas para endereços públicos; URLs privadas, credenciais e redirecionamentos não são aceitos. Envie a lista completa de eventos que deseja manter. Os eventos MED são opcionais e valem para mudanças futuras, incluindo casos abertos pelo Compliance, alterações do bloqueio, defesas e encerramentos. Os eventos usam a mesma fila assinada e retentativas.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url",
                  "events"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048
                  },
                  "events": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 22,
                    "uniqueItems": true,
                    "items": {
                      "type": "string",
                      "enum": [
                        "pix.in.created",
                        "pix.in.completed",
                        "pix.in.failed",
                        "pix.out.created",
                        "pix.out.processing",
                        "pix.out.completed",
                        "pix.out.failed",
                        "pix.qr_pay.created",
                        "pix.qr_pay.processing",
                        "pix.qr_pay.completed",
                        "pix.qr_pay.failed",
                        "boleto.created",
                        "boleto.paid",
                        "boleto.failed",
                        "card.payment.created",
                        "card.payment.paid",
                        "card.payment.failed",
                        "med.received",
                        "med.updated",
                        "med.balance_changed",
                        "med.defense_submitted",
                        "med.resolved"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Configuração atualizada; signing_secret é null.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "endpoint": {
                      "$ref": "#/components/schemas/PaymentWebhookEndpoint"
                    },
                    "signing_secret": {
                      "type": "string",
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Destino criado; guarde o signing_secret agora, ele não será exibido novamente."
          },
          "400": {
            "description": "URL ou lista de eventos inválida."
          },
          "401": {
            "description": "Token ausente ou inválido."
          },
          "403": {
            "description": "Credencial sem webhooks.manage."
          },
          "503": {
            "description": "Chave de cifragem indisponível no servidor."
          }
        },
        "callbacks": {
          "eventoDaConta": {
            "{$request.body#/url}": {
              "post": {
                "summary": "Evento assinado da conta",
                "description": "Valide HMAC-SHA256(timestamp + \".\" + corpo bruto) com signing_secret e deduplique por id. Para MED, consulte GET /api/infractions/{infraction_id} para reconciliar. med.received — Primeiro vínculo da infração com um Pix desta conta. Um caso identificado tardiamente pode chegar já encerrado. med.updated — O caso mudou para outro status em aberto, como under_review. med.balance_changed — Houve movimento efetivo na carteira. movements lista as variações do saldo disponível e do bloqueado. med.defense_submitted — O recebimento da defesa foi confirmado. O resultado da análise chega em med.resolved. med.resolved — O caso foi encerrado. status informa won (ganho), lost (perdido) ou cancelled (cancelado).",
                "parameters": [
                  {
                    "in": "header",
                    "name": "X-Avalonpay-Event",
                    "required": true,
                    "schema": {
                      "type": "string"
                    }
                  },
                  {
                    "in": "header",
                    "name": "X-Avalonpay-Event-Id",
                    "required": true,
                    "schema": {
                      "type": "string"
                    }
                  },
                  {
                    "in": "header",
                    "name": "X-Avalonpay-Delivery-Id",
                    "required": true,
                    "schema": {
                      "type": "string"
                    }
                  },
                  {
                    "in": "header",
                    "name": "X-Avalonpay-Timestamp",
                    "required": true,
                    "schema": {
                      "type": "string"
                    }
                  },
                  {
                    "in": "header",
                    "name": "X-Avalonpay-Signature",
                    "required": true,
                    "schema": {
                      "type": "string"
                    }
                  }
                ],
                "requestBody": {
                  "required": true,
                  "content": {
                    "application/json": {
                      "schema": {
                        "$ref": "#/components/schemas/PaymentWebhookEvent"
                      },
                      "examples": {
                        "bloqueioMed": {
                          "value": {
                            "id": "dabd8314-6eb1-44a4-bfd5-52c19fc63d4d",
                            "type": "med.balance_changed",
                            "created_at": "2026-11-14T15:04:05.000Z",
                            "data": {
                              "infraction_id": "57aedb28-a60b-4c88-b03c-4fc7b96bc71a",
                              "transaction_id": "AP-EXEMPLO-42",
                              "end_to_end_id": null,
                              "status": "open",
                              "defense_status": "none",
                              "currency": "BRL",
                              "amount_cents": 2500,
                              "blocked_cents": 2500,
                              "opened_at": "2026-11-14T15:01:00.000Z",
                              "movements": [
                                {
                                  "stage": "held",
                                  "available_delta_cents": -2500,
                                  "blocked_delta_cents": 2500
                                }
                              ]
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "responses": {
                  "2XX": {
                    "description": "Evento recebido e registrado."
                  },
                  "default": {
                    "description": "Entrega sujeita a novas tentativas, até oito no total."
                  }
                },
                "security": []
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks de pagamentos"
        ],
        "summary": "Desativar o webhook de pagamentos",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Destino desativado e segredo removido da fila."
          },
          "401": {
            "description": "Token ausente ou inválido."
          },
          "403": {
            "description": "Credencial sem webhooks.manage."
          }
        }
      }
    },
    "/api/webhooks/rotate-secret": {
      "post": {
        "tags": [
          "Webhooks de pagamentos"
        ],
        "summary": "Rotacionar o signing secret",
        "description": "Invalida o segredo anterior, cancela entregas pendentes e retorna o novo segredo uma única vez.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Novo segredo criado; copie e guarde imediatamente.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "endpoint": {
                      "$ref": "#/components/schemas/PaymentWebhookEndpoint"
                    },
                    "signing_secret": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Token ausente ou inválido."
          },
          "403": {
            "description": "Credencial sem webhooks.manage."
          },
          "404": {
            "description": "Destino ativo não encontrado."
          }
        }
      }
    },
    "/api/webhooks/test": {
      "post": {
        "tags": [
          "Webhooks de pagamentos"
        ],
        "summary": "Enfileirar um evento de teste",
        "description": "Envia webhook.test ao destino ativo sem executar operação financeira.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Evento de teste enfileirado.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "event_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "delivery_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Token ausente ou inválido."
          },
          "403": {
            "description": "Credencial sem webhooks.manage."
          },
          "404": {
            "description": "Destino ativo não encontrado."
          }
        }
      }
    },
    "/api/webhooks/deliveries/{deliveryId}/retry": {
      "post": {
        "tags": [
          "Webhooks de pagamentos"
        ],
        "summary": "Tentar novamente uma entrega com falha",
        "description": "Somente entregas FAILED podem ser reenfileiradas. A configuração atual precisa manter a mesma URL, signing secret e inscrição no evento.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "deliveryId",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Entrega reenfileirada com o mesmo event_id e delivery_id."
          },
          "401": {
            "description": "Token ausente ou inválido."
          },
          "403": {
            "description": "Credencial sem webhooks.manage."
          },
          "404": {
            "description": "Entrega não encontrada nesta conta."
          },
          "409": {
            "description": "Entrega ainda não falhou ou a configuração mudou."
          }
        }
      }
    },
    "/api/payments/pix/{transaction_id}/status": {
      "get": {
        "tags": [
          "Pagamentos"
        ],
        "summary": "Consultar código e estado do Pix assíncrono",
        "description": "Disponível para cobranças que retornam status_url. Escopo pix.cash_in. Consulta isolada por usuário. HTTP 202 na criação nunca significa pagamento concluído. Prefira webhooks para a confirmação financeira.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "transaction_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^avp_[a-f0-9]{32}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Estado local conciliado pela AvalonPay",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transaction_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "PENDING",
                        "COMPLETED",
                        "FAILED",
                        "EXPIRED"
                      ]
                    },
                    "amount": {
                      "type": "number"
                    },
                    "pix_status": {
                      "type": "string"
                    },
                    "qrcode": {
                      "type": "string",
                      "nullable": true
                    },
                    "expires_at": {
                      "type": "string",
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Credencial inválida"
          },
          "403": {
            "description": "Escopo ou IP sem autorização"
          },
          "404": {
            "description": "Cobrança não encontrada nesta conta"
          },
          "429": {
            "description": "Aguarde antes de consultar novamente"
          }
        }
      }
    },
    "/api/infractions": {
      "get": {
        "tags": [
          "Infrações Pix"
        ],
        "summary": "Listar infrações da conta",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "page",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MedInfraction"
                      }
                    },
                    "page": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "per_page": {
                      "type": "integer"
                    },
                    "blocked_cents": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Permissão insuficiente"
          }
        },
        "description": "A resposta inclui source=provider ou source=compliance. Casos manuais do Compliance aparecem nesta mesma lista e não chamam a API da liquidante. Datas são apresentadas em UTC."
      }
    },
    "/api/infractions/{id}": {
      "get": {
        "tags": [
          "Infrações Pix"
        ],
        "summary": "Consultar infração da conta",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MedInfraction"
                }
              }
            }
          },
          "403": {
            "description": "Permissão insuficiente"
          }
        },
        "description": "A resposta inclui source=provider ou source=compliance. Casos manuais do Compliance aparecem nesta mesma lista e não chamam a API da liquidante. Datas são apresentadas em UTC."
      }
    },
    "/api/infractions/{id}/defense": {
      "post": {
        "tags": [
          "Infrações Pix"
        ],
        "summary": "Enviar defesa de uma infração",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MedInfraction"
                }
              }
            }
          },
          "202": {
            "description": "Envio em confirmação"
          },
          "403": {
            "description": "Permissão insuficiente"
          },
          "409": {
            "description": "Caso não aceita nova defesa"
          },
          "422": {
            "description": "Dados recusados"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "defense"
                ],
                "properties": {
                  "defense": {
                    "type": "string",
                    "maxLength": 2000,
                    "minLength": 1
                  },
                  "proofs": {
                    "type": "array",
                    "maxItems": 10,
                    "items": {
                      "type": "string",
                      "format": "uri"
                    }
                  },
                  "files": {
                    "type": "array",
                    "maxItems": 5,
                    "items": {
                      "type": "object",
                      "required": [
                        "name",
                        "content"
                      ],
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "content": {
                          "type": "string",
                          "format": "byte"
                        }
                      }
                    }
                  }
                },
                "description": "Para evidence_mode=none, envie apenas defense. proofs/files não são aceitos."
              }
            }
          }
        },
        "description": "Requer infractions.respond. Envie defesa apenas quando can_defend=true. No modo evidence_mode=none, usado em caso manual aberto pelo Compliance, envie somente defense em texto; o recebimento pela AvalonPay retorna HTTP 201 e não chama o provedor. Nos modos links e files, a defesa segue a confirmação do provedor e pode retornar HTTP 202."
      }
    },
    "/api/crypto/v1/wallets/additional": {
      "get": {
        "tags": [
          "Criptomoedas · Carteiras"
        ],
        "summary": "Listar endereços adicionais",
        "operationId": "cryptoListAdditionalWallets",
        "security": [
          {
            "cryptoBearer": [
              "crypto.read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página por ordem de criação.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "wallets": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CryptoWallet"
                      }
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/crypto/usdt-tron/orders": {
      "servers": [
        {
          "url": "https://avalonpay.com.br",
          "description": "Portal AvalonPay · API JWT de compra USDT TRON"
        }
      ],
      "get": {
        "tags": [
          "Criptomoedas · Compra USDT TRON"
        ],
        "operationId": "listManagedUsdtTronOrders",
        "summary": "Listar pedidos de compra USDT TRON",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "description": "Retorna os últimos 30 pedidos pertencentes à conta autenticada.",
        "responses": {
          "200": {
            "description": "Pedidos recentes.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "orders": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CryptoUsdtTronOrder"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "JWT ausente ou inválido."
          },
          "403": {
            "description": "Conta não aprovada."
          },
          "429": {
            "description": "Limite de consultas atingido."
          }
        }
      }
    },
    "/api/v1/crypto/usdt-tron/quote": {
      "servers": [
        {
          "url": "https://avalonpay.com.br",
          "description": "Portal AvalonPay · API JWT de compra USDT TRON"
        }
      ],
      "post": {
        "tags": [
          "Criptomoedas · Compra USDT TRON"
        ],
        "operationId": "quoteManagedUsdtTronPurchase",
        "summary": "Cotar compra gerenciada de USDT TRON",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "description": "Cota uma compra em BRL para USDT TRC20. Usa Binance Spot USDTBRL best ask e o spread AvalonPay configurado, além da política de tarifas e custos Pix aplicáveis. A cotação não movimenta saldo; mínimo de R$ 5,00; validade devolvida em quote_expires_at. Envie a mesma Idempotency-Key somente para repetir a mesma solicitação. Os campos retornados são a referência final para exibição do total em BRL e do USDT líquido.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9._:-]{8,100}$"
            },
            "description": "Use uma chave única por intenção e preserve a mesma chave ao repetir o mesmo pedido."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "amount_brl",
                  "destination_address"
                ],
                "properties": {
                  "amount_brl": {
                    "type": "string",
                    "pattern": "^(?:0|[1-9]\\d{0,8})(?:[.,]\\d{1,2})?$",
                    "example": "100.00",
                    "description": "Valor total informado em BRL, string decimal com até duas casas."
                  },
                  "destination_address": {
                    "type": "string",
                    "maxLength": 80,
                    "example": "TENDERECO_TRON_VALIDADO",
                    "description": "Endereço TRON escolhido pelo cliente; pode ser interno ou externo."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Cotação criada; nenhum saldo foi debitado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoUsdtTronOrder"
                }
              }
            }
          },
          "401": {
            "description": "JWT ausente ou inválido."
          },
          "403": {
            "description": "Conta não aprovada para a API."
          },
          "422": {
            "description": "Valor, endereço ou chave idempotente inválidos; mínimo de R$ 5,00."
          },
          "429": {
            "description": "Limite de cotações atingido; 10 por minuto."
          },
          "503": {
            "description": "Cotação de mercado ou serviço temporariamente indisponível."
          }
        }
      }
    },
    "/api/v1/crypto/usdt-tron/orders/{orderId}/confirm": {
      "servers": [
        {
          "url": "https://avalonpay.com.br",
          "description": "Portal AvalonPay · API JWT de compra USDT TRON"
        }
      ],
      "post": {
        "tags": [
          "Criptomoedas · Compra USDT TRON"
        ],
        "operationId": "confirmManagedUsdtTronPurchase",
        "summary": "Confirmar compra cotada de USDT TRON",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "description": "Confirma um pedido ainda válido com o PIN transacional. Inicia o processamento da compra. Envie uma única vez; em timeout consulte o mesmo pedido antes de qualquer nova tentativa.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "pin"
                ],
                "properties": {
                  "pin": {
                    "type": "string",
                    "description": "PIN transacional da conta. Envie somente de um backend protegido."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Pedido processado ou estado idempotente existente.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoUsdtTronOrder"
                }
              }
            }
          },
          "202": {
            "description": "Pix ou conciliação em andamento.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoUsdtTronOrder"
                }
              }
            }
          },
          "401": {
            "description": "JWT ausente ou inválido."
          },
          "403": {
            "description": "Conta ou PIN não autorizado."
          },
          "404": {
            "description": "Pedido inexistente ou pertencente a outra conta."
          },
          "422": {
            "description": "Cotação expirada ou pedido incompatível com a confirmação."
          },
          "429": {
            "description": "Limite de confirmações atingido; 5 por minuto."
          },
          "503": {
            "description": "Resultado não conclusivo; consulte o mesmo pedido antes de repetir."
          }
        }
      }
    },
    "/api/v1/crypto/usdt-tron/orders/{orderId}": {
      "servers": [
        {
          "url": "https://avalonpay.com.br",
          "description": "Portal AvalonPay · API JWT de compra USDT TRON"
        }
      ],
      "get": {
        "tags": [
          "Criptomoedas · Compra USDT TRON"
        ],
        "operationId": "getManagedUsdtTronOrder",
        "summary": "Consultar compra USDT TRON",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "description": "Atualiza e retorna o pedido da conta autenticada.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pedido e estado atual.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoUsdtTronOrder"
                }
              }
            }
          },
          "401": {
            "description": "JWT ausente ou inválido."
          },
          "403": {
            "description": "Conta não aprovada."
          },
          "404": {
            "description": "Pedido inexistente ou pertencente a outra conta."
          },
          "429": {
            "description": "Limite de consultas atingido."
          }
        }
      }
    },
    "/api/v1/crypto/usdt-tron-sale/pix-key": {
      "servers": [
        {
          "url": "https://avalonpay.com.br",
          "description": "Portal AvalonPay · API JWT de venda USDT TRON"
        }
      ],
      "get": {
        "tags": [
          "Criptomoedas · Venda USDT TRON"
        ],
        "operationId": "getTronSalePixKey",
        "summary": "Consultar chave Pix salva para vendas",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "description": "Retorna somente o tipo e a chave mascarada da conta autenticada.",
        "responses": {
          "200": {
            "description": "Chave Pix mascarada.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "configured": {
                      "type": "boolean"
                    },
                    "key_type": {
                      "type": "string"
                    },
                    "masked_key": {
                      "type": "string",
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "JWT inválido ou ausente."
          },
          "403": {
            "description": "Conta não aprovada."
          },
          "422": {
            "description": "Dados inválidos, cotação expirada ou regra da operação recusada."
          },
          "429": {
            "description": "Limite de requisições atingido."
          }
        }
      },
      "put": {
        "tags": [
          "Criptomoedas · Venda USDT TRON"
        ],
        "operationId": "saveTronSalePixKey",
        "summary": "Salvar ou atualizar chave Pix",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "key_type",
                  "pix_key"
                ],
                "properties": {
                  "key_type": {
                    "type": "string",
                    "enum": [
                      "CPF",
                      "CNPJ",
                      "EMAIL",
                      "PHONE",
                      "EVP"
                    ]
                  },
                  "pix_key": {
                    "type": "string",
                    "description": "Chave Pix de titularidade/uso do cliente. É criptografada em repouso.",
                    "example": "cliente@example.com"
                  }
                }
              },
              "example": {
                "key_type": "EMAIL",
                "pix_key": "cliente@example.com"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Chave salva; a resposta é mascarada.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "configured": {
                      "type": "boolean"
                    },
                    "key_type": {
                      "type": "string"
                    },
                    "masked_key": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "JWT inválido ou ausente."
          },
          "403": {
            "description": "Conta não aprovada."
          },
          "422": {
            "description": "Dados inválidos, cotação expirada ou regra da operação recusada."
          },
          "429": {
            "description": "Limite de requisições atingido."
          }
        }
      }
    },
    "/api/v1/crypto/usdt-tron-sale/quotes": {
      "servers": [
        {
          "url": "https://avalonpay.com.br",
          "description": "Portal AvalonPay · API JWT de venda USDT TRON"
        }
      ],
      "post": {
        "tags": [
          "Criptomoedas · Venda USDT TRON"
        ],
        "operationId": "quoteTronSale",
        "summary": "Cotar venda de USDT TRC-20",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9._:-]{8,100}$"
            },
            "description": "Chave estável para repetir a mesma solicitação sem duplicar a operação."
          }
        ],
        "description": "Cota 5 a 100.000 USDT usando Binance Spot USDTBRL best bid; desconta o spread configurado e a tarifa global swap (percentual e fixa). A cotação é válida por 15 minutos, persiste os componentes e não movimenta saldo nem paga Pix.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "amount_usdt"
                ],
                "properties": {
                  "amount_usdt": {
                    "type": "string",
                    "pattern": "^(?:0|[1-9][0-9]{0,5})(?:[.,][0-9]{1,6})?$",
                    "example": "25.00"
                  }
                }
              },
              "example": {
                "amount_usdt": "25.00"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Cotação pronta; use response.order_id como quote_id ao criar a ordem.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "order_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "QUOTE_READY",
                        "AWAITING_USDT",
                        "USDT_CONFIRMING",
                        "PIX_PENDING",
                        "PIX_PENDING",
                        "REVIEW",
                        "COMPLETED",
                        "EXPIRED"
                      ]
                    },
                    "status_label": {
                      "type": "string"
                    },
                    "amount_usdt": {
                      "type": "string",
                      "description": "USDT que deve ser enviado exatamente, até 6 casas.",
                      "example": "25.000000"
                    },
                    "network": {
                      "type": "string",
                      "example": "TRON"
                    },
                    "asset": {
                      "type": "string",
                      "example": "USDT_TRC20"
                    },
                    "spot_bid_brl": {
                      "type": "string",
                      "description": "Preço spot bid salvo na cotação.",
                      "example": "5.78000000"
                    },
                    "effective_price_brl": {
                      "type": "string",
                      "description": "Preço após spread salvo.",
                      "example": "5.72220000"
                    },
                    "spread_bps": {
                      "type": "integer",
                      "example": 100
                    },
                    "spread_fee_brl": {
                      "type": "string",
                      "description": "Spread em reais.",
                      "example": "1.45"
                    },
                    "global_fee_percent": {
                      "type": "string",
                      "description": "Percentual global de swap.",
                      "example": "1.50"
                    },
                    "global_fee_percent_brl": {
                      "type": "string",
                      "description": "Valor da tarifa percentual em reais.",
                      "example": "2.16"
                    },
                    "global_fee_fixed_brl": {
                      "type": "string",
                      "description": "Tarifa fixa global em reais.",
                      "example": "0.99"
                    },
                    "gross_amount_brl": {
                      "type": "string",
                      "description": "Equivalente bruto antes dos descontos.",
                      "example": "144.50"
                    },
                    "total_fee_brl": {
                      "type": "string",
                      "description": "Total de spread e tarifas globais.",
                      "example": "4.60"
                    },
                    "net_payout_brl": {
                      "type": "string",
                      "description": "Líquido estimado para a chave Pix confirmada.",
                      "example": "139.90"
                    },
                    "pix_key": {
                      "type": "string",
                      "description": "Chave Pix mascarada para conferência."
                    },
                    "pix_key_type": {
                      "type": "string"
                    },
                    "quote_expires_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "wallet_challenge": {
                      "type": "string",
                      "description": "Desafio de assinatura; retornado antes da prova da carteira."
                    },
                    "wallet_proof": {
                      "type": "boolean"
                    },
                    "wallet_address": {
                      "type": "string"
                    },
                    "receiving_address": {
                      "type": "string"
                    },
                    "deposit_amount_usdt": {
                      "type": "string"
                    },
                    "qr_svg_base64": {
                      "type": "string",
                      "description": "QR SVG Base64 após a prova da carteira."
                    },
                    "transaction_hash": {
                      "type": "string"
                    },
                    "explorer_url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "chain_status": {
                      "type": "string"
                    },
                    "settled_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "submitted_transaction_hash": {
                      "type": "string",
                      "nullable": true,
                      "description": "Hash informado pelo cliente; só passa a transaction_hash após verificação solidificada."
                    },
                    "submitted_explorer_url": {
                      "type": "string",
                      "nullable": true,
                      "format": "uri",
                      "description": "Explorador do hash informado, sem afirmar que foi validado."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "JWT inválido ou ausente."
          },
          "403": {
            "description": "Conta não aprovada."
          },
          "422": {
            "description": "Dados inválidos, cotação expirada ou regra da operação recusada."
          },
          "429": {
            "description": "Limite de requisições atingido."
          },
          "503": {
            "description": "Binance, tarifa global ou serviço de cotação indisponível."
          }
        }
      }
    },
    "/api/v1/crypto/usdt-tron-sale/orders": {
      "servers": [
        {
          "url": "https://avalonpay.com.br",
          "description": "Portal AvalonPay · API JWT de venda USDT TRON"
        }
      ],
      "get": {
        "tags": [
          "Criptomoedas · Venda USDT TRON"
        ],
        "operationId": "listTronSaleOrders",
        "summary": "Listar ordens de venda",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "description": "Retorna as últimas 50 ordens da conta autenticada.",
        "responses": {
          "200": {
            "description": "Ordens da conta.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "orders": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "order_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "QUOTE_READY",
                              "AWAITING_USDT",
                              "USDT_CONFIRMING",
                              "PIX_PENDING",
                              "PIX_PENDING",
                              "REVIEW",
                              "COMPLETED",
                              "EXPIRED"
                            ]
                          },
                          "status_label": {
                            "type": "string"
                          },
                          "amount_usdt": {
                            "type": "string",
                            "description": "USDT que deve ser enviado exatamente, até 6 casas.",
                            "example": "25.000000"
                          },
                          "network": {
                            "type": "string",
                            "example": "TRON"
                          },
                          "asset": {
                            "type": "string",
                            "example": "USDT_TRC20"
                          },
                          "spot_bid_brl": {
                            "type": "string",
                            "description": "Preço spot bid salvo na cotação.",
                            "example": "5.78000000"
                          },
                          "effective_price_brl": {
                            "type": "string",
                            "description": "Preço após spread salvo.",
                            "example": "5.72220000"
                          },
                          "spread_bps": {
                            "type": "integer",
                            "example": 100
                          },
                          "spread_fee_brl": {
                            "type": "string",
                            "description": "Spread em reais.",
                            "example": "1.45"
                          },
                          "global_fee_percent": {
                            "type": "string",
                            "description": "Percentual global de swap.",
                            "example": "1.50"
                          },
                          "global_fee_percent_brl": {
                            "type": "string",
                            "description": "Valor da tarifa percentual em reais.",
                            "example": "2.16"
                          },
                          "global_fee_fixed_brl": {
                            "type": "string",
                            "description": "Tarifa fixa global em reais.",
                            "example": "0.99"
                          },
                          "gross_amount_brl": {
                            "type": "string",
                            "description": "Equivalente bruto antes dos descontos.",
                            "example": "144.50"
                          },
                          "total_fee_brl": {
                            "type": "string",
                            "description": "Total de spread e tarifas globais.",
                            "example": "4.60"
                          },
                          "net_payout_brl": {
                            "type": "string",
                            "description": "Líquido estimado para a chave Pix confirmada.",
                            "example": "139.90"
                          },
                          "pix_key": {
                            "type": "string",
                            "description": "Chave Pix mascarada para conferência."
                          },
                          "pix_key_type": {
                            "type": "string"
                          },
                          "quote_expires_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "wallet_challenge": {
                            "type": "string",
                            "description": "Desafio de assinatura; retornado antes da prova da carteira."
                          },
                          "wallet_proof": {
                            "type": "boolean"
                          },
                          "wallet_address": {
                            "type": "string"
                          },
                          "receiving_address": {
                            "type": "string"
                          },
                          "deposit_amount_usdt": {
                            "type": "string"
                          },
                          "qr_svg_base64": {
                            "type": "string",
                            "description": "QR SVG Base64 após a prova da carteira."
                          },
                          "transaction_hash": {
                            "type": "string"
                          },
                          "explorer_url": {
                            "type": "string",
                            "format": "uri"
                          },
                          "chain_status": {
                            "type": "string"
                          },
                          "settled_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "JWT inválido ou ausente."
          },
          "403": {
            "description": "Conta não aprovada."
          },
          "422": {
            "description": "Dados inválidos, cotação expirada ou regra da operação recusada."
          },
          "429": {
            "description": "Limite de requisições atingido."
          }
        }
      },
      "post": {
        "tags": [
          "Criptomoedas · Venda USDT TRON"
        ],
        "operationId": "createTronSaleOrder",
        "summary": "Criar ordem e confirmar chave Pix",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9._:-]{8,100}$"
            },
            "description": "Chave estável para repetir a mesma solicitação sem duplicar a operação."
          }
        ],
        "description": "Cria uma ordem vinculada à cotação ainda válida e copia a chave Pix salva para o snapshot da ordem. A resposta inclui um desafio que deve ser assinado pela carteira TRON de origem.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "quote_id",
                  "confirm_pix_key"
                ],
                "properties": {
                  "quote_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "order_id da resposta da cotação."
                  },
                  "confirm_pix_key": {
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  }
                }
              },
              "example": {
                "quote_id": "UUID_DA_COTACAO",
                "confirm_pix_key": true
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Ordem criada, aguardando prova da carteira e transferência.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "order_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "QUOTE_READY",
                        "AWAITING_USDT",
                        "USDT_CONFIRMING",
                        "PIX_PENDING",
                        "PIX_PENDING",
                        "REVIEW",
                        "COMPLETED",
                        "EXPIRED"
                      ]
                    },
                    "status_label": {
                      "type": "string"
                    },
                    "amount_usdt": {
                      "type": "string",
                      "description": "USDT que deve ser enviado exatamente, até 6 casas.",
                      "example": "25.000000"
                    },
                    "network": {
                      "type": "string",
                      "example": "TRON"
                    },
                    "asset": {
                      "type": "string",
                      "example": "USDT_TRC20"
                    },
                    "spot_bid_brl": {
                      "type": "string",
                      "description": "Preço spot bid salvo na cotação.",
                      "example": "5.78000000"
                    },
                    "effective_price_brl": {
                      "type": "string",
                      "description": "Preço após spread salvo.",
                      "example": "5.72220000"
                    },
                    "spread_bps": {
                      "type": "integer",
                      "example": 100
                    },
                    "spread_fee_brl": {
                      "type": "string",
                      "description": "Spread em reais.",
                      "example": "1.45"
                    },
                    "global_fee_percent": {
                      "type": "string",
                      "description": "Percentual global de swap.",
                      "example": "1.50"
                    },
                    "global_fee_percent_brl": {
                      "type": "string",
                      "description": "Valor da tarifa percentual em reais.",
                      "example": "2.16"
                    },
                    "global_fee_fixed_brl": {
                      "type": "string",
                      "description": "Tarifa fixa global em reais.",
                      "example": "0.99"
                    },
                    "gross_amount_brl": {
                      "type": "string",
                      "description": "Equivalente bruto antes dos descontos.",
                      "example": "144.50"
                    },
                    "total_fee_brl": {
                      "type": "string",
                      "description": "Total de spread e tarifas globais.",
                      "example": "4.60"
                    },
                    "net_payout_brl": {
                      "type": "string",
                      "description": "Líquido estimado para a chave Pix confirmada.",
                      "example": "139.90"
                    },
                    "pix_key": {
                      "type": "string",
                      "description": "Chave Pix mascarada para conferência."
                    },
                    "pix_key_type": {
                      "type": "string"
                    },
                    "quote_expires_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "wallet_challenge": {
                      "type": "string",
                      "description": "Desafio de assinatura; retornado antes da prova da carteira."
                    },
                    "wallet_proof": {
                      "type": "boolean"
                    },
                    "wallet_address": {
                      "type": "string"
                    },
                    "receiving_address": {
                      "type": "string"
                    },
                    "deposit_amount_usdt": {
                      "type": "string"
                    },
                    "qr_svg_base64": {
                      "type": "string",
                      "description": "QR SVG Base64 após a prova da carteira."
                    },
                    "transaction_hash": {
                      "type": "string"
                    },
                    "explorer_url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "chain_status": {
                      "type": "string"
                    },
                    "settled_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "submitted_transaction_hash": {
                      "type": "string",
                      "nullable": true,
                      "description": "Hash informado pelo cliente; só passa a transaction_hash após verificação solidificada."
                    },
                    "submitted_explorer_url": {
                      "type": "string",
                      "nullable": true,
                      "format": "uri",
                      "description": "Explorador do hash informado, sem afirmar que foi validado."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "JWT inválido ou ausente."
          },
          "403": {
            "description": "Conta não aprovada."
          },
          "422": {
            "description": "Dados inválidos, cotação expirada ou regra da operação recusada."
          },
          "429": {
            "description": "Limite de requisições atingido."
          }
        }
      }
    },
    "/api/v1/crypto/usdt-tron-sale/orders/{orderId}/wallet-proof": {
      "servers": [
        {
          "url": "https://avalonpay.com.br",
          "description": "Portal AvalonPay · API JWT de venda USDT TRON"
        }
      ],
      "post": {
        "tags": [
          "Criptomoedas · Venda USDT TRON"
        ],
        "operationId": "proveTronSaleWallet",
        "summary": "Provar controle da carteira TRON",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "description": "Valida assinatura TRON message V2 do desafio exato da ordem. Nunca envie chave privada ou frase-semente.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "wallet_address",
                  "challenge",
                  "signature"
                ],
                "properties": {
                  "wallet_address": {
                    "type": "string",
                    "description": "Endereço TRON que enviará o USDT.",
                    "example": "T..."
                  },
                  "challenge": {
                    "type": "string",
                    "description": "Desafio idêntico ao retornado pela ordem.",
                    "example": "AvalonPay · Venda de USDT TRON\nOrdem: ..."
                  },
                  "signature": {
                    "type": "string",
                    "pattern": "^(?:0x)?[a-fA-F0-9]{130}$"
                  }
                }
              },
              "example": {
                "wallet_address": "T...",
                "challenge": "DESAFIO_RETORNADO",
                "signature": "ASSINATURA_TRONLINK"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Prova aceita; resposta inclui endereço de recebimento e QR.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "order_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "QUOTE_READY",
                        "AWAITING_USDT",
                        "USDT_CONFIRMING",
                        "PIX_PENDING",
                        "PIX_PENDING",
                        "REVIEW",
                        "COMPLETED",
                        "EXPIRED"
                      ]
                    },
                    "status_label": {
                      "type": "string"
                    },
                    "amount_usdt": {
                      "type": "string",
                      "description": "USDT que deve ser enviado exatamente, até 6 casas.",
                      "example": "25.000000"
                    },
                    "network": {
                      "type": "string",
                      "example": "TRON"
                    },
                    "asset": {
                      "type": "string",
                      "example": "USDT_TRC20"
                    },
                    "spot_bid_brl": {
                      "type": "string",
                      "description": "Preço spot bid salvo na cotação.",
                      "example": "5.78000000"
                    },
                    "effective_price_brl": {
                      "type": "string",
                      "description": "Preço após spread salvo.",
                      "example": "5.72220000"
                    },
                    "spread_bps": {
                      "type": "integer",
                      "example": 100
                    },
                    "spread_fee_brl": {
                      "type": "string",
                      "description": "Spread em reais.",
                      "example": "1.45"
                    },
                    "global_fee_percent": {
                      "type": "string",
                      "description": "Percentual global de swap.",
                      "example": "1.50"
                    },
                    "global_fee_percent_brl": {
                      "type": "string",
                      "description": "Valor da tarifa percentual em reais.",
                      "example": "2.16"
                    },
                    "global_fee_fixed_brl": {
                      "type": "string",
                      "description": "Tarifa fixa global em reais.",
                      "example": "0.99"
                    },
                    "gross_amount_brl": {
                      "type": "string",
                      "description": "Equivalente bruto antes dos descontos.",
                      "example": "144.50"
                    },
                    "total_fee_brl": {
                      "type": "string",
                      "description": "Total de spread e tarifas globais.",
                      "example": "4.60"
                    },
                    "net_payout_brl": {
                      "type": "string",
                      "description": "Líquido estimado para a chave Pix confirmada.",
                      "example": "139.90"
                    },
                    "pix_key": {
                      "type": "string",
                      "description": "Chave Pix mascarada para conferência."
                    },
                    "pix_key_type": {
                      "type": "string"
                    },
                    "quote_expires_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "wallet_challenge": {
                      "type": "string",
                      "description": "Desafio de assinatura; retornado antes da prova da carteira."
                    },
                    "wallet_proof": {
                      "type": "boolean"
                    },
                    "wallet_address": {
                      "type": "string"
                    },
                    "receiving_address": {
                      "type": "string"
                    },
                    "deposit_amount_usdt": {
                      "type": "string"
                    },
                    "qr_svg_base64": {
                      "type": "string",
                      "description": "QR SVG Base64 após a prova da carteira."
                    },
                    "transaction_hash": {
                      "type": "string"
                    },
                    "explorer_url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "chain_status": {
                      "type": "string"
                    },
                    "settled_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "submitted_transaction_hash": {
                      "type": "string",
                      "nullable": true,
                      "description": "Hash informado pelo cliente; só passa a transaction_hash após verificação solidificada."
                    },
                    "submitted_explorer_url": {
                      "type": "string",
                      "nullable": true,
                      "format": "uri",
                      "description": "Explorador do hash informado, sem afirmar que foi validado."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "JWT inválido ou ausente."
          },
          "403": {
            "description": "Conta não aprovada."
          },
          "422": {
            "description": "Dados inválidos, cotação expirada ou regra da operação recusada."
          },
          "429": {
            "description": "Limite de requisições atingido."
          }
        }
      }
    },
    "/api/v1/crypto/usdt-tron-sale/orders/{orderId}/transactions": {
      "servers": [
        {
          "url": "https://avalonpay.com.br",
          "description": "Portal AvalonPay · API JWT de venda USDT TRON"
        }
      ],
      "post": {
        "tags": [
          "Criptomoedas · Venda USDT TRON"
        ],
        "operationId": "submitTronSaleTransaction",
        "summary": "Enviar hash da transferência USDT",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "description": "Verifica transação e logs na TRON solidificada. Somente transferência exata do contrato oficial USDT TRC-20, da carteira assinada ao endereço da ordem, dentro da validade é aceita. Hash duplicado, transferência parcial/excedente, origem/rede incorreta, envio fora da janela ou falha do recibo vai para revisão. Repetir a mesma requisição é seguro.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "transaction_hash"
                ],
                "properties": {
                  "transaction_hash": {
                    "type": "string",
                    "pattern": "^[a-fA-F0-9]{64}$"
                  }
                }
              },
              "example": {
                "transaction_hash": "HASH_TRON_DE_64_CARACTERES"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Estado verificado ou encaminhado para revisão.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "order_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "QUOTE_READY",
                        "AWAITING_USDT",
                        "USDT_CONFIRMING",
                        "PIX_PENDING",
                        "PIX_PENDING",
                        "REVIEW",
                        "COMPLETED",
                        "EXPIRED"
                      ]
                    },
                    "status_label": {
                      "type": "string"
                    },
                    "amount_usdt": {
                      "type": "string",
                      "description": "USDT que deve ser enviado exatamente, até 6 casas.",
                      "example": "25.000000"
                    },
                    "network": {
                      "type": "string",
                      "example": "TRON"
                    },
                    "asset": {
                      "type": "string",
                      "example": "USDT_TRC20"
                    },
                    "spot_bid_brl": {
                      "type": "string",
                      "description": "Preço spot bid salvo na cotação.",
                      "example": "5.78000000"
                    },
                    "effective_price_brl": {
                      "type": "string",
                      "description": "Preço após spread salvo.",
                      "example": "5.72220000"
                    },
                    "spread_bps": {
                      "type": "integer",
                      "example": 100
                    },
                    "spread_fee_brl": {
                      "type": "string",
                      "description": "Spread em reais.",
                      "example": "1.45"
                    },
                    "global_fee_percent": {
                      "type": "string",
                      "description": "Percentual global de swap.",
                      "example": "1.50"
                    },
                    "global_fee_percent_brl": {
                      "type": "string",
                      "description": "Valor da tarifa percentual em reais.",
                      "example": "2.16"
                    },
                    "global_fee_fixed_brl": {
                      "type": "string",
                      "description": "Tarifa fixa global em reais.",
                      "example": "0.99"
                    },
                    "gross_amount_brl": {
                      "type": "string",
                      "description": "Equivalente bruto antes dos descontos.",
                      "example": "144.50"
                    },
                    "total_fee_brl": {
                      "type": "string",
                      "description": "Total de spread e tarifas globais.",
                      "example": "4.60"
                    },
                    "net_payout_brl": {
                      "type": "string",
                      "description": "Líquido estimado para a chave Pix confirmada.",
                      "example": "139.90"
                    },
                    "pix_key": {
                      "type": "string",
                      "description": "Chave Pix mascarada para conferência."
                    },
                    "pix_key_type": {
                      "type": "string"
                    },
                    "quote_expires_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "wallet_challenge": {
                      "type": "string",
                      "description": "Desafio de assinatura; retornado antes da prova da carteira."
                    },
                    "wallet_proof": {
                      "type": "boolean"
                    },
                    "wallet_address": {
                      "type": "string"
                    },
                    "receiving_address": {
                      "type": "string"
                    },
                    "deposit_amount_usdt": {
                      "type": "string"
                    },
                    "qr_svg_base64": {
                      "type": "string",
                      "description": "QR SVG Base64 após a prova da carteira."
                    },
                    "transaction_hash": {
                      "type": "string"
                    },
                    "explorer_url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "chain_status": {
                      "type": "string"
                    },
                    "settled_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "submitted_transaction_hash": {
                      "type": "string",
                      "nullable": true,
                      "description": "Hash informado pelo cliente; só passa a transaction_hash após verificação solidificada."
                    },
                    "submitted_explorer_url": {
                      "type": "string",
                      "nullable": true,
                      "format": "uri",
                      "description": "Explorador do hash informado, sem afirmar que foi validado."
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "A transação aguarda solidificação; consulte o mesmo pedido.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "order_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "QUOTE_READY",
                        "AWAITING_USDT",
                        "USDT_CONFIRMING",
                        "PIX_PENDING",
                        "PIX_PENDING",
                        "REVIEW",
                        "COMPLETED",
                        "EXPIRED"
                      ]
                    },
                    "status_label": {
                      "type": "string"
                    },
                    "amount_usdt": {
                      "type": "string",
                      "description": "USDT que deve ser enviado exatamente, até 6 casas.",
                      "example": "25.000000"
                    },
                    "network": {
                      "type": "string",
                      "example": "TRON"
                    },
                    "asset": {
                      "type": "string",
                      "example": "USDT_TRC20"
                    },
                    "spot_bid_brl": {
                      "type": "string",
                      "description": "Preço spot bid salvo na cotação.",
                      "example": "5.78000000"
                    },
                    "effective_price_brl": {
                      "type": "string",
                      "description": "Preço após spread salvo.",
                      "example": "5.72220000"
                    },
                    "spread_bps": {
                      "type": "integer",
                      "example": 100
                    },
                    "spread_fee_brl": {
                      "type": "string",
                      "description": "Spread em reais.",
                      "example": "1.45"
                    },
                    "global_fee_percent": {
                      "type": "string",
                      "description": "Percentual global de swap.",
                      "example": "1.50"
                    },
                    "global_fee_percent_brl": {
                      "type": "string",
                      "description": "Valor da tarifa percentual em reais.",
                      "example": "2.16"
                    },
                    "global_fee_fixed_brl": {
                      "type": "string",
                      "description": "Tarifa fixa global em reais.",
                      "example": "0.99"
                    },
                    "gross_amount_brl": {
                      "type": "string",
                      "description": "Equivalente bruto antes dos descontos.",
                      "example": "144.50"
                    },
                    "total_fee_brl": {
                      "type": "string",
                      "description": "Total de spread e tarifas globais.",
                      "example": "4.60"
                    },
                    "net_payout_brl": {
                      "type": "string",
                      "description": "Líquido estimado para a chave Pix confirmada.",
                      "example": "139.90"
                    },
                    "pix_key": {
                      "type": "string",
                      "description": "Chave Pix mascarada para conferência."
                    },
                    "pix_key_type": {
                      "type": "string"
                    },
                    "quote_expires_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "wallet_challenge": {
                      "type": "string",
                      "description": "Desafio de assinatura; retornado antes da prova da carteira."
                    },
                    "wallet_proof": {
                      "type": "boolean"
                    },
                    "wallet_address": {
                      "type": "string"
                    },
                    "receiving_address": {
                      "type": "string"
                    },
                    "deposit_amount_usdt": {
                      "type": "string"
                    },
                    "qr_svg_base64": {
                      "type": "string",
                      "description": "QR SVG Base64 após a prova da carteira."
                    },
                    "transaction_hash": {
                      "type": "string"
                    },
                    "explorer_url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "chain_status": {
                      "type": "string"
                    },
                    "settled_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "submitted_transaction_hash": {
                      "type": "string",
                      "nullable": true,
                      "description": "Hash informado pelo cliente; só passa a transaction_hash após verificação solidificada."
                    },
                    "submitted_explorer_url": {
                      "type": "string",
                      "nullable": true,
                      "format": "uri",
                      "description": "Explorador do hash informado, sem afirmar que foi validado."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "JWT inválido ou ausente."
          },
          "403": {
            "description": "Conta não aprovada."
          },
          "422": {
            "description": "Dados inválidos, cotação expirada ou regra da operação recusada."
          },
          "429": {
            "description": "Limite de requisições atingido."
          },
          "503": {
            "description": "Verificação temporariamente inconclusiva. Consulte a mesma ordem; não crie outra."
          }
        }
      }
    },
    "/api/v1/crypto/usdt-tron-sale/orders/{orderId}": {
      "servers": [
        {
          "url": "https://avalonpay.com.br",
          "description": "Portal AvalonPay · API JWT de venda USDT TRON"
        }
      ],
      "get": {
        "tags": [
          "Criptomoedas · Venda USDT TRON"
        ],
        "operationId": "getTronSaleOrder",
        "summary": "Consultar estado de uma ordem",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "description": "Atualiza a verificação on-chain pendente e retorna apenas a ordem da conta autenticada. O Pix só é considerado pago quando a ordem fica COMPLETED após validação administrativa do E2E.",
        "responses": {
          "200": {
            "description": "Estado e detalhes públicos da ordem.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "order_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "QUOTE_READY",
                        "AWAITING_USDT",
                        "USDT_CONFIRMING",
                        "PIX_PENDING",
                        "PIX_PENDING",
                        "REVIEW",
                        "COMPLETED",
                        "EXPIRED"
                      ]
                    },
                    "status_label": {
                      "type": "string"
                    },
                    "amount_usdt": {
                      "type": "string",
                      "description": "USDT que deve ser enviado exatamente, até 6 casas.",
                      "example": "25.000000"
                    },
                    "network": {
                      "type": "string",
                      "example": "TRON"
                    },
                    "asset": {
                      "type": "string",
                      "example": "USDT_TRC20"
                    },
                    "spot_bid_brl": {
                      "type": "string",
                      "description": "Preço spot bid salvo na cotação.",
                      "example": "5.78000000"
                    },
                    "effective_price_brl": {
                      "type": "string",
                      "description": "Preço após spread salvo.",
                      "example": "5.72220000"
                    },
                    "spread_bps": {
                      "type": "integer",
                      "example": 100
                    },
                    "spread_fee_brl": {
                      "type": "string",
                      "description": "Spread em reais.",
                      "example": "1.45"
                    },
                    "global_fee_percent": {
                      "type": "string",
                      "description": "Percentual global de swap.",
                      "example": "1.50"
                    },
                    "global_fee_percent_brl": {
                      "type": "string",
                      "description": "Valor da tarifa percentual em reais.",
                      "example": "2.16"
                    },
                    "global_fee_fixed_brl": {
                      "type": "string",
                      "description": "Tarifa fixa global em reais.",
                      "example": "0.99"
                    },
                    "gross_amount_brl": {
                      "type": "string",
                      "description": "Equivalente bruto antes dos descontos.",
                      "example": "144.50"
                    },
                    "total_fee_brl": {
                      "type": "string",
                      "description": "Total de spread e tarifas globais.",
                      "example": "4.60"
                    },
                    "net_payout_brl": {
                      "type": "string",
                      "description": "Líquido estimado para a chave Pix confirmada.",
                      "example": "139.90"
                    },
                    "pix_key": {
                      "type": "string",
                      "description": "Chave Pix mascarada para conferência."
                    },
                    "pix_key_type": {
                      "type": "string"
                    },
                    "quote_expires_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "wallet_challenge": {
                      "type": "string",
                      "description": "Desafio de assinatura; retornado antes da prova da carteira."
                    },
                    "wallet_proof": {
                      "type": "boolean"
                    },
                    "wallet_address": {
                      "type": "string"
                    },
                    "receiving_address": {
                      "type": "string"
                    },
                    "deposit_amount_usdt": {
                      "type": "string"
                    },
                    "qr_svg_base64": {
                      "type": "string",
                      "description": "QR SVG Base64 após a prova da carteira."
                    },
                    "transaction_hash": {
                      "type": "string"
                    },
                    "explorer_url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "chain_status": {
                      "type": "string"
                    },
                    "settled_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "submitted_transaction_hash": {
                      "type": "string",
                      "nullable": true,
                      "description": "Hash informado pelo cliente; só passa a transaction_hash após verificação solidificada."
                    },
                    "submitted_explorer_url": {
                      "type": "string",
                      "nullable": true,
                      "format": "uri",
                      "description": "Explorador do hash informado, sem afirmar que foi validado."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "JWT inválido ou ausente."
          },
          "403": {
            "description": "Conta não aprovada."
          },
          "404": {
            "description": "Ordem inexistente ou não pertence à conta."
          },
          "422": {
            "description": "Dados inválidos, cotação expirada ou regra da operação recusada."
          },
          "429": {
            "description": "Limite de requisições atingido."
          }
        }
      }
    },
    "/api/v1/crypto/usdt-tron-sale/webhook": {
      "servers": [
        {
          "url": "https://avalonpay.com.br",
          "description": "Portal AvalonPay · API JWT de venda USDT TRON"
        }
      ],
      "get": {
        "tags": [
          "Criptomoedas · Venda USDT TRON"
        ],
        "operationId": "getTronSaleWebhook",
        "summary": "Consultar configuração de webhook",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "responses": {
          "200": {
            "description": "URL ativa; o segredo não é retornado novamente.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "configured": {
                      "type": "boolean"
                    },
                    "url": {
                      "type": "string",
                      "nullable": true
                    },
                    "active": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "JWT inválido ou ausente."
          },
          "403": {
            "description": "Conta não aprovada."
          },
          "422": {
            "description": "Dados inválidos, cotação expirada ou regra da operação recusada."
          },
          "429": {
            "description": "Limite de requisições atingido."
          }
        }
      },
      "put": {
        "tags": [
          "Criptomoedas · Venda USDT TRON"
        ],
        "operationId": "saveTronSaleWebhook",
        "summary": "Cadastrar webhook de vendas",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "description": "URL HTTPS pública. O segredo HMAC é retornado uma única vez. Entregas retentadas preservam o ID para deduplicação.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "pattern": "^https://",
                    "maxLength": 2048
                  }
                }
              },
              "example": {
                "url": "https://sua-api.example.com/webhooks/avalonpay"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Endpoint ativo e segredo de assinatura exibido uma única vez.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "active": {
                      "type": "boolean"
                    },
                    "signing_secret": {
                      "type": "string"
                    },
                    "secret_notice": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "JWT inválido ou ausente."
          },
          "403": {
            "description": "Conta não aprovada."
          },
          "422": {
            "description": "Dados inválidos, cotação expirada ou regra da operação recusada."
          },
          "429": {
            "description": "Limite de requisições atingido."
          }
        }
      }
    },
    "/api/v1/crypto/bnb/orders": {
      "servers": [
        {
          "url": "https://avalonpay.com.br",
          "description": "Portal AvalonPay · API JWT de compra BNB nativo"
        }
      ],
      "get": {
        "tags": [
          "Criptomoedas · Compra BNB nativo"
        ],
        "operationId": "listManagedBnbPurchaseOrders",
        "summary": "Listar pedidos de compra BNB nativo",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "description": "Retorna os últimos 30 pedidos pertencentes à conta autenticada.",
        "responses": {
          "200": {
            "description": "Pedidos recentes.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "orders": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CryptoBnbPurchaseOrder"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "JWT ausente ou inválido."
          },
          "403": {
            "description": "Conta não aprovada."
          },
          "429": {
            "description": "Limite de consultas atingido."
          }
        }
      }
    },
    "/api/v1/crypto/bnb/quote": {
      "servers": [
        {
          "url": "https://avalonpay.com.br",
          "description": "Portal AvalonPay · API JWT de compra BNB nativo"
        }
      ],
      "post": {
        "tags": [
          "Criptomoedas · Compra BNB nativo"
        ],
        "operationId": "quoteManagedBnbPurchase",
        "summary": "Cotar compra gerenciada de BNB nativo",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "description": "Cota uma compra em BRL de BNB nativo pela Binance Spot BNBBRL best ask, spread AvalonPay e tarifas aplicáveis. A cotação não movimenta saldo; mínimo de R$ 5,00; validade informada em quote_expires_at. Use a Idempotency-Key somente para repetir exatamente o mesmo valor e endereço.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9._:-]{8,100}$"
            },
            "description": "Use uma chave única por intenção e preserve a mesma chave ao repetir o mesmo pedido."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "amount_brl",
                  "destination_address"
                ],
                "properties": {
                  "amount_brl": {
                    "type": "string",
                    "pattern": "^(?:0|[1-9]\\d{0,8})(?:[.,]\\d{1,2})?$",
                    "example": "100.00",
                    "description": "Valor total informado em BRL, string decimal com até duas casas."
                  },
                  "destination_address": {
                    "type": "string",
                    "maxLength": 80,
                    "example": "0xENDERECO_BNB_CHAIN",
                    "description": "Endereço da carteira de destino na BNB Chain. O ativo enviado é BNB nativo.",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Cotação criada; nenhum saldo foi debitado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoBnbPurchaseOrder"
                }
              }
            }
          },
          "401": {
            "description": "JWT ausente ou inválido."
          },
          "403": {
            "description": "Conta não aprovada para a API."
          },
          "422": {
            "description": "Valor, endereço ou chave idempotente inválidos; mínimo de R$ 5,00."
          },
          "429": {
            "description": "Limite de cotações atingido; 10 por minuto."
          },
          "503": {
            "description": "Cotação de mercado ou serviço temporariamente indisponível."
          }
        }
      }
    },
    "/api/v1/crypto/bnb/orders/{orderId}/confirm": {
      "servers": [
        {
          "url": "https://avalonpay.com.br",
          "description": "Portal AvalonPay · API JWT de compra BNB nativo"
        }
      ],
      "post": {
        "tags": [
          "Criptomoedas · Compra BNB nativo"
        ],
        "operationId": "confirmManagedBnbPurchase",
        "summary": "Confirmar compra cotada de BNB nativo",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "description": "Confirma uma cotação válida com o PIN transacional. Debita o total cotado do saldo AvalonPay e inicia a compra de BNB para o endereço informado. Envie uma vez; em timeout consulte o mesmo pedido.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "pin"
                ],
                "properties": {
                  "pin": {
                    "type": "string",
                    "description": "PIN transacional da conta. Envie somente de um backend protegido."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Pedido processado ou estado idempotente existente.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoBnbPurchaseOrder"
                }
              }
            }
          },
          "202": {
            "description": "Pix ou conciliação em andamento.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoBnbPurchaseOrder"
                }
              }
            }
          },
          "401": {
            "description": "JWT ausente ou inválido."
          },
          "403": {
            "description": "Conta ou PIN não autorizado."
          },
          "404": {
            "description": "Pedido inexistente ou pertencente a outra conta."
          },
          "422": {
            "description": "Cotação expirada ou pedido incompatível com a confirmação."
          },
          "429": {
            "description": "Limite de confirmações atingido; 5 por minuto."
          },
          "503": {
            "description": "Resultado não conclusivo; consulte o mesmo pedido antes de repetir."
          }
        }
      }
    },
    "/api/v1/crypto/bnb/orders/{orderId}": {
      "servers": [
        {
          "url": "https://avalonpay.com.br",
          "description": "Portal AvalonPay · API JWT de compra BNB nativo"
        }
      ],
      "get": {
        "tags": [
          "Criptomoedas · Compra BNB nativo"
        ],
        "operationId": "getManagedBnbPurchaseOrder",
        "summary": "Consultar compra BNB nativo",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "description": "Atualiza e retorna o pedido da conta autenticada.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pedido e estado atual.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoBnbPurchaseOrder"
                }
              }
            }
          },
          "401": {
            "description": "JWT ausente ou inválido."
          },
          "403": {
            "description": "Conta não aprovada."
          },
          "404": {
            "description": "Pedido inexistente ou pertencente a outra conta."
          },
          "429": {
            "description": "Limite de consultas atingido."
          }
        }
      }
    },
    "/api/v1/cards": {
      "get": {
        "tags": [
          "Cartões virtuais"
        ],
        "summary": "Listar cartões da conta",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "responses": {
          "200": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "cards": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "brand": {
                            "type": "string"
                          },
                          "last_four": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "balance_brl_minor": {
                            "type": "integer",
                            "nullable": true
                          },
                          "balance_currency": {
                            "type": "string",
                            "example": "BRL"
                          },
                          "balance_as_of": {
                            "type": "string",
                            "format": "date-time",
                            "nullable": true
                          },
                          "recharge_available": {
                            "type": "boolean"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    },
                    "balance_as_of": {
                      "type": "string",
                      "format": "date-time",
                      "nullable": true
                    }
                  }
                },
                "example": {
                  "cards": [
                    {
                      "id": "e3c57625-7e6e-47af-93c2-052770e5fd1d",
                      "brand": "Visa",
                      "last_four": "1434",
                      "status": "ACTIVE",
                      "balance_brl_minor": 5678,
                      "balance_currency": "BRL",
                      "balance_as_of": "2026-11-22T12:00:00Z",
                      "recharge_available": false,
                      "created_at": "2026-11-22T11:00:00Z"
                    }
                  ],
                  "balance_as_of": "2026-11-22T12:00:00Z"
                }
              }
            }
          },
          "401": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "code": "UNAUTHENTICATED",
                  "message": "JWT ausente ou inválido."
                }
              }
            }
          },
          "403": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "code": "ACCOUNT_NOT_APPROVED",
                  "message": "A conta precisa estar aprovada."
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cards/quote": {
      "post": {
        "tags": [
          "Cartões virtuais"
        ],
        "summary": "Cotar emissão ou recarga",
        "description": "Valores em BRL. O mínimo do saldo carregado é R$ 1.000,00 antes das tarifas. Emissão soma R$ 4,99 de emissão, R$ 3,99 de KYC e R$ 2,99 + 5% da carga inicial; recarga posterior soma R$ 2,99 + 5% do valor carregado. A cotação retorna as tarifas efetivas da conta e o total em centavos, sem debitar saldo. Tarifas posteriores: R$ 1,99 por autorização aprovada (mesmo se revertida depois), R$ 1,99 mensais por cartão ativo na data da emissão, FX de 2% apenas para compra em moeda diferente de USD e compra internacional de 0,50% somente quando os países do estabelecimento e de emissão forem confirmados e diferentes. Sem saldo, taxas posteriores ficam pendentes e são retentadas sem saldo negativo. O limite nominal de US$ 1.000.000 por mês é exibido no painel como equivalente em BRL.",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "quote_id",
                  "amount_brl",
                  "holder_name",
                  "operation"
                ],
                "properties": {
                  "quote_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "amount_brl": {
                    "type": "string",
                    "pattern": "^(?:0|[1-9][0-9]{0,6})(?:\\.[0-9]{1,2})?$",
                    "example": "1000.00"
                  },
                  "holder_name": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 120
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "ISSUE",
                      "TOPUP"
                    ]
                  },
                  "card_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Obrigatório para TOPUP."
                  }
                }
              },
              "example": {
                "quote_id": "0e83858e-78b7-4dc6-9c93-ec80035a39ad",
                "operation": "ISSUE",
                "amount_brl": "1000.00",
                "holder_name": "João da Silva"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quote_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "expires_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "quote": {
                      "type": "object",
                      "description": "Cotação em centavos de BRL. Use os valores retornados sem recalcular; taxas personalizadas da conta substituem as tarifas padrão.",
                      "properties": {
                        "currency": { "type": "string", "enum": ["BRL"] },
                        "loaded_usd_minor": { "type": "integer", "description": "Carga convertida para USD em centavos." },
                        "loaded_minor": { "type": "integer", "description": "Valor carregado, em centavos de BRL." },
                        "issuance_fee_minor": { "type": "integer", "description": "Tarifa de emissão, em centavos de BRL; padrão R$ 4,99." },
                        "kyc_fee_minor": { "type": "integer", "description": "Tarifa KYC, em centavos de BRL; padrão R$ 3,99." },
                        "recharge_fee_minor": { "type": "integer", "description": "Tarifa da carga, em centavos de BRL; padrão R$ 2,99 + 5%." },
                        "combined_fee_minor": { "type": "integer", "description": "Soma das tarifas cobradas nesta cotação." },
                        "total_minor": { "type": "integer", "description": "Total a debitar, incluindo a carga e tarifas da cotação." },
                        "fee_items": { "type": "array", "description": "Linhas das tarifas cobradas nesta cotação.", "items": { "type": "object" } },
                        "future_fee_items": { "type": "array", "description": "Tarifas eventuais ou mensais aplicadas após a emissão.", "items": { "type": "object" } },
                        "monthly_spend_limit_usd_minor": { "type": "integer", "description": "Limite nominal mensal em centavos de USD." },
                        "monthly_spend_limit_brl_minor": { "type": "integer", "description": "Equivalente do limite mensal em centavos de BRL, calculado pela cotação vigente." },
                        "indicative": { "type": "boolean" }
                      }
                    },
                    "confirmation_available": {
                      "type": "boolean"
                    },
                    "blocked_reason": {
                      "type": "string",
                      "nullable": true
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "quote_id": "0e83858e-78b7-4dc6-9c93-ec80035a39ad",
                  "expires_at": "2026-11-22T12:05:00Z",
                  "quote": {
                    "currency": "BRL",
                    "loaded_minor": 100000,
                    "issuance_fee_minor": 499,
                    "kyc_fee_minor": 399,
                    "recharge_fee_minor": 5299,
                    "combined_fee_minor": 6197,
                    "total_minor": 106197,
                    "indicative": false
                  },
                  "confirmation_available": true,
                  "blocked_reason": null,
                  "message": "Confira o saldo e o total em reais. Depois de confirmar com seu PIN, acompanhe o pedido nesta página."
                }
              }
            }
          },
          "401": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "code": "UNAUTHENTICATED",
                  "message": "JWT ausente ou inválido."
                }
              }
            }
          },
          "403": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "code": "ACCOUNT_NOT_APPROVED",
                  "message": "A conta precisa estar aprovada."
                }
              }
            }
          },
          "422": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "code": "CARD_AMOUNT_BELOW_MINIMUM",
                  "message": "O saldo inicial ou recarga mínima é R$ 1.000,00."
                }
              }
            }
          },
          "503": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "code": "CARD_OPERATION_UNAVAILABLE",
                  "message": "Cotação indisponível no momento."
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cards/confirm": {
      "post": {
        "tags": [
          "Cartões virtuais"
        ],
        "summary": "Confirmar uma cotação",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "quote_id",
                  "idempotency_key",
                  "pin"
                ],
                "properties": {
                  "quote_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "idempotency_key": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "pin": {
                    "type": "string",
                    "pattern": "^[0-9]{6}$"
                  },
                  "two_factor_code": {
                    "type": "string",
                    "pattern": "^[0-9]{6}$",
                    "description": "Obrigatório quando a conta usa 2FA."
                  }
                }
              },
              "example": {
                "quote_id": "0e83858e-78b7-4dc6-9c93-ec80035a39ad",
                "idempotency_key": "7b8cb4cf-cf92-4a4c-9f3e-58ed82206382",
                "pin": "123456"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string"
                    },
                    "stage": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "total_brl": {
                      "type": "string"
                    },
                    "currency": {
                      "type": "string",
                      "example": "BRL"
                    },
                    "card_id": {
                      "type": "string",
                      "format": "uuid",
                      "nullable": true
                    },
                    "completed": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "id": "6a0b600b-9729-4a62-906a-cf60ef690ff1",
                  "status": "PROCESSING",
                  "stage": "RESERVED",
                  "message": "Pedido recebido. Preparando o cartão.",
                  "total_brl": "1061.97",
                  "currency": "BRL",
                  "card_id": null,
                  "completed": false
                }
              }
            }
          },
          "401": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "code": "UNAUTHENTICATED",
                  "message": "JWT ausente ou inválido."
                }
              }
            }
          },
          "403": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "code": "PIN_REQUIRED",
                  "message": "Confirme seu PIN."
                }
              }
            }
          },
          "409": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "code": "CARD_OPERATION_IN_PROGRESS",
                  "message": "Há outra operação em conferência."
                }
              }
            }
          },
          "422": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "code": "CARD_QUOTE_EXPIRED",
                  "message": "A cotação expirou."
                }
              }
            }
          },
          "503": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "code": "CARD_OPERATION_REQUIRES_REVIEW",
                  "message": "A solicitação está em conferência. Não repita a operação."
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cards/operations/{id}": {
      "get": {
        "tags": [
          "Cartões virtuais"
        ],
        "summary": "Consultar emissão ou recarga",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "PROCESSING",
                        "COMPLETED",
                        "CANCELLED",
                        "REQUIRES_REVIEW"
                      ]
                    },
                    "stage": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "total_brl": {
                      "type": "string"
                    },
                    "currency": {
                      "type": "string",
                      "example": "BRL"
                    },
                    "card_id": {
                      "type": "string",
                      "format": "uuid",
                      "nullable": true
                    },
                    "completed": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "id": "6a0b600b-9729-4a62-906a-cf60ef690ff1",
                  "status": "REQUIRES_REVIEW",
                  "stage": "REQUIRES_REVIEW",
                  "message": "Pedido em conferência. Não repita a compra; o saldo permanece reservado.",
                  "total_brl": "1061.97",
                  "currency": "BRL",
                  "card_id": null,
                  "completed": false
                }
              }
            }
          },
          "401": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "code": "UNAUTHENTICATED",
                  "message": "JWT ausente ou inválido."
                }
              }
            }
          },
          "404": {
            "description": "Resposta JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "code": "CARD_OPERATION_NOT_FOUND",
                  "message": "Operação não encontrada."
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cards/{id}/otp": {
      "post": {
        "tags": [
          "Cartões virtuais"
        ],
        "summary": "Consultar códigos de verificação do cartão",
        "description": "Retorna códigos ativos para o cartão pertencente à conta autenticada. Exige PIN transacional e, quando habilitada, autenticação em duas etapas. Os códigos expiram em até cinco minutos e a resposta não deve ser armazenada.",
        "operationId": "readCardVerificationCodes",
        "security": [
          {
            "avalonUserJwt": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "pin"
                ],
                "properties": {
                  "pin": {
                    "type": "string",
                    "pattern": "^[0-9]{6}$"
                  },
                  "two_factor_code": {
                    "type": "string",
                    "pattern": "^[0-9]{6}$",
                    "description": "Obrigatório quando a autenticação em duas etapas estiver habilitada."
                  }
                }
              },
              "example": {
                "pin": "123456",
                "two_factor_code": "123456"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Códigos ativos ou lista vazia quando não há verificação pendente.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "example": "private, no-store, max-age=0"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "codes",
                    "message"
                  ],
                  "properties": {
                    "codes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "code",
                          "expires_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "code": {
                            "type": "string",
                            "pattern": "^[0-9]{4,8}$"
                          },
                          "expires_at": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "codes": [
                    {
                      "id": "a3b9e41d...",
                      "code": "234562",
                      "expires_at": "2026-11-22T12:05:00+00:00"
                    }
                  ],
                  "message": "Código de verificação disponível."
                }
              }
            }
          },
          "401": {
            "description": "JWT ausente ou inválido."
          },
          "403": {
            "description": "Conta não aprovada, PIN inválido ou autenticação em duas etapas inválida."
          },
          "404": {
            "description": "Cartão não encontrado para a conta autenticada."
          },
          "429": {
            "description": "Limite de consulta atingido; até três solicitações por minuto."
          },
          "503": {
            "description": "Não foi possível atualizar a consulta de código neste momento."
          }
        }
      }
    }
  }
}
