How it works
- Create the customer with
POST /v2/customers, including a CPF or CNPJ. - Create the subscription with
payment_method: "pix_automatic". No card token is involved. - Show
authorization.qr_codeto the payer. - The payer authorizes the recurring debit in their bank app.
- The payer’s bank debits each cycle. Listen to subscription webhooks to follow authorizations, payments, failures, and cancellation.
Prerequisites
- Subscriptions must be enabled for your account (
403otherwise), and so must Pix Automático (422otherwise). See Errors. - The customer must exist in
/v2/customerswith a CPF or CNPJ indocument. Address and phone are optional. currencymust beBRL.
Create a subscription without a trial
Withouttrial_end, the same QR code authorizes the recurring debit and pays the first cycle.
201:
incomplete until the payer authorizes and the first debit is paid. At that point it becomes active and you receive subscription.started with previous_status: "incomplete". This flow does not send subscription.created.
Create a subscription with a trial
Sendtrial_end (ISO 8601, in the future) and the QR code only authorizes the recurring debit. Nothing is charged until the trial ends.
Trials depend on your account configuration. When they are not available, the request returns 422 with PIX_AUTOMATIC_TRIAL_NOT_SUPPORTED and nothing is created.
Where trials are available, also send billing_day_of_month. The first debit is scheduled for the first occurrence of that day on or after the signup date, and that date must fall on or after trial_end and at least 3 full days (72 hours) after the moment of signup. Without billing_day_of_month, the billing day is the signup day, so the first debit would fall before the trial ends and the request is rejected. When the dates do not fit, the request returns 422 with PIX_AUTHORIZATION_FAILED and a detail that explains why.
In this example the subscription is created on September 23, with trial_end on October 7 and billing_day_of_month: 10, so the first debit is scheduled for October 10:
201:
trialing and you receive subscription.created (with latest_transaction: null). Three days before trial_end you receive subscription.trial_will_end, if the subscription is already trialing by then. The first debit after the trial makes it active and sends subscription.started.
Request fields
Billing intervals
Any other combination, or one your account does not support, returns
422 with PIX_AUTHORIZATION_FAILED and a detail that says the interval is not supported.
Show the QR code
Theauthorization block is what the payer needs:
GET /v2/subscriptions/{id} returns authorization only while the authorization is pending. After the payer approves or rejects it, the block disappears.
If the payer never authorizes, what happens depends on your account configuration: the subscription either stays incomplete, or is canceled when the code expires and you receive subscription.canceled. To stop waiting, cancel it yourself (see Cancel).
recurringAuthorization.status tells you where the authorization stands: pending, approved, rejected, cancel_pending, or canceled. On GET by id, recurringAuthorization.lastDebit shows the most recent debit attempt.
What to store
- subscription
id - customer
id - current
status authorization.qr_code, while the authorization is pendingrecurringAuthorization.statuslatest_transaction.idfrom the webhooks, when present
Status and webhooks
Things to know when you handle these events:
- Pix Automático charges are reported only through
subscription.*events. You do not receivetransaction.*webhooks for them. latest_transaction.methodis"pix". The payload does not say which payment method the subscription uses, so identify Pix Automático subscriptions by theidyou stored, or readpaymentMethodwithGET /v2/subscriptions/{id}.failure_reasonis informative. Do not build logic on specific values.
Failed debits
The payer’s bank may try a debit more than once. Those intermediate attempts do not generate events. When no attempts are left, you receivesubscription.payment_failed with attempt_number and failure_reason.
- If it was the first debit of a subscription without a trial, the subscription stays
incomplete. - Otherwise (the first debit after a trial, or a later cycle), with
failure_policy: retry_then_cancelthe subscription becomespast_dueand you receivesubscription.past_due. For a later cycle, a debit paid afterwards makes itactiveagain and sendssubscription.renewed. - A failed debit does not create a new transaction. On
subscription.payment_failedandsubscription.past_due,latest_transactionis the most recent transaction of the subscription, which is usually the previous paid cycle. retry_offsets_daysis accepted but has no effect: retry timing follows the Pix Automático rules and cannot be configured.- Anything else
failure_policydoes for Pix Automático depends on your account configuration.subscription.canceledis the only confirmation that a subscription ended.
Cancel
POST /v2/subscriptions/{id}/cancel works while the subscription is incomplete, trialing, active, or past_due. For Pix Automático the cancellation is immediate: it is never scheduled for the end of the period, the status never becomes cancel_scheduled, and the webhook is subscription.canceled, not subscription.updated.
The response comes in one of two forms, depending on your account configuration:
- Already canceled:
statusiscanceledandrecurringAuthorization.statusiscanceled. - Waiting for confirmation:
statuskeeps its current value andrecurringAuthorization.statusiscancel_pending. The subscription becomescanceledonce the cancellation is confirmed, and you receivesubscription.canceledthen.
subscription.canceled as the source of truth.
Repeating the call on a subscription that is canceled, or whose cancellation is waiting for confirmation, returns 200 with no change. Two concurrent calls on the same subscription may return 409 with SUBSCRIPTION_CANCEL_IN_PROGRESS; retry after a short wait.
Limitations
- Plan changes are not available.
PATCH /v2/subscriptions/{id}withproduct_idreturns422and the plan stays the same:PLAN_CHANGE_UNAVAILABLE_FOR_PAYMENT_METHODwhen the subscription is tied to a catalog plan, orSUBSCRIPTION_HAS_NO_CATALOG_PLAN/PRODUCT_NOT_FOUNDwhen it is not. To move the payer to another plan, cancel the subscription and create a new one, which needs a new authorization. - Billing intervals are limited to the table in Request fields.
- Trials depend on your account configuration.
- Retry spacing cannot be configured:
retry_offsets_daysis ignored. - The debit date is not guaranteed. Follow the webhooks instead of expecting a charge on a fixed day.
Errors
When Pix Automático is not enabled or not configured, contact support to enable it for your account.
Sandbox
In the sandbox (https://api.sandbox.pagou.ai) there is no payer’s bank on the other side: nobody scans the QR code and nothing is debited on its own. You play the payer’s bank with POST /v2/subscriptions/{id}/simulate. The subscription moves exactly as it would in production and you receive the same webhooks.
Create the customer and the subscription as described above, with your sandbox token. Then send one event per call:
200 with the updated subscription, in the same shape as GET /v2/subscriptions/{id}.
After
fail, with failure_policy: retry_then_cancel the subscription becomes past_due and you receive subscription.past_due; for a later cycle, a pay makes it active again with subscription.renewed. With immediate_cancel it becomes canceled and you receive subscription.canceled. With a trial, a fail before the first debit is paid leaves the subscription past_due and no pay recovers it: cancel it and create a new one to keep testing.
What to know about the sandbox:
- One call is one event. Each
paypays one cycle right away, whatever the billing interval. - The subscription moves only when you call the endpoint. Do not rely on time-based events such as
subscription.trial_will_endin the sandbox. - An event that does not fit the current authorization or status returns
409withSUBSCRIPTION_SIMULATION_NOT_APPLICABLEand changes nothing: for example,paybeforeauthorize, orauthorizetwice. authorization.qr_codehas the Pix format, but it does not set up a real recurring authorization: do not scan it with a bank app, useauthorizeinstead.expires_atisnulland the authorization never expires on its own: userejectto test a refused authorization.- The sandbox accepts
trial_endwithout checking it againstbilling_day_of_month, and the first debit happens when you sendpay. In production, trials depend on your account configuration and the dates must fit (see Create a subscription with a trial). - Billing intervals are
week×1andmonth×1,6, or12.month×3is refused, and so is an amount below100. - A cancellation responds already
canceled. - Do not use
PUT /v2/transactions/{id}on a Pix Automático charge: it changes the transaction but not the subscription. - The Pix values in Test Data (documents and the
7300amount) do not apply to Pix Automático. - The route exists only in the sandbox. In production it returns
404.

