Guides
Open Finance

Pix through Open Finance

Configure the application, initiate an immediate, scheduled or recurring Pix and send the payer to the consent at their bank.

In the Open Finance API Efí is the payment initiator: your application requests the Pix, the payer authorizes it at their bank and the money leaves their account. Every payment starts pendente and only moves after the consent.

Efí (homologation)Mimicr
https://openfinance-h.api.efipay.com.brhttps://openfinance.efi.mimicr.dev

At Efí the calls use the application certificate (mTLS); in Mimicr you only swap the host. The credentials are the Efí sandbox's (see Authentication).

1. Get a token

bash
curl --request POST \
  --url https://openfinance.efi.mimicr.dev/v1/oauth/token \
  --header 'Authorization: Basic <base64(client_id:client_secret)>' \
  --header 'Content-Type: application/json' \
  --data '{ "grant_type": "client_credentials" }'
json
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "gn.opb.participants.read gn.opb.payment.pix.send gn.opb.payment.pix.read ..."
}

The token lasts 1 hour and only works on this host: a token from the Pix API or another /v1 API answers 401 invalid_token. Reference: Get a token (Open Finance).

2. Configure the return and the webhook

bash
curl --request PUT \
  --url https://openfinance.efi.mimicr.dev/v1/config \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "redirectURL": "https://sua-app.dev/open-finance/retorno",
    "webhookURL": "https://sua-app.dev/open-finance",
    "webhookSecurity": { "type": "hmac", "hash": "minha-hash-secreta" },
    "processPayment": "async"
  }'

The response is 201 with the full configuration. Without it, the payer doesn't come back to your application and no webhook is sent (deliveries are recorded as skipped). Reference: Configure the application.

3. Pick the payer's bank

bash
curl --url 'https://openfinance.efi.mimicr.dev/v1/participantes?modalidade=pagamentos' \
  --header 'Authorization: Bearer <token>'

Mimicr lists three fictitious banks. Use the identificador in pagador.idParticipante, for example 9f4cd202-8f2b-11ec-b909-0242ac120002 (Banco Simulado Mimicr). Reference: List participants.

4. Initiate the Pix

Payment POSTs require x-idempotency-key (36 to 72 characters). Repeating the same key with the same body returns the first response; with another body, 409 conflito_chave_idempotencia.

bash
curl --request POST \
  --url https://openfinance.efi.mimicr.dev/v1/pagamentos/pix \
  --header 'Authorization: Bearer <token>' \
  --header 'x-idempotency-key: 6f1c1d2e-9a3b-4c5d-8e7f-0a1b2c3d4e5f' \
  --header 'Content-Type: application/json' \
  --data '{
    "pagador": { "idParticipante": "9f4cd202-8f2b-11ec-b909-0242ac120002", "cpf": "94271564656" },
    "favorecido": {
      "contaBanco": { "nome": "Lucas Silva", "documento": "17558266300", "codigoBanco": "09089356", "agencia": "0001", "conta": "654984", "tipoConta": "TRAN" }
    },
    "pagamento": { "valor": "9.99", "infoPagador": "Churrasco", "idProprio": "6236574863254" }
  }'
json
{
  "identificadorPagamento": "urn:efi:31ad3884-2914-4b63-a9f5-560f3ce13cce",
  "redirectURI": "https://openfinance.efi.mimicr.dev/consentimento/urn:efi:31ad3884-2914-4b63-a9f5-560f3ce13cce"
}

The payee can be contaBanco, chave (a Pix key) or nothing, when paying a QR Code in pagamento.qrCode. If the payee is the sandbox's own account (ISPB 09089356 and the account from GET /v1/efi, or one of its Pix keys), the amount goes into the balance and shows up in statements. Reference: Initiate a Pix.

5. The payer authorizes

Redirect the payer to redirectURI. At Efí it is their bank's screen; in Mimicr it is a page on the same host with Autorizar (authorize) and Recusar (refuse) buttons. In an automated test, play the other side with an action:

bash
curl --request POST \
  --url https://api.mimicr.dev/v1/efi/actions/openfinance.consent \
  --header 'Authorization: Bearer mk_...' \
  --header 'Content-Type: application/json' \
  --data '{ "kind": "pagamento", "id": "urn:efi:31ad3884-2914-4b63-a9f5-560f3ce13cce", "approve": true }'

Or npx mimicr action efi openfinance.consent kind=pagamento id=urn:efi:… approve=true.

After the page, the payer returns to your redirectURL with this query string:

text
https://sua-app.dev/open-finance/retorno?identificadorPagamento=urn:efi:31ad3884-...
https://sua-app.dev/open-finance/retorno?identificadorPagamento=urn:efi:31ad3884-...&erro=acesso_negado

6. The result

SituationStatusmotivo
Authorized, amount other than 0.11aceito
Authorized, amount 0.11 (Efí homologation rule)rejeitadoPagamento recusado no destino
Refused by the payerrejeitadoCancelado pelo usuário na instituição bancária
No answer for 1 hour (Mimicr rule)expirado

Each change triggers a tipo: pagamento webhook (see Webhooks and errors). To check, list the day's payments:

bash
curl --url 'https://openfinance.efi.mimicr.dev/v1/pagamentos/pix?inicio=2026-10-21&fim=2026-10-21' \
  --header 'Authorization: Bearer <token>'
json
{
  "pagamentos": [
    { "identificadorPagamento": "urn:efi:31ad3884-2914-4b63-a9f5-560f3ce13cce", "endToEndId": "E09089356202610220135Tw8gFokZtlG", "valor": "9.99", "status": "aceito", "dataCriacao": "2026-10-22T01:35:05.666Z", "devolucoes": [], "idProprio": "6236574863254" }
  ],
  "total": 1,
  "porPagina": 50,
  "ultimo": "/pagamentos/pix?inicio=2026-10-21&fim=2026-10-21&quantidade=50&pagina=1",
  "proximo": null,
  "anterior": null,
  "atual": "/pagamentos/pix?inicio=2026-10-21&fim=2026-10-21&quantidade=50&pagina=1"
}

When no payment matches, the response is 404 pagamento_nao_encontrado, not an empty list. Reference: List initiated Pix.

7. Refund

bash
curl --request POST \
  --url https://openfinance.efi.mimicr.dev/v1/pagamentos/pix/urn:efi:31ad3884-2914-4b63-a9f5-560f3ce13cce/devolver \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{ "valor": "1.00" }'

The response is 202 with status: pendente. Within a few seconds the refund becomes aceito and the tipo: devolucao webhook arrives. Only aceito payments can be refunded, up to the amount paid (saldo_devolucao_insuficiente). Reference: Refund a Pix.

Scheduled Pix

Same body, plus pagamento.dataAgendamento (D+1 to D+365), in Schedule a Pix. Once authorized, the payment becomes agendado and settles on the date, with the webhook. 0.11 is rejected on the date with the reason Saldo insuficiente. Before the date, cancel it with Cancel a scheduled Pix.

To avoid waiting for the date:

  • Advance the sandbox clock (npx mimicr clock efi +1d); everything that comes due runs right away.
  • Or settle now: npx mimicr action efi openfinance.payment id=urn:efi:… action=processar.

Recurring Pix

One consent covers every installment. Send pagamento.recorrencia in Create a recurring Pix:

tipoFields
diariadataInicio, quantidade
semanaldataInicio, diaDaSemana (SEGUNDA_FEIRA … DOMINGO), quantidade
mensaldataInicio, diaDoMes, quantidade
personalizadadatas (2 to 60), descricao

dataInicio ranges from D+1 to D+365 and quantidade from 2 to 60. Once authorized, the recurrence becomes ativa and each installment gets an endToEndId and becomes agendado. Each installment settles on its date (0.11 is rejected), and the recurrence ends concluida. Refused, it becomes cancelada; unanswered for 1 hour, expirada.

  • Cancel a recurring Pix with the urn cancels everything; with an installment's endToEndId, only that one.
  • Replace an installment recreates a cancelado or rejeitado installment. The new installment stays pendente until the payer consents again on the response's redirectURI; once authorized, it is agendado. Refused, or unanswered for 1 hour, it becomes cancelado.
  • Refund installments takes a devolucoes list of {endToEndId, valor}.
  • The openfinance.payment action with action=processar settles the next scheduled installment now.