Skip to main content

Designing Webhooks for eSIM Activation Status Updates

Updated 5 min readMarkdown

When a customer buys an eSIM, their next question is whether it worked. Your backend learns the answer from events: the profile was released, a download started, an installation succeeded or failed. If other systems need to know, such as a storefront, a reseller platform or a customer app, webhooks are the usual way to tell them. This post covers how to design a webhook feed for activation status that receivers can trust and handle.

What to send

Send small events that describe a change, not a snapshot of everything. A useful envelope looks like this:

{
  "id": "evt_01HZX3K9",
  "type": "profile.installed",
  "created": "2026-10-01T09:30:12Z",
  "api_version": "2026-01",
  "data": {
    "order_id": "ord_8841",
    "iccid": "8901260000000000000",
    "state": "installed"
  }
}

A few decisions in that payload matter:

  • A stable event ID. Receivers use it to ignore duplicates.
  • A type string that is specific and namespaced, such as profile.downloaded, profile.installed and profile.failed. Add new types freely, and tell receivers to ignore types they do not know.
  • A version field, so you can evolve the payload without breaking existing receivers.
  • Minimal data. Do not put activation codes, matching IDs or keys in a webhook. Send identifiers and let the receiver fetch details from an authenticated API if it needs them.

Delivery semantics: at least once

You cannot guarantee exactly-once delivery over HTTP. If the receiver processes an event and the response is lost, you will send it again. Design for at-least-once delivery and require idempotent receivers, and document that events can arrive twice and out of order.

Ordering is the subtle part. Do not promise global ordering. Instead, include enough information for the receiver to ignore stale events: a sequence number per profile, or the state plus a timestamp. A receiver then keeps the highest sequence it has seen and discards anything older.

Signing the payload

A webhook endpoint is a public URL, so anyone can post to it. The receiver needs to verify that the call came from you. Sign the raw body with a shared secret, include a timestamp to limit replay, and send the signature in a header:

import hmac, hashlib, time

def sign(secret: bytes, body: bytes, timestamp: int) -> str:
    signed = f"{timestamp}.".encode() + body
    return hmac.new(secret, signed, hashlib.sha256).hexdigest()

# header: X-Signature: t=1760000000,v1=<hex digest>

The receiver recomputes the digest over the raw bytes, compares with a constant-time function, and rejects timestamps older than a few minutes:

def verify(secret: bytes, body: bytes, header: str, tolerance=300) -> bool:
    parts = dict(p.split("=", 1) for p in header.split(","))
    ts = int(parts["t"])
    if abs(time.time() - ts) > tolerance:
        return False
    expected = sign(secret, body, ts)
    return hmac.compare_digest(expected, parts["v1"])

Verify the raw body before parsing it, since re-serializing JSON can change the bytes. Support secret rotation by accepting more than one active secret for a period.

Retries and the outbox

Delivery must survive crashes and slow receivers. The reliable pattern is a transactional outbox: when the state of a profile changes, write the event to an outbox table in the same transaction. A separate dispatcher reads the table and delivers.

CREATE TABLE webhook_outbox (
    id            BIGSERIAL PRIMARY KEY,
    endpoint_id   BIGINT NOT NULL,
    event_id      TEXT NOT NULL,
    payload       JSONB NOT NULL,
    attempts      INTEGER NOT NULL DEFAULT 0,
    next_attempt  TIMESTAMPTZ NOT NULL DEFAULT now(),
    delivered_at  TIMESTAMPTZ,
    UNIQUE (endpoint_id, event_id)
);

The dispatcher treats any 2xx response as success. For anything else, including timeouts, it schedules another attempt with exponential backoff and jitter, as in the retry post of this series. After a long failure window, disable the endpoint and notify its owner so that a dead URL does not consume resources forever.

Keep the receiver fast

Tell consumers to acknowledge quickly and process afterwards: verify the signature, store the event, return a 2xx, and do the real work in a background job. A receiver that does slow work before replying will cause timeouts and trigger duplicate deliveries.

Give receivers a way to recover

People will miss events, through outages, bugs or a deleted endpoint. Offer:

  • An API to list events in a time range, so a receiver can backfill.
  • A way to resend a specific event.
  • A status endpoint for a profile, so that a missed webhook costs a lookup, not a support ticket.

Mapping provider events

The SM-DP+ notifications that tell you about installation are your inputs. Your webhook events are a translation of them into your own vocabulary, after your state machine has accepted the change. Emit an event only when the transition really happened, so that duplicates from upstream do not become duplicates for your receivers.

Takeaways

  • Send small, versioned, signed events with stable IDs.
  • Promise at-least-once delivery and make receivers idempotent.
  • Use a transactional outbox with backoff and an endpoint-disable policy.
  • Keep secrets out of payloads and provide a backfill path.

About the author: I work on content and web development at eSIMCircle, a travel eSIM provider. This series comes from the engineering side of that work.

About the author

  • eSIMCircle provides affordable global eSIM plans with reliable data in 200+ countries.

No comments yet. Be the first to comment.

More from this blog