Guides
Bill payment

Bill payment

Look up a barcode, pay boletos, utility bills and taxes with the account balance and follow the payment to LIQUIDADO.

The Bill payment API (Pagamento de contas) pays boletos, utility bills (water, power, phone) and taxes with the Efí account balance. Amounts are integers in cents.

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

1. Get a token

bash
curl --request POST \
  --url https://pagarcontas.efi.mimicr.dev/v1/oauth/token \
  --header 'Authorization: Basic <base64(client_id:client_secret)>' \
  --header 'Content-Type: application/json' \
  --data '{ "grant_type": "client_credentials" }'

The token lasts 1 hour, with the scopes gn.barcode.read, gn.barcode.pay.write, gn.barcode.pay.read, payment.webhook.write and payment.webhook.read. It only works on this host. Reference: Get a token (Bill payment).

2. Register the webhook

bash
curl --request PUT \
  --url https://pagarcontas.efi.mimicr.dev/v1/webhook \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{ "url": "https://sua-app.dev/contas" }'

The response is 201 with {"url": ...}. There is one URL per account. Without it, payments work but no status change is sent. Reference: Set the webhook.

3. Get a barcode

Any FEBRABAN code with valid check digits works: a bank boleto (47-digit digitable line) or a utility/tax code (48 digits). To generate one, use the pagarcontas.barcode action:

bash
npx mimicr action efi pagarcontas.barcode tipo=boleto valor=159.90
npx mimicr action efi pagarcontas.barcode tipo=convenio valor=47.00 segmento=3
json
{ "ok": true, "action": "pagarcontas.barcode", "message": "Boleto: 2379…", "data": { "codBarras": "2379…", "linhaDigitavel": "23790…" } }

A boleto issued by the same sandbox's Billing API also works (see Boleto and Bolix): when the payment settles, that charge becomes paid and its notification goes out.

4. Look it up before paying

bash
curl --url https://pagarcontas.efi.mimicr.dev/v1/codBarras/36496161100000159900000001000002732348665880 \
  --header 'Authorization: Bearer <token>'
json
{
  "tipo": "boleto",
  "banco": { "codigo": 364, "nome": "EFI S.A." },
  "codBarras": "36496161100000159900000001000002732348665880",
  "linhaDigitavel": "36490000010100000273123486658802616110000015990",
  "datas": { "vencimento": "2026-10-26 23:59:59", "limitePagamento": "2026-12-24 23:59:59" },
  "beneficiario": { "nome": "Exemplos Efi", "fantasia": "Exemplos Efi", "documento": "94885877000150" },
  "pagador": { "nome": "Gorbadoc Oldbuck", "documento": "94271564656" },
  "valores": { "original": 15990, "abatimento": 0, "multa": 0, "juros": 0, "desconto": 0, "final": 15990 },
  "informacoesPagamento": { "divergente": { "deveAceitar": false, "valorMinimo": 0, "valorMaximo": 0 }, "parcial": { "deveAceitar": false, "limiteDePagamentos": 0 }, "podeSerPago": true }
}

Always pay valores.final. Mimicr rules for other banks' boletos: overdue boletos of R$ 10,00 or more get a 2% fine and 0.033% interest per day, and the payment limit is the due date plus 59 days. Utilities and taxes come with tipo: tributo, banco: null and datas.vencimento: "contraApresentacao". Reference: Look up a barcode.

5. Pay

bash
curl --request POST \
  --url https://pagarcontas.efi.mimicr.dev/v1/codBarras/36496161100000159900000001000002732348665880 \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{ "valor": 15990, "dataPagamento": "2026-10-21", "descricao": "Mensalidade de outubro" }'
json
{ "idPagamento": "30000003", "valorPago": 15990, "status": "AGENDADO", "data": { "solicitacao": "2026-10-21 22:35:38", "pagamento": "2026-10-22 00:00:00" } }

This example was requested at 22:35, after the cut-off, and moved to the next business day. Efí's cut-off times, Brasília time:

TypePaid the same day until
Boletos22:00
Boletos above R$ 249.000,0014:00
Utilities and taxes18:00

After the cut-off, or with a future dataPagamento, the payment becomes AGENDADO. Weekends are skipped; holidays are not. Reference: Pay a barcode.

6. Follow it

text
CRIADO → EM_PROCESSAMENTO → EXECUTADO → LIQUIDADO
CRIADO → AGENDADO → (on the date) EM_PROCESSAMENTO → EXECUTADO → LIQUIDADO
AGENDADO or CRIADO → NAO_REALIZADO   (insufficient balance, chaos)
AGENDADO → CANCELADO                 (canceled in the Efí app)

The balance is debited when the payment enters EM_PROCESSAMENTO. Without available balance, the payment becomes NAO_REALIZADO with Saldo Insuficiente. Data: DD/MM/AAAA.. In Mimicr each following step takes a few seconds, and every change triggers a webhook (see Webhooks and errors).

bash
curl --url https://pagarcontas.efi.mimicr.dev/v1/30000003 \
  --header 'Authorization: Bearer <token>'

References: Get a bill payment and Payment summary (?dataInicio=…&dataFim=…, counts by situation).

The other side

The API has no cancel route: at Efí, that is done in the app or Internet Banking. In Mimicr:

ToUse
Run an AGENDADO payment nownpx mimicr action efi pagarcontas.payment idPagamento=30000003 action=processar
Cancel an AGENDADO paymentnpx mimicr action efi pagarcontas.payment idPagamento=30000003 action=cancelar
Reach the scheduled datenpx mimicr clock efi +1d
Force NAO_REALIZADOControlled chaos for the pagarcontas area with opsFailRate 100

To test insufficient balance, pay more than the sandbox balance (GET https://api.mimicr.dev/v1/efi shows it). The balance grows with Pix received on the Pix API (see Sandbox control).