Docs menu

Webhooks and events: signatures, retries and event types

Receive bubblr events by webhook: verify the X-Signature HMAC, handle retries and duplicates, and see every event type and its data.

Everything that happens on your lines is an event: a reply arrives, a message is delivered or read, a draft waits, a call ends. bubblr sends events to your webhooks, signed and retried, and to the live event stream.

Creating a webhook

Shell
curl -X POST https://api.bubblr.io/v1/webhooks \
  -H "Authorization: Bearer $BUBBLR_API_KEY" -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/hooks/bubblr", "events": ["message.received", "message.failed"]}'
  • url must be public https://: no credentials in it, no private or local addresses. Redirects aren't followed.
  • events lists the event types to send.
  • profile_ids limits it to some lines. A key limited to some lines must list them, and only sees webhooks for them.

The answer has secret (whsec_…), shown only once. Keep it with your other secrets; POST /v1/webhooks/{webhook_id}/rotate-secret makes a new one. The key needs the webhooks:manage scope.

What a delivery looks like

HTTP
POST /hooks/bubblr HTTP/1.1
Content-Type: application/json
X-Bubblr-Event: message.received
X-Bubblr-Event-Id: evt_8Bv3nR7tLx
X-Bubblr-Delivery: dlv_6Gy1qW5mKc
X-Bubblr-Attempt: 1
X-Signature: t=1795382645,v1=5f0c…

{
  "id": "evt_8Bv3nR7tLx",
  "object": "event",
  "type": "message.received",
  "created_at": "2026-11-20T16:04:05.000Z",
  "profile_id": "prf_2Wq8nT4kLm",
  "data": { "message": { "id": "msg_9KxT3vQ7Pa", "chat_id": "cht_5Rf1sD8hJw", "direction": "inbound", "text": "Is the 7 PM table still free?", … } }
}

Checking the signature

X-Signature is t=<unix seconds>,v1=<hex>, where v1 is the HMAC-SHA256 of <t>.<raw body> with your webhook's secret. Check it on the raw body, before parsing the JSON, and refuse a t older than 5 minutes so an old delivery can't be replayed at you.

With the SDK:

TypeScript
import { verifyWebhook } from "@bubblr/sdk";

const event = await verifyWebhook({ payload: rawBody, signature: headers["x-signature"], secret: process.env.BUBBLR_WEBHOOK_SECRET! });
// throws WebhookVerificationError if it doesn't check out

With Node's own crypto:

JavaScript
import crypto from "node:crypto";

function verify(secret, rawBody, header) {
  const { t, v1 } = Object.fromEntries(header.split(",").map((part) => part.split("=")));
  if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
  const want = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
  return v1?.length === want.length && crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(want));
}

With Python:

Python
import hashlib, hmac, time

def verify(secret: str, raw_body: bytes, header: str) -> bool:
    parts = dict(p.split("=", 1) for p in header.split(","))
    t = int(parts.get("t", "0"))
    if abs(time.time() - t) > 300:
        return False
    want = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(want, parts.get("v1", ""))

Answering, retries and duplicates

  • Answer with any 2xx within 10 seconds. Do slow work after answering (put the event on a queue).
  • Anything else, or no answer, is retried: up to 6 attempts, about 2 seconds, 8 seconds, 30 seconds, 2 minutes and 8 minutes apart. After the last, the delivery is failed.
  • Each delivery is stored before the first attempt, so an event isn't lost if something restarts mid-way.
  • Delivery is at least once: the same event can arrive twice. De-duplicate by X-Bubblr-Event-Id (the event's id).
  • Events can arrive out of order (a message.delivered before its message.sent, after a retry). Use each message's status and times rather than the order events came in.

See what happened with GET /v1/webhooks/{webhook_id}/deliveries (attempts, your endpoint's last status, the last error), send a finished delivery again with POST …/deliveries/{delivery_id}/replay, and try your endpoint with POST /v1/webhooks/{webhook_id}/test, which sends a webhook.test event. PATCH a webhook with "active": false to pause it.

Event types

Type When data
message.received Someone texted the line. message
message.sent A message went out. service says how. message
message.delivered It reached their device. message
message.read They read it (iMessage read receipts). message
message.failed It couldn't be sent; message.error.code says why. message
message.fallback iMessage couldn't reach them, so it's going again as a text. message
message.reaction A reaction was added to or removed from a message. reaction (kind, emoji, removed), from, chat_id, target_message_id, at, message (the message reacted to, with all its reactions, or null)
draft.created A draft-only key wrote a draft. draft
draft.approved A person approved it; it's being sent. draft, message
draft.rejected A person discarded it. draft
chat.updated A chat was assigned (agent, human or nobody). chat, changed, by
profile.online The line is working again. profile_id, state
profile.offline The line is having trouble; sends wait in the queue. profile_id, state
call.ringing A call started ringing. call
call.answered Someone (or your voice agent) answered. call
call.transferred The caller was moved to someone else. call, to, by
call.ended The call ended. call
call.voicemail The caller left a voicemail. call
call.transcription The voicemail's transcription is ready. call
calling.cap_warning The team used 80% or 100% of its monthly minutes cap. month, minutes_used, minutes_cap, percent, outbound_blocked
webhook.test You asked for a test delivery. webhook_id, message

message, draft, chat and call are the same objects the API answers (see the API reference). Events about a line carry its profile_id; team-wide ones (calling.cap_warning, webhook.test) have null.

The live event stream

GET /v1/events streams the same events as Server-Sent Events, for dashboards and tools that are connected anyway:

Shell
curl -N "https://api.bubblr.io/v1/events?types=message.received,message.sent" -H "Authorization: Bearer $BUBBLR_API_KEY"
Text
id: evt_8Bv3nR7tLx
event: message.received
data: {"id":"evt_8Bv3nR7tLx","object":"event","type":"message.received",…}

Filter with profile_id and types. The stream is live only: what happened while you were disconnected isn't replayed, so anything you must not miss belongs on a webhook. It needs messages:read, and stops within seconds of the key being revoked.

Keys come with your first line.

Request an invite and we'll set up a line for your team. API access is part of every plan.

Request an invite