Pre-release: the public API is not live yet and has no base URL. Routes and fields are in the OpenAPI contract, at /openapi.yaml.

Skip to Content
xaseDocumentation

Refunds

Sending the amount of a paid charge back to the payer: what it takes, how it ends, and how to retry safely.

A refund sends the amount of a paid charge back to the payer, by PIX. You ask for the refund, what it takes leaves your balance at once, and the bank returns the amount to the payer shortly after.

Operations

Operation in the contractWhat it does
createRefundAsks for the refund of a charge. Requires Idempotency-Key and the refunds:write scope
getRefundReturns one refund by its id
listRefundsReturns the refunds of the environment, newest first, paginated by cursor

The route, the fields and the limits of each operation are in the OpenAPI contract, under these names.

What a refund takes

  • A key with the refunds:write scope. A key without it gets 403 with the insufficient_scope code. See What a key can do. Reading and listing refunds ask for another scope, refunds:read.
  • A paid charge. A charge that was never paid answers 409 with the charge_not_paid code, and one that is disputed, 409 with the charge_disputed code: see Disputes.
  • One refund per charge. A charge that was refunded, or has a refund in progress, answers 409 with the charge_already_refunded code.
  • At most 90 days since the payment. That is the window in which PIX accepts a return. After it the answer is 409 with the refund_window_closed code.
  • Balance to cover it. What the refund takes comes out of the balance of the environment: see The amount. Without enough balance the answer is 409 with the insufficient_balance code, and nothing is refunded.

A refusal moves nothing: no refund is created and the balance stays as it was.

The amount

  • A refund is always for the full amount of the charge. There is no partial refund, and the payer gets the full amount back.
  • By default the fee of the charge is returned with the refund. The refund takes from your balance only what the charge left there, and the platform gives back the fee. A charge covers its own refund.
  • The rule is a setting of your account. An account can be set to leave the fee with the platform. Then the full amount comes out of your balance, and the balance left by a charge does not cover its own refund: the difference is the fee.
  • A refund follows the rule in force when it was asked for. Changing the setting does not change a refund that is pending.

States

The state is the status field.

StateMeaning
pendingWhat the refund takes left your balance, and the bank has not confirmed the return yet
succeededThe amount reached the payer, and the charge is refunded. Final
failedThe bank did not make the return. What the refund took is back in your balance. Final
  • A refund is created pending. The answer of createRefund never says how it ended: follow the webhooks, or read the refund.
  • After a failed refund the charge is still paid, and it can be refunded again, with a new Idempotency-Key.
  • Handle an unknown state without failing. In the contract status is an open string, not an enum, for this reason.

Events

EventWhendata.id
refund.createdThe refund was asked for, and what it takes left your balanceThe refund
refund.succeededThe amount reached the payerThe refund
refund.failedThe bank did not make the return, and what the refund took is back in your balanceThe refund
charge.refundedThe charge became refunded, together with refund.succeededThe charge

To know which charge a refund event is about, read the refund with getRefund: charge_id says it.

Idempotency

Asking for a refund requires the Idempotency-Key header: a value that you choose, unique for each refund you intend to ask for. A UUID is fine.

You repeat the request withResult
The same Idempotency-Key and the same chargeThe refund that already exists is returned, as it is now. No new refund is asked for
The same Idempotency-Key and another charge422 with the idempotency_key_reused code
A different Idempotency-Key and the same charge409 with the charge_already_refunded code, unless the earlier refund failed
  • The key is unique per environment, among refunds. It does not collide with the key of a charge.
  • The key never expires.
  • Simultaneous requests for the same charge ask for a single refund. The ones with the same key receive it, and the others get charge_already_refunded.
  • If a request fails with a network error or a timeout, repeat it with the same key. It is safe: the money never goes back twice.

Identifiers

The id of a refund has the same format as the one of a charge, with the prefix rfd. For example, rfd_01h455vb4pex5vsknk084sn02q. See Identifiers.

Refunds of another environment

Asking for a refund that does not belong to the environment of your key returns 404 with the refund_not_found code, exactly as if it did not exist. Asking to refund a charge of another environment returns 404 with the charge_not_found code.

On this page