Skip to main content

Withdrawals

Withdrawals require the withdraw scope, which in turn requires an IP allowlist on the key.

1. Fee preview​

curl "https://api-sandbox.rivusfinance.com/v1/withdrawals/fee-preview?kind=brl_pix&amount=1500" \
-H "Authorization: Bearer $RIVUS_API_KEY"

Returns the fee, total debited, minimum, maximum and available balance, using the same rule as the POST.

2. Request​

curl -X POST https://api-sandbox.rivusfinance.com/v1/withdrawals \
-H "Authorization: Bearer $RIVUS_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"kind": "brl_pix",
"gross_amount": 1500,
"pix_key": "12345678000199",
"pix_key_type": "cnpj",
"pix_recipient_name": "Empresa Exemplo Ltda",
"expected_fee_amount": 2.5
}'
kindRequired fields
brl_pixpix_key, pix_key_type (cpf, cnpj, email, telefone, aleatoria) and pix_recipient_name
usdt_trc20wallet_address (TRC-20 wallet)

The request starts in processando. To guarantee the fee you showed your user, send expected_fee_amount: if the rule has changed, the API responds 409 instead of charging a different fee.

Pix (brl_pix)​

The Rivus team completes or cancels the request, triggering the withdrawal.completed or withdrawal.canceled webhooks. The balance is debited on completion.

USDT (usdt_trc20)​

Sending may be automatic. In that case the request goes through:

  • enviando (webhook withdrawal.sent): the balance has already been debited and the transfer is on its way. tx_hash may already be filled in, but it is not final yet.
  • concluido (webhook withdrawal.completed): transfer confirmed on-chain.
  • falhou (webhook withdrawal.failed): nothing was sent and the amount is in your balance (refunded, or never debited when the withdrawal wallet could not cover the request in time). The Rivus team resends the same request (it goes back to processando) or cancels it (withdrawal.canceled).

:::warning One USDT withdrawal at a time With automatic sending, while there is a USDT withdrawal in processando or enviando, a new USDT POST /v1/withdrawals responds 409. The fee preview warns with usdt_in_progress: true. Pix is not affected by this rule. :::

Statuses and event order​

Possible statuses: processando, enviando, concluido, falhou, cancelado. New statuses may be added: treat an unknown value as "in progress", not as an error.

  • withdrawal.sent is not final: only withdrawal.completed, withdrawal.failed or withdrawal.canceled end an attempt.
  • withdrawal.failed is not final either: if the Rivus team resends, the same request goes back to processando and you get withdrawal.sent again. The request is only over in concluido or cancelado.
  • Always use the resource's current status (GET /v1/withdrawals/{id}) as the source of truth, not the order in which webhooks arrive.