Webhooks

Webhooks

Signed events for orders, the eSIM's life and your balance, with retries and a delivery log.

Set up an endpoint

Webhooks tell your server what happens after you order: the order went through or failed, the traveller installed the eSIM, it connected, used 80% of its data, expired; your balance ran low or was topped up.

  1. Create an HTTPS endpoint that accepts POST with a JSON body.
  2. Register it with /webhook/configuration (or in the dashboard under Webhooks). The first URL creates your signing secret, which is in the answer. Store it with your other secrets.
  3. Optionally limit events (default: all; null resets to all) and set lowBalanceThreshold in USD to receive balance.low.

Live and Sandbox have separate settings and secrets. Rotate a secret with /webhook/secret/rotate, and read the current settings with /webhook/get.

The request we send

Every event is a POST with a JSON body { id, event, createdTime, environment, test, data }:

FieldMeaning
idUnique per event. Also in the Burj-Delivery-Id header. Use it to ignore duplicates.
eventThe event name, also in the Burj-Event header.
createdTimeWhen it happened, ISO 8601 UTC.
environmentproduction or sandbox
testtrue for events sent by /webhook/test
dataThe event's payload: see the event catalog.

Verify the signature

Anyone can POST to your URL, so check every request came from Burj before acting on it. The Burj-Signature header looks like t=<unix seconds>,v1=<hex>, where:

Signature
v1 = hex( HMAC_SHA256( secret, t + "." + rawBody ) )
  1. Use the raw body bytes, before any JSON parsing. Re-serialised JSON won't match.
  2. Compare in constant time.
  3. Reject the request if t is more than 5 minutes away from your clock (replay protection).
  4. Answer 400 if the check fails, and don't process the event.

Answer fast; retries

Any 2xx within 10 seconds counts as delivered. Answer first, then do the work (queue it), so a slow database never turns into a retry.

On an error, a timeout or a non-2xx answer, Burj retries after:

Attempt234567
Wait1 min5 min30 min2 h6 h12 h

That's 7 attempts over about 21 hours. After the last one the delivery is FAILED. You can send any delivery again from the delivery log.

Handle duplicates

Duplicates are rare but possible (for example when your 200 got lost on the way back). Store each event's id and skip the ones you've seen. Events can also arrive out of order: rely on the status in the payload, or fetch the eSIM with /{orderId}/data, rather than on arrival order.

Test your endpoint

  • /webhook/test sends a webhook.test event (or a sample of another event) to your URL right now and tells you how your server answered.
  • In the sandbox, the eSIM simulator sends the real esim.* events, and a simulated failure sends order.failed.
  • Working locally? Expose your server with a tunnel and register the tunnel's HTTPS URL in the sandbox.

Delivery log

/webhook/deliveries lists every event sent to you, newest first, with the payload, attempts and your server's last answer. Filter by status (PENDING, RETRYING, DELIVERED, FAILED) or event. After fixing your endpoint, resend what failed.

Event catalog

EventSent when
order.completedAn order went through (also partial ones, with partial)
order.failedThe provider failed; the amount is back in the balance
esim.installedThe traveller installed the eSIM
esim.activatedThe eSIM connected for the first time (plan started)
esim.usage_80_percent80% of the data is used (once per eSIM)
esim.expiredThe plan ended
balance.lowBalance went under your lowBalanceThreshold (once, re-armed when it goes back above)
balance.topped_upA top-up payment was credited
webhook.testSent by /webhook/test only

order.completed

An order went through (also partial ones, with partial).

  • externalReferencestring
  • packageIdstring
  • countryIdstring
  • quantityinteger
  • unitPriceinteger
  • totalinteger
  • currencystring
  • transactionIdstring
  • balanceinteger
  • esimsobject[]

order.failed

The provider failed; the amount is back in the balance.

  • externalReferencestring
  • packageIdstring
  • countryIdstring
  • quantityinteger
  • refundedAmountnumber
  • currencystring
  • reasonstring
  • balanceinteger

esim.installed

The traveller installed the eSIM.

  • orderIdstring
  • esimIdstring
  • iccidstring
  • externalReferencestring
  • packageIdstring
  • countryIdstring
  • statusinteger
  • statusLabelstring
  • usageobject

esim.activated

The eSIM connected for the first time (plan started).

  • orderIdstring
  • esimIdstring
  • iccidstring
  • externalReferencestring
  • packageIdstring
  • countryIdstring
  • statusinteger
  • statusLabelstring
  • usageobject

esim.usage_80_percent

80% of the data is used (once per eSIM).

  • orderIdstring
  • esimIdstring
  • iccidstring
  • externalReferencestring
  • packageIdstring
  • countryIdstring
  • statusinteger
  • statusLabelstring
  • usageobject

esim.expired

The plan ended.

  • orderIdstring
  • esimIdstring
  • iccidstring
  • externalReferencestring
  • packageIdstring
  • countryIdstring
  • statusinteger
  • statusLabelstring
  • usageobject

balance.low

Balance went under your lowBalanceThreshold (once, re-armed when it goes back above).

  • balancenumber
  • thresholdinteger
  • currencystring

balance.topped_up

A top-up payment was credited.

  • invoiceIdstring
  • amountinteger
  • balanceinteger
  • currencystring
  • sourcestring

webhook.test

Sent by /webhook/test only.

  • ninteger