{
  "info": {
    "name": "AvalonPay Cripto v1",
    "description": "API cripto AvalonPay em produção. A pasta Compra gerenciada USDT TRON usa JWT da conta e cotação Binance Spot + spread AvalonPay. As demais pastas usam OAuth cripto e cobrem carteiras, depósitos, envios de saldo existente, swaps e webhooks. Guardar tokens somente em variáveis locais do Postman; nunca compartilhar segredos. Há também Venda USDT TRON · Pix (JWT de conta), com cotação best bid, prova de carteira, validação solidificada TRC-20 e conciliação Pix; as requisições ficam em uma pasta separada. Atualizada em 21 nov 2026.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{access_token}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://api.avalonpay.com.br",
      "type": "string"
    },
    {
      "key": "wallet_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "operation_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "deposit_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "idempotency_key",
      "value": "",
      "type": "string"
    },
    {
      "type": "string",
      "key": "endpoint_id",
      "value": ""
    },
    {
      "key": "client_id",
      "value": "",
      "type": "string",
      "description": "Preencha no ambiente local Postman."
    },
    {
      "key": "client_secret",
      "value": "",
      "type": "string",
      "description": "Segredo em variável local do tipo Secret; não compartilhe o environment."
    },
    {
      "key": "access_token",
      "value": "",
      "type": "string",
      "description": "Token OAuth local; nunca inclua valor real nesta coleção."
    },
    {
      "key": "quote_ref",
      "value": "",
      "type": "string",
      "description": "Referência de cotação recebida pela API."
    },
    {
      "key": "delivery_id",
      "value": "",
      "type": "string",
      "description": "UUID da entrega que deseja reconciliar ou reenviar."
    },
    {
      "key": "destination_address",
      "value": "",
      "type": "string",
      "description": "Endereço compatível com a rede da cotação."
    },
    {
      "key": "avalon_app_url",
      "value": "https://avalonpay.com.br",
      "type": "string",
      "description": "API de compra gerenciada USDT TRON."
    },
    {
      "key": "user_jwt",
      "value": "",
      "type": "string",
      "description": "JWT de conta aprovado; armazenar localmente como variável Secret."
    },
    {
      "key": "supplier_order_id",
      "value": "",
      "type": "string",
      "description": "UUID retornado pela cotação."
    },
    {
      "key": "supplier_idempotency_key",
      "value": "",
      "type": "string",
      "description": "Chave de 8 a 100 caracteres; preserve-a em retries da mesma cotação."
    },
    {
      "key": "transaction_pin",
      "value": "",
      "type": "string",
      "description": "PIN transacional para confirmação; armazenar localmente como variável Secret."
    },
    {
      "key": "sale_pix_key_type",
      "value": "EMAIL",
      "type": "string",
      "description": ""
    },
    {
      "key": "sale_pix_key",
      "value": "qa@example.com",
      "type": "string",
      "description": ""
    },
    {
      "key": "sale_amount_usdt",
      "value": "5.00",
      "type": "string",
      "description": ""
    },
    {
      "key": "sale_quote_idempotency_key",
      "value": "sale-quote-qa-001",
      "type": "string",
      "description": ""
    },
    {
      "key": "sale_order_idempotency_key",
      "value": "sale-order-qa-001",
      "type": "string",
      "description": ""
    },
    {
      "key": "sale_quote_id",
      "value": "",
      "type": "string",
      "description": ""
    },
    {
      "key": "sale_order_id",
      "value": "",
      "type": "string",
      "description": ""
    },
    {
      "key": "sale_wallet_challenge",
      "value": "",
      "type": "string",
      "description": ""
    },
    {
      "key": "sale_wallet_address",
      "value": "",
      "type": "string",
      "description": ""
    },
    {
      "key": "sale_wallet_signature",
      "value": "",
      "type": "string",
      "description": ""
    },
    {
      "key": "sale_transaction_hash",
      "value": "",
      "type": "string",
      "description": "Hash real de transação solidificada. A coleção não cria transferência de teste."
    },
    {
      "key": "sale_webhook_url",
      "value": "https://sua-api.example.com/webhooks/avalonpay",
      "type": "string",
      "description": ""
    }
  ],
  "item": [
    {
      "name": "Autenticação",
      "item": [
        {
          "name": "Emitir token OAuth",
          "request": {
            "method": "POST",
            "auth": {
              "type": "basic",
              "basic": [
                {
                  "key": "username",
                  "value": "{{client_id}}",
                  "type": "string"
                },
                {
                  "key": "password",
                  "value": "{{client_secret}}",
                  "type": "string"
                }
              ]
            },
            "header": [
              {
                "key": "Content-Type",
                "value": "application/x-www-form-urlencoded"
              }
            ],
            "body": {
              "mode": "urlencoded",
              "urlencoded": [
                {
                  "key": "grant_type",
                  "value": "client_credentials",
                  "type": "text"
                },
                {
                  "key": "scope",
                  "value": "crypto.read crypto.swaps",
                  "type": "text"
                }
              ]
            },
            "url": "{{base_url}}/api/crypto/v1/oauth/token",
            "description": "Use uma credencial cripto ativa. Não cole segredos em documentação, repositórios ou telas compartilhadas."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 200) {",
                  "  const body = pm.response.json();",
                  "  if (body.access_token) pm.environment.set('access_token', body.access_token);",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "Consultas",
      "item": [
        {
          "name": "Listar redes",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/crypto/v1/networks"
          }
        },
        {
          "name": "Listar ativos e capacidades",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/crypto/v1/assets"
          }
        },
        {
          "name": "Listar carteiras",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/crypto/v1/wallets",
            "description": "A conta precisa estar aprovada e a recuperação segura da raiz de carteiras verificada."
          }
        },
        {
          "name": "Consultar carteira",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/crypto/v1/wallets/{{wallet_id}}"
          }
        },
        {
          "name": "Consultar saldos",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/crypto/v1/balances"
          }
        },
        {
          "name": "Listar operações",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/api/crypto/v1/transactions?limit=50",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "crypto",
                "v1",
                "transactions"
              ],
              "query": [
                {
                  "key": "limit",
                  "value": "50"
                }
              ]
            }
          }
        },
        {
          "name": "Consultar operação",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/crypto/v1/transactions/{{operation_id}}"
          }
        },
        {
          "name": "Listar depósitos",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/crypto/v1/deposits?limit=50"
          }
        },
        {
          "name": "Consultar depósito",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/crypto/v1/deposits/{{deposit_id}}"
          }
        },
        {
          "name": "Criar carteira adicional",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{idempotency_key}}"
              }
            ],
            "url": "{{base_url}}/api/crypto/v1/wallets",
            "body": {
              "mode": "raw",
              "raw": "{\"network\":\"BSC\"}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "Escopo crypto.wallets.create. Use uma chave por carteira e repita a mesma chave em caso de timeout."
          }
        },
        {
          "name": "Listar carteiras adicionais",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/crypto/v1/wallets/additional?limit=100"
          }
        }
      ]
    },
    {
      "name": "Cotações",
      "item": [
        {
          "name": "Consultar cotação de swap",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{idempotency_key}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"network\": \"BSC\",\n  \"asset_in\": \"BNB\",\n  \"asset_out\": \"USDT\",\n  \"amount\": \"1\",\n  \"slippage_bps\": 50\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": "{{base_url}}/api/crypto/v1/swaps/quote",
            "description": "Cotação dry-run para BSC, TRON ou cross-chain via 1Click; não cria ordem nem move fundos. Same-chain executável: BNB para tokens BEP-20 na BSC e TRX para USDT TRC20 na TRON. Cross-chain aceita BNB ou token BEP-20 na BSC, e TRX ou USDT TRC20 na TRON como origem quando houver rota. Confirme somente quando execution_enabled=true; execution_ready=false em cross-chain significa que a ordem ainda será criada no POST /swaps. Cotações expiram em 45 segundos."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.environment.set('idempotency_key', pm.variables.replaceIn('{{$guid}}'));"
                ]
              }
            }
          ]
        },
        {
          "name": "Cotar envio",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{idempotency_key}}"
              }
            ],
            "url": "{{base_url}}/api/crypto/v1/withdrawals/quote",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"network\": \"BSC\",\n  \"asset\": \"USDT\",\n  \"amount\": \"1\",\n  \"destination_address\": \"{{destination_address}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "Calcula tarifas, limites e custo máximo de rede; não transmite. A cotação expira em 60 segundos."
          }
        },
        {
          "name": "Cotar envio USDT TRC20 · TRON",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{idempotency_key}}",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"network\": \"TRON\",\n  \"asset\": \"USDT\",\n  \"amount\": \"10.00\",\n  \"destination_address\": \"{{destination_address}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{avalon_app_url}}/api/crypto/v1/withdrawals/quote",
              "host": [
                "{{avalon_app_url}}"
              ],
              "path": [
                "api",
                "crypto",
                "v1",
                "withdrawals",
                "quote"
              ]
            },
            "description": "OAuth scope crypto.withdrawals. Envia USDT já disponível na carteira, não compra cripto. A cotação não transmite e expira em 60 segundos."
          }
        }
      ]
    },
    {
      "name": "Webhooks (scope crypto.webhooks)",
      "item": [
        {
          "name": "Listar callbacks",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/crypto/v1/webhook-endpoints",
            "description": "Emita o token OAuth com scope=crypto.read crypto.webhooks para usar esta pasta."
          }
        },
        {
          "name": "Listar entregas",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/crypto/v1/webhook-deliveries?limit=50"
          }
        },
        {
          "request": {
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Eventos cripto produção\",\n  \"url\": \"https://merchant.example.com/webhooks/avalonpay/crypto\",\n  \"events\": [\"crypto.deposit.confirmed\"]\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "method": "POST",
            "header": [
              {
                "value": "application/json",
                "key": "Content-Type"
              },
              {
                "value": "{{idempotency_key}}",
                "key": "Idempotency-Key"
              }
            ],
            "url": "{{base_url}}/api/crypto/v1/webhook-endpoints",
            "description": "Repetições usam a mesma Idempotency-Key e payload. Guarde o signing_secret retornado; ele aparece uma única vez."
          },
          "name": "Cadastrar callback",
          "event": [
            {
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.environment.set('idempotency_key', pm.variables.replaceIn('{{$guid}}'));"
                ]
              },
              "listen": "prerequest"
            }
          ]
        },
        {
          "request": {
            "description": "Cada rotação nova usa uma chave nova. Após timeout, repita a mesma chave para recuperar o segredo da rotação.",
            "method": "POST",
            "header": [
              {
                "value": "{{idempotency_key}}",
                "key": "Idempotency-Key"
              }
            ],
            "url": "{{base_url}}/api/crypto/v1/webhook-endpoints/{{endpoint_id}}/rotate-secret"
          },
          "name": "Rotacionar signing secret",
          "event": [
            {
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.environment.set('idempotency_key', pm.variables.replaceIn('{{$guid}}'));"
                ]
              },
              "listen": "prerequest"
            }
          ]
        },
        {
          "name": "Consultar callback",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/api/crypto/v1/webhook-endpoints/{{endpoint_id}}",
            "description": "Consulta detalhes do callback da credencial autenticada; o signing secret nunca é retornado."
          }
        },
        {
          "name": "Editar callback",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/api/crypto/v1/webhook-endpoints/{{endpoint_id}}",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Eventos cripto\",\n  \"url\": \"https://merchant.example.com/webhooks/avalonpay/crypto\",\n  \"events\": [\n    \"crypto.deposit.confirmed\"\n  ],\n  \"active\": true\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "Altera a configuração e cria nova versão. Entregas pendentes mantêm o snapshot anterior. Substitua os exemplos antes de enviar."
          }
        },
        {
          "name": "Desativar callback",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/api/crypto/v1/webhook-endpoints/{{endpoint_id}}",
            "description": "Desativa o endpoint da credencial autenticada; não apaga o histórico de entregas."
          }
        },
        {
          "name": "Enfileirar webhook.test",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/api/crypto/v1/webhook-endpoints/{{endpoint_id}}/test",
            "description": "Enfileira um evento de teste sem operação financeira. A entrega é assíncrona."
          }
        },
        {
          "name": "Reenviar entrega",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/api/crypto/v1/webhook-deliveries/{{delivery_id}}/retry",
            "description": "Agenda nova tentativa do evento financeiro existente. Só execute após conferir que o destino está correto; o mesmo event_id e conteúdo serão reenviados."
          }
        }
      ]
    },
    {
      "name": "Envios (produção)",
      "item": [
        {
          "name": "Solicitar envio em produção",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{idempotency_key}}"
              }
            ],
            "url": "{{base_url}}/api/crypto/v1/withdrawals",
            "description": "Confirma o quote_ref. Requer escopo crypto.withdrawals e Idempotency-Key única por operação. Pode movimentar fundos reais. Se houver timeout/BROADCAST_STATUS_UNKNOWN, consulte o operation_id e repita apenas com a mesma chave.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"quote_ref\": \"{{quote_ref}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "Consultar envio",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/api/crypto/v1/withdrawals/{{operation_id}}",
            "description": "Consulta somente o envio pertencente à credencial autenticada."
          }
        }
      ]
    },
    {
      "name": "Swaps (produção; rota condicional)",
      "item": [
        {
          "name": "Solicitar swap em produção",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{idempotency_key}}"
              }
            ],
            "url": "{{base_url}}/api/crypto/v1/swaps",
            "description": "Confirma somente uma cotação vigente com execution_enabled=true. Para cross-chain, a API tenta criar uma ordem no 1Click; somente depois das validações, reserva e autorização o envio pode ser transmitido. A disponibilidade do provedor pode mudar e uma recusa antes do broadcast não transfere fundos. Requer escopo crypto.swaps e Idempotency-Key única. Pode movimentar fundos reais.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"quote_ref\": \"{{quote_ref}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "Consultar swap",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/api/crypto/v1/swaps/{{operation_id}}",
            "description": "Consulta somente o swap pertencente à credencial autenticada."
          }
        }
      ]
    },
    {
      "name": "Compra gerenciada USDT TRON (JWT da conta)",
      "description": "Compra em BRL para endereço TRON informado pelo cliente. Cotação usa Binance Spot USDTBRL best ask + spread AvalonPay. Confirmação movimenta saldo real e inicia Pix. Configure user_jwt, destination_address, supplier_idempotency_key e supplier_order_id. Em retries da mesma cotação, preserve a chave e o payload.",
      "auth": {
        "type": "bearer",
        "bearer": [
          {
            "key": "token",
            "value": "{{user_jwt}}",
            "type": "string"
          }
        ]
      },
      "item": [
        {
          "name": "Listar últimos pedidos",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{avalon_app_url}}/api/v1/crypto/usdt-tron/orders",
              "host": [
                "{{avalon_app_url}}"
              ],
              "path": [
                "api",
                "v1",
                "crypto",
                "usdt-tron",
                "orders"
              ]
            },
            "description": "Lista os últimos 30 pedidos da conta autenticada."
          }
        },
        {
          "name": "Cotar compra USDT TRON",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{supplier_idempotency_key}}",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"amount_brl\": \"100.00\",\n  \"destination_address\": \"{{destination_address}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{avalon_app_url}}/api/v1/crypto/usdt-tron/quote",
              "host": [
                "{{avalon_app_url}}"
              ],
              "path": [
                "api",
                "v1",
                "crypto",
                "usdt-tron",
                "quote"
              ]
            },
            "description": "Mínimo R$ 5,00. A cotação não debita saldo. A resposta contém total, taxas, spread, preço Spot e USDT líquido; use os valores retornados."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 201) { const body = pm.response.json(); if (body.order_id) pm.collectionVariables.set('supplier_order_id', body.order_id); }"
                ]
              }
            }
          ]
        },
        {
          "name": "Confirmar compra cotada",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"pin\": \"{{transaction_pin}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{avalon_app_url}}/api/v1/crypto/usdt-tron/orders/{{supplier_order_id}}/confirm",
              "host": [
                "{{avalon_app_url}}"
              ],
              "path": [
                "api",
                "v1",
                "crypto",
                "usdt-tron",
                "orders",
                "{{supplier_order_id}}",
                "confirm"
              ]
            },
            "description": "Movimenta saldo real e inicia o Pix. Envie o PIN somente de backend protegido. Se houver timeout, consulte este pedido; não crie outro."
          }
        },
        {
          "name": "Consultar pedido",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{avalon_app_url}}/api/v1/crypto/usdt-tron/orders/{{supplier_order_id}}",
              "host": [
                "{{avalon_app_url}}"
              ],
              "path": [
                "api",
                "v1",
                "crypto",
                "usdt-tron",
                "orders",
                "{{supplier_order_id}}"
              ]
            },
            "description": "Consulte o estado da compra antes de qualquer retry."
          }
        }
      ]
    },
    {
      "name": "Venda USDT TRON · Pix (JWT da conta)",
      "description": "Fluxo separado da compra: salve e confirme uma chave Pix, cote USDT, crie a ordem, assine desafio na carteira TRON, envie o hash real e acompanhe a conciliação. As requisições não simulam nem criam transações on-chain.",
      "auth": {
        "type": "bearer",
        "bearer": [
          {
            "key": "token",
            "value": "{{user_jwt}}",
            "type": "string"
          }
        ]
      },
      "item": [
        {
          "name": "Consultar chave Pix salva",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{avalon_app_url}}/api/v1/crypto/usdt-tron-sale/pix-key",
              "host": [
                "{{avalon_app_url}}"
              ],
              "path": [
                "api",
                "v1",
                "crypto",
                "usdt-tron-sale",
                "pix-key"
              ]
            },
            "description": "Mostra somente o tipo e a chave mascarada."
          }
        },
        {
          "name": "Salvar chave Pix de teste",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Accept",
                "value": "application/json",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{avalon_app_url}}/api/v1/crypto/usdt-tron-sale/pix-key",
              "host": [
                "{{avalon_app_url}}"
              ],
              "path": [
                "api",
                "v1",
                "crypto",
                "usdt-tron-sale",
                "pix-key"
              ]
            },
            "description": "Exemplo QA com e-mail reservado; use uma chave controlada pela conta em ambiente habilitado.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"key_type\": \"{{sale_pix_key_type}}\",\n  \"pix_key\": \"{{sale_pix_key}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "Cotar venda USDT TRON",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{sale_quote_idempotency_key}}",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{avalon_app_url}}/api/v1/crypto/usdt-tron-sale/quotes",
              "host": [
                "{{avalon_app_url}}"
              ],
              "path": [
                "api",
                "v1",
                "crypto",
                "usdt-tron-sale",
                "quotes"
              ]
            },
            "description": "Usa best bid Binance, spread e tarifa swap globais. Repita com o mesmo header apenas para os mesmos dados.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"amount_usdt\": \"{{sale_amount_usdt}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Cotação criada ou repetida\", function () { pm.expect([200, 201]).to.include(pm.response.code); });",
                  "if (pm.response.code === 201 || pm.response.code === 200) {",
                  "  const data = pm.response.json();",
                  "  if (data.order_id) pm.collectionVariables.set(\"sale_quote_id\", data.order_id);",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "Criar ordem e confirmar Pix",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{sale_order_idempotency_key}}",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{avalon_app_url}}/api/v1/crypto/usdt-tron-sale/orders",
              "host": [
                "{{avalon_app_url}}"
              ],
              "path": [
                "api",
                "v1",
                "crypto",
                "usdt-tron-sale",
                "orders"
              ]
            },
            "description": "Passa o ID da cotação como quote_id e confirma a chave Pix salva.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"quote_id\": \"{{sale_quote_id}}\",\n  \"confirm_pix_key\": true\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Ordem criada ou repetida\", function () { pm.expect([200, 201]).to.include(pm.response.code); });",
                  "if (pm.response.code === 201 || pm.response.code === 200) {",
                  "  const data = pm.response.json();",
                  "  if (data.order_id) pm.collectionVariables.set(\"sale_order_id\", data.order_id);",
                  "  if (data.wallet_challenge) pm.collectionVariables.set(\"sale_wallet_challenge\", data.wallet_challenge);",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "Provar carteira TRON",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{avalon_app_url}}/api/v1/crypto/usdt-tron-sale/orders/{{sale_order_id}}/wallet-proof",
              "host": [
                "{{avalon_app_url}}"
              ],
              "path": [
                "api",
                "v1",
                "crypto",
                "usdt-tron-sale",
                "orders",
                "{{sale_order_id}}",
                "wallet-proof"
              ]
            },
            "description": "A assinatura deve vir de TronLink para o desafio retornado. Nunca cole chave privada ou frase-semente.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"wallet_address\": \"{{sale_wallet_address}}\",\n  \"challenge\": \"{{sale_wallet_challenge}}\",\n  \"signature\": \"{{sale_wallet_signature}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "Enviar hash real da transferência",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{avalon_app_url}}/api/v1/crypto/usdt-tron-sale/orders/{{sale_order_id}}/transactions",
              "host": [
                "{{avalon_app_url}}"
              ],
              "path": [
                "api",
                "v1",
                "crypto",
                "usdt-tron-sale",
                "orders",
                "{{sale_order_id}}",
                "transactions"
              ]
            },
            "description": "Use apenas após transferir USDT real exato para o endereço apresentado. Este exemplo não cria uma transferência.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"transaction_hash\": \"{{sale_transaction_hash}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "Consultar ordens",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{avalon_app_url}}/api/v1/crypto/usdt-tron-sale/orders",
              "host": [
                "{{avalon_app_url}}"
              ],
              "path": [
                "api",
                "v1",
                "crypto",
                "usdt-tron-sale",
                "orders"
              ]
            },
            "description": "Lista as últimas 50 ordens da conta."
          }
        },
        {
          "name": "Consultar ordem",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{avalon_app_url}}/api/v1/crypto/usdt-tron-sale/orders/{{sale_order_id}}",
              "host": [
                "{{avalon_app_url}}"
              ],
              "path": [
                "api",
                "v1",
                "crypto",
                "usdt-tron-sale",
                "orders",
                "{{sale_order_id}}"
              ]
            },
            "description": "Consulte a mesma ordem em caso de timeout; não crie outra para a mesma transferência."
          }
        },
        {
          "name": "Consultar webhook",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{avalon_app_url}}/api/v1/crypto/usdt-tron-sale/webhook",
              "host": [
                "{{avalon_app_url}}"
              ],
              "path": [
                "api",
                "v1",
                "crypto",
                "usdt-tron-sale",
                "webhook"
              ]
            },
            "description": "Retorna URL e estado; o segredo não é exibido após cadastro."
          }
        },
        {
          "name": "Cadastrar webhook",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Accept",
                "value": "application/json",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{avalon_app_url}}/api/v1/crypto/usdt-tron-sale/webhook",
              "host": [
                "{{avalon_app_url}}"
              ],
              "path": [
                "api",
                "v1",
                "crypto",
                "usdt-tron-sale",
                "webhook"
              ]
            },
            "description": "O segredo de assinatura será mostrado uma vez. Guarde em variável local secreta.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"url\": \"{{sale_webhook_url}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        }
      ]
    }
  ]
}
