Guides
Journeys

Automatic Pix (recurrences)

Create the recurrence with an immediate payment, let the player authorize it, schedule charges and handle cancellations.

In Automatic Pix the player authorizes, at their bank, recurring charges from the operator. A recurrence starts with an immediate payment: the player pays the QR Code and, in the same step, authorizes the next charges. Notifications go to the automaticDepositUrl.

1. Create the recurrence

bash
curl --request POST \
  --url https://okto.mimicr.dev/automatic/recurrences \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "taxId": "604.184.437-34",
    "name": "Ana Ribeiro",
    "amount": 2990,
    "frequency": "MONTHLY",
    "dateFirstRecurrence": "2026-10-26",
    "totalRecurrences": 12,
    "immediateTransaction": { "amount": 2990, "expirationInSeconds": 3600 },
    "contract": { "id": "assinatura0001", "description": "Assinatura do clube" },
    "descriptionToPayer": "Assinatura mensal do clube",
    "externalId": "5c3d8382-ab14-4d30-b42b-bc806ecc69a7",
    "tags": ["clube"]
  }'

The response is 201:

json
{
  "id": "e7c925a5-c9a7-4144-b84f-a3d99cc13d97",
  "externalId": "5c3d8382-ab14-4d30-b42b-bc806ecc69a7",
  "bankingId": "RR30980539202610211dbfcf5ab19",
  "status": "PENDING",
  "subStatus": "AWAITING_FIRST_PAYMENT",
  "frequency": "MONTHLY",
  "totalRecurrences": 12,
  "dateFirstRecurrence": "2026-10-26",
  "dateLastRecurrence": "2027-09-26",
  "expirationDate": "2026-10-21T20:09:06.914000+00:00",
  "brcode": "00020101021226880014br.gov.bcb.pix2566qrcode.okto.mimicr.dev/v2/rec/e7c925a5-...",
  "immediatePixTransaction": { "amount": 2990, "id": "…", "status": "pending" }
}
FieldRuleError
taxId, nameValid CPF and a name2001, 2009
frequencyWEEKLY, MONTHLY, QUARTERLY, BIANNUAL or ANNUAL4443
dateFirstRecurrenceyyyy-MM-dd, at least 2 days after today2004, 4505
totalRecurrencesPositive integer4443
descriptionToPayerRequired4442
immediateTransaction.amountRequired, in cents4506
immediateTransaction.expirationInSecondsDefault 36004443
contract.idUp to 35 alphanumeric characters4443
externalIdUUID (generated if omitted)2010

See Create a recurrence.

2. The player pays and authorizes

The player scans the brcode at their bank. In the sandbox, play that role in one of these ways:

  • The test endpoint Mock pay and authorize, with the exact brcode in pixChargeTextContent (anything else answers 4446) and the payerTaxId.
  • The test endpoint Mock QR payment: pays without authorizing (subStatus: "FIRST_PAYMENT_SUCCESS", the recurrence stays PENDING).
  • The control API: npx mimicr action okto player.step step=automatic:authorize id=<recurrence-id> (also automatic:pay, automatic:reject and automatic:cancel).
bash
curl --request POST \
  --url https://okto.mimicr.dev/automatic/recurrences/e7c925a5-c9a7-4144-b84f-a3d99cc13d97/mock-pay-and-authorize \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "pixChargeTextContent": "<brcode>",
    "payerTaxId": "60418443734"
  }'

The response is 200 with no body. Two notifications arrive: AutomaticPixDepositPayment (the immediate payment, paid) and AutomaticRecurrenceAuthorization (the recurrence, AUTHORIZED).

bash
npx mimicr wait okto delivery transaction_id=e7c925a5-c9a7-4144-b84f-a3d99cc13d97 event=AUTHORIZED

Recurrence statuses

statussubStatusWhen
PENDINGAWAITING_FIRST_PAYMENTCreated, QR not paid yet
PENDINGFIRST_PAYMENT_SUCCESSQR paid, authorization pending
AUTHORIZEDVALIDATION_SUCCEEDEDPaid and authorized
REJECTEDVALIDATION_REJECTED_PAYERThe player refused; immediate payment failed with 4114
FAILEDFAILEDThe payer was rejected by the test CPFs or by chaos
EXPIREDEXPIREDexpirationDate passed unpaid; immediate payment failed with 4108
CANCELLEDCANCELLEDThe player cancelled at the bank
CANCELLEDCANCELLATION_VALIDATION_SUCCESSThe operator cancelled

Check it with Get a recurrence or Get recurrence status.

3. Scheduled charges

Once the recurrence is AUTHORIZED, charges are scheduled on the bank side. In the sandbox, use the test endpoint Mock a scheduled charge:

bash
curl --request POST \
  --url https://okto.mimicr.dev/automatic/recurrences/e7c925a5-c9a7-4144-b84f-a3d99cc13d97/mock-scheduling \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "payer": { "taxId": "60418443734", "ispb": "30980539", "accountNumber": "123456789", "name": "Ana Ribeiro" },
    "dueDate": "2026-10-21"
  }'
  • payer.taxId, payer.ispb and payer.accountNumber are required (4442).
  • dueDate defaults to today; a charge due today or earlier settles right away, a future one settles on its day (move the clock with npx mimicr clock okto +5d).
  • amount defaults to the recurrence amount.
  • "isRejected": true creates the charge already refused (4454).
  • At most totalRecurrences scheduled charges (4520).

Each charge is a transaction with its own id, notified as AutomaticPixDepositPayment. List them with List recurrence transactions and check one with Get transaction status.

Cancellations

WhoHowOutcome
Operator, the recurrenceCancel a recurrence with reason RECEIVER_OR_PARTICIPANT_REQUEST_ERROR or RECEIVER_PARTICIPANT_CONFIRMED_ELSEWHERE204; pending charges failed with 4501
Operator, one chargeCancel a scheduled transaction with reason MERCHANT_REQUESTED or OTHER_REASONS204; only scheduled charges not settled yet (4140 otherwise)
Player, the recurrenceMock cancellation by the payer or step=automatic:cancelCANCELLED / CANCELLED
Player, the schedulingMock scheduling cancellationThe pending charge becomes failed with 4501

Only PENDING or AUTHORIZED recurrences can be cancelled; otherwise the answer is 400 with 1000. An unknown recurrence answers 4502.

Notifications

json
{
  "AutomaticRecurrenceAuthorization": {
    "id": "e7c925a5-c9a7-4144-b84f-a3d99cc13d97",
    "bankingId": "RR30980539202610211dbfcf5ab19",
    "externalId": "5c3d8382-ab14-4d30-b42b-bc806ecc69a7",
    "status": "AUTHORIZED",
    "detailedStatus": "VALIDATION_SUCCEEDED",
    "immediatePixTransaction": { "amount": 2990, "id": "…" },
    "recurrence": { "id": "e7c925a5-c9a7-4144-b84f-a3d99cc13d97", "status": "AUTHORIZED", "statusDetailed": "VALIDATION_SUCCEEDED" }
  }
}

AutomaticPixDepositPayment carries id, amount, status (paid or failed), errorList, recurrence and, when paid, transactionInfo. See Notifications.

The mock-* endpoints exist in Okto's demo environment and are never hit by chaos in Mimicr. Settling on the due date and the cap of scheduled charges at totalRecurrences are Mimicr's own choices.