Flow
Step 1: Create the payment
Send the boleto’s digitable line (linha digitável — 47 digits for a bank boleto, 48 for a utility or tax bill) or its barcode (44 digits) inbarcode. Send the digits; the check digits must be right.
The boleto is looked up at the bank and the payment is created as
REQUESTED — nothing is paid yet. Review who you’re paying (payee, payeeDocument) and how much (txnUpdatedAmount) before going on:
_id — it is the {boletoId} of every next step. txnUpdatedAmount is the face value (txnOriginalAmount) with today’s discount, fine and interest applied. pendingConfirmation holds what will be paid, and policy what your organization’s business policies say about it.
type tells the two kinds of boleto apart: GENERIC is a bank boleto, with a due date; UTILITY_BILL is a utility or tax bill (energy, water, phone, taxes).
Reference: Create a boleto payment
Step 2: Set the details, if any are missing
Confirming pays exactly whatpendingConfirmation holds, so it needs the amount and the balance category. The amount is usually known after creating — the one you sent, or else the one the boleto asks for (txnUpdatedAmount, or its face value when that is 0); only a boleto that states no amount at all leaves it out. If the payment has both, skip this step. Otherwise — or to pay another amount, change the day or fill in custom fields — set them:
amount and category are required here, and what you send replaces what was stored. A boleto that accepts a range of amounts takes one between txnMinAmount and txnMaxAmount; the bank checks the amount when the payment is confirmed. The answer carries an updated policy.
Reference: Set a boleto payment’s details
Step 3: Confirm the payment
Whenpolicy.actions.autoAction is APPROVE, confirm the payment — with no body:
200 with the payment PAID: the money left the wallet, and confirmedAmount and confirmedAt record it. If the bank refuses it — for insufficient funds or a limit, for example — the payment becomes FAILED, with the reason in failReason, and you get the error. A FAILED payment can’t be retried: create another one.
When autoAction is NONE, the payment needs approval: send it for approval instead of confirming it. With DENY, the policies refuse it.
Reference: Confirm a boleto payment
Pay on a later day
SendscheduledAt (YYYY-MM-DD) when creating the payment, or with PUT, to pay on a later day. The confirmation then answers 201 with the schedule, and the payment becomes SCHEDULED; on that day a new payment is created from the same barcode and paid.
- A bank boleto (
GENERIC) can only be scheduled for its due date — or, when the due date falls on a weekend or holiday, the next business day. Any other later day is refused with422 SCHEDULED_AT_NOT_ALLOWED, whose message names the allowed day. A bank boleto with no due date can be scheduled for any business day. - A utility or tax bill (
UTILITY_BILL) can be scheduled for any later day. - A day before today is refused with
422 INVALID_SCHEDULED_AT. At creation, today or noscheduledAtpays as soon as the payment is confirmed. WithPUT, leavingscheduledAtout keeps the day already set; send today to pay as soon as it is confirmed again. - On that day the new payment is charged to the general-purpose balance category (
FLEX_INTERNATIONAL), whatevercategoryyou set, and it carries none of the payment’s custom fields — so it fails if your organization has a required transaction custom field. Pay those boletos on the day instead. - A later-day payment’s amount must be one the boleto accepts (between
txnMinAmountandtxnMaxAmount, when it states them); otherwise the confirmation is refused with400 INVALID_AMOUNTand nothing is scheduled.
Cancel a payment
A payment that wasn’t paid yet —REQUESTED, waiting for approval, or SCHEDULED — can be cancelled. Cancelling a scheduled payment cancels its schedule too:
Common errors
Errors come in the error envelope with a stablecode. When the bank refuses a boleto, code carries the bank’s reason — some reasons come in lowercase, with the message Unknown error, so branch on code, not on the message.
Each endpoint’s reference page lists every error it can return.
Follow a payment
Read the payment to see itsstatus, or list a wallet’s boleto payments — filter by status, for example ?status=PAID,FAILED. To be notified, subscribe to the BANK_SLIP_PAID webhook, sent when a boleto is paid from a wallet.
Next steps
Business policies and approvals
Send payments for approval when your organization’s policies require it.
Send a Pix payment
Pay by Pix key, QR code or bank details.