The steps below use a Pix payment. Boleto payments follow the same policies and the same create → set details → send for approval or confirm flow, through their own endpoints and with their own error codes — see Boleto payments.Transfer requests between wallets are checked against the same policies and go through the same send for approval or confirm steps, with their own endpoints and error codes. The main differences: their amount and balance category are fixed when they are created — to change them, cancel the request and create a new one — and only organization admins can cancel them.
What a policy decides
The organization’s policies are evaluated in theirorder, and the first one whose conditions match the payment decides. Conditions read the payment as it stands: its amount, the balance category it is charged to, the recipient, the paying wallet, who created it, its custom fields, and how many days are left to its due date.
The decision is the policy’s actions.autoAction:
A policy can also top up the wallet before paying (
actions.moveBalance): the payment’s amount is first moved into the paying wallet from another one, then paid. That happens on its own when a payment the policy approves is confirmed, and when an approval request is approved — you don’t do anything extra. An organization admin who confirms a payment the policy would send for approval, or refuse, gets no top-up. A payment for a later day (scheduledAt) that you confirm directly is not topped up — make sure the wallet has the money on that day; one that goes through an approval is topped up when it is approved.
Admins manage the policies in the Portão 3 app or through the Rule Engine API’s business policies endpoints.
The flow
Every step answers with the payment, so you always know itsstatus.
Step 1: Create the payment
Create the Pix payment with the recipient — a Pix key, a Pix Copia e Cola / QR code, or bank details. Nothing is paid yet: the payment starts asREQUESTED.
policy — what the policies say about it as it stands:
_id as {pixId} in the next steps.
Step 2: Set the details and read the verdict
pendingConfirmation holds what will be paid — the amount, the balance category charged and a description. Sending for approval and confirming take no details of their own: they use these.
When you sent amount and category at creation (as above), they are already set and policy already reflects them — go to step 3. Otherwise — typically a QR code, whose amount you only know after reading it, or a create without category — set the details:
policy. Read policy.actions.autoAction from the latest answer to choose step 3a, 3b or nothing (DENY). You can call PUT as many times as you need while the payment is REQUESTED.
Step 3a: Confirm the payment
When the verdict isAPPROVE, confirm the payment. Send no body:
CONFIRMED — it becomes PAID when the Pix network settles it. If the payment is for a later day (scheduledAt), the answer is 201 with the schedule instead, and the payment becomes SCHEDULED.
If a policy now requires approval, the confirmation is refused with 403 PIX_REQUIRES_APPROVAL — send the payment for approval instead. If a policy refuses it, you get 403 PIX_POLICY_DENIED.
Step 3b: Send the payment for approval
When the verdict isNONE, send the payment for approval. Send no body:
PENDING_APPROVAL, and an approval request is opened for the approvers the policy names. The answer brings it in policyRequest:
- The details are frozen. The approvers approve exactly the amount, category and description the payment had when it was sent. To change them, cancel the payment — its approval request is cancelled too — and create a new one.
- The approvers decide. They are notified in the Portão 3 app and approve or deny there, or through the Rule Engine API — approve or deny the approval request whose
idis the payment’spolicyRequestId. WithapprovalHierarchy: truethey decide one after the other, in order. Organization admins can decide any request on their own: force-approve or force-deny. - Approved → paid. Once every approval is given, Portão 3 confirms the payment for you, with the approved details — no call from you. It becomes
CONFIRMED, thenPAID(orSCHEDULED, for a later day). If the payment is refused at that point — for example, for insufficient funds — it becomesFAILED, with the reason infailReason. - Approved, but not carried out. If the policy’s top-up of the wallet can’t be done after the approval, the payment is not sent. A few problems found before any money moves are retried automatically (the approval request’s
executionStatusgoes back toWAITING). Any other failure — a timeout or an error from the bank during the top-up included — ends the approval request withexecutionStatus: FAILEDand the reason inexecutionFailReason, and the payment staysPENDING_APPROVALuntil its deadline, then shows asEXPIRED. The top-up may have gone through: check the wallets’ balances before you cancel the payment and create a new one, and contact support if the money moved. - Denied → cancelled. The payment becomes
CANCELLED. - Deadline passed → expired. The deadline is
approvalExpiresAt: 21:00 (São Paulo time) of the day the payment is for, and at least one hour after it was sent. A payment still waiting then becomesEXPIRED.
403 PIX_PENDING_APPROVAL): the approval request is the record of the decision.
To follow the outcome, read the payment until its status leaves PENDING_APPROVAL, read the approval request to see who decided what, or subscribe to the PIX_OUT webhook, sent when the payment goes out.
Organization admins
An organization admin can confirm a payment whatever the policies decide: their confirmation skips the approval and still returns the verdict inpolicy, for the record. API clients act as admins of their organizations, so this applies to them too. The only exception is a payment already waiting for approval, which only its approval request can resolve — an admin settles it with force-approve or force-deny.
When the policies can’t be evaluated
If the policies can’t be evaluated at that moment:- creating the payment and setting its details still succeed, with
policyset to{ "error": "POLICY_EVALUATION_UNAVAILABLE" }; - sending for approval and confirming answer
503 POLICY_EVALUATION_UNAVAILABLEand change nothing — retry shortly. An organization admin’s confirmation goes ahead, withpolicy: null.
Errors of the flow
Boleto payments
A boleto payment goes through the same steps, on its own endpoints. Use the payment’s_id as {boletoId}:
What differs for a boleto:
- The amount is usually known after creating — the
amountyou sent, or else what the boleto asks for today (txnUpdatedAmount, or its face value when that is0). Sendcategoryat creation too and you can go straight to step 3; otherwise — or when the boleto states no amount at all — set them withPUT, which also lets you change the amount, the day or the custom fields. - A confirmed boleto is
PAIDright away — there is noCONFIRMEDstep. Once an approval request is approved, the payment becomesPAID(orSCHEDULED, for a later day), orFAILEDif the bank refuses it. - What a policy sees:
subjectTypeisBOLETO— so a policy can govern boleto payments only — the beneficiary (payee,payeeDocument) is the recipient (creditParty), who the boleto was issued to isdebitParty, anddaysToDueDatecounts the days to the boleto’s due date. - The day to pay: the approval deadline is 21:00 (São Paulo time) of the day the payment is for — today, unless you set
scheduledAt. A bank boleto can only be scheduled for its due date (or the next business day, when it falls on a weekend or holiday; any business day when it has no due date). - Notifications: subscribe to the
BANK_SLIP_PAIDwebhook, sent when the boleto is paid.
Next steps
Send a Pix payment
Pay by Pix key, QR code or bank details, step by step.
Pay a boleto
Pay a bank boleto or a utility bill from its barcode.
Receive webhooks
Get notified when a payment goes out.