Guides
Billing API (Cobranças)

Notifications

Receive the POST with the token, read the history at GET /v1/notification/{token} and understand the retries.

The Billing API doesn't put the event in the callback body. On every status change, Efí POSTs to the notification_url of the charge, carnê or subscription with a single field, the token. Your application looks the token up to find out what changed.

1. Set the URL

Send metadata.notification_url when creating the charge, carnê or subscription, or later with Update charge metadata:

json
{ "metadata": { "custom_id": "pedido-1042", "notification_url": "https://sua-app.dev/webhooks/efi" } }

2. Receive the POST

text
POST /webhooks/efi HTTP/1.1
Content-Type: application/x-www-form-urlencoded

notification=09027955-5e06-4ff0-a9c7-46b47b8f1b27

The token is a UUID and stays the same for the object's whole lifecycle: a standalone charge has its own; a carnê and its parcels share one; a subscription and its charges, another. Answer 2xx quickly and process afterwards.

javascript
app.post("/webhooks/efi", express.urlencoded({ extended: false }), async (req, res) => {
  res.sendStatus(200);
  const token = req.body.notification;
  const r = await fetch(`https://cobrancas.efi.mimicr.dev/v1/notification/${token}`, {
    headers: { Authorization: `Bearer ${await billingToken()}` },
  });
  const { data } = await r.json();
  const last = data[data.length - 1];
  console.log(last.type, last.identifiers, last.status.previous, "→", last.status.current);
});

3. Read the history

bash
curl --url https://cobrancas.efi.mimicr.dev/v1/notification/09027955-5e06-4ff0-a9c7-46b47b8f1b27 \
  --header 'Authorization: Bearer <token>'
json
{
  "code": 200,
  "data": [
    { "id": 1, "type": "charge", "status": { "current": "new", "previous": null }, "custom_id": "pedido-1042", "created_at": "2026-10-21 21:25:00", "identifiers": { "charge_id": 1000001 } },
    { "id": 2, "type": "charge", "status": { "current": "waiting", "previous": "new" }, "custom_id": "pedido-1042", "created_at": "2026-10-21 21:25:01", "identifiers": { "charge_id": 1000001 } },
    { "id": 3, "type": "charge", "status": { "current": "paid", "previous": "waiting" }, "custom_id": "pedido-1042", "created_at": "2026-10-23 10:02:11", "identifiers": { "charge_id": 1000001 }, "value": 5990, "received_by_bank_at": "2026-10-23" }
  ]
}

The response carries the full history, in order; id is the sequence on the token, starting at 1. Use the last item (or the items with an id greater than the last one you processed). An unknown token answers 400 with 3500010 property_does_not_exists. Reference: Get a notification.

typeidentifiersWhen
charge{charge_id}Standalone or link charge
carnet{carnet_id}Carnê status (up_to_date, unpaid, finished, canceled)
carnet_charge{carnet_id, charge_id}Carnê parcel
subscription{subscription_id}Subscription status (new, active, canceled, expired)
subscription_charge{subscription_id, charge_id}Charge of a subscription cycle

value (cents) comes on payment confirmations (paid); received_by_bank_at, on boleto ones. Changes that don't change the status (metadata, history, a new due date without a status change) generate no notification.

4. Retries

If your URL doesn't answer 2xx (3xx redirects count as failures), Efí retries up to 10 times:

AttemptMinutes after the previous failure
2 to 55, 10, 20, 40
6 to 980, 160, 320, 640
10 and 111280, 52560

In Mimicr, a 2xx answer ends the retries of that POST, and calling GET /v1/notification/{token} ends the token's pending retries. Each attempt waits up to 10 seconds for the answer. Without notification_url, the event goes into the token history but no POST is sent.

5. Test in Mimicr

Every POST is recorded in the control API, with body, attempts and what your URL answered:

bash
curl --url 'https://api.mimicr.dev/v1/efi/deliveries?api=cobrancas&kind=charge' \
  --header 'Authorization: Bearer mk_...'

To wait for a payment notification in a test:

bash
npx mimicr action efi cobrancas.charge id=1000001 action=pagar
npx mimicr wait efi delivery api=cobrancas kind=charge

POST /v1/efi/deliveries/{id}/resend resends a delivery. The cobrancas chaos with webhookFailRate makes the first attempt fail, and webhookDuplicateRate delivers the same POST twice, to test your handler's idempotency. Advancing the sandbox clock fires the retries that came due. See Sandbox control.