Skip to content
Book a demo

Developers

13 SAGARIS webhook events, HMAC and dead letters

Register an https endpoint and SAGARIS will POST a signed JSON envelope to it when something happens in your workspace. Delivery is durable: every event becomes a queued row that is retried on its own schedule rather than fired once and forgotten.

Registering an endpoint

Every subscription action needs the Manage API keys permission, held by default by the same Admin role that can mint an API key, and a custom role can be given it. That covers listing your subscriptions, registering one, deleting one, and the test, replay and rotate actions below.

A subscription is a persistent, signed, active outbound channel carrying contact records and reply content, so a lower-privilege member cannot stand one up, and the list is held to the same permission because a target url is often a secret in its own right. Deleting one and rotating its secret need it for the mirror-image reason: a member should not be able to tear down or quietly re-point another admin's delivery channel.

You supply a target_url and, optionally, the event types you want. An empty list means every event. Any type you do list must be a known event type, so a typo is refused at registration rather than silently subscribing you to nothing.

A subscription also carries only events whose data you could see yourself, because it sends that data outside the workspace. The contact, meeting, reply, opt-out and sequence events need View all records. The two deal events need View all deals and Deal margin, because they carry the deal's value. The call and AI receptionist events need Listen to recordings and View all records. A campaign launch needs nothing more. An empty list needs all of them, and registering an event you could not see is refused with the permissions it needs. This is checked when you register: a subscription does not yet record who registered it, so it keeps delivering if that person later loses one of these permissions.

Note

The signing secret is generated server-side and returned exactly once, in the response to the registration call. Listing your subscriptions afterwards never echoes it. If you lose it, rotate it; rotation issues a new secret and is the only way to get one.

  • The target must be https. An http url is refused.
  • The hostname is resolved at registration and rejected if it points anywhere private, internal, or at a cloud metadata endpoint, so a subscription cannot be used to make the platform fetch something on its own network.
  • That check is not only done once. It runs again immediately before every single delivery, because a host that resolved publicly at registration can be re-pointed later.

The 13 events, what emits each one, and what it needs

13 event types exist. Each is listed here with the action that actually fires it, because the interesting question is not what the type list contains but which of your real workflows will produce one, and with the permissions you need to subscribe to it.

contact.created
A contact is created in the app. It also fires when the AI receptionist creates a contact for a new caller: that one is queued when the receptionist creates it and again by the webhook dispatch sweep described below, with one delivery per subscription. Needs View all records.
contact.stage_changed
A contact's lifecycle stage moves. Needs View all records.
contact.unsubscribed
An opt-out is recorded, whether from a consent change in the app, an unsubscribe or a reply handled by inbound mail processing. Needs View all records.
meeting.booked
A meeting is booked. It also fires when the AI receptionist books a meeting on a call, or when a person confirms a booking request the receptionist took, with source set to ai_receptionist. Needs View all records.
reply.received
An inbound reply arrives, by email or by SMS. Needs View all records.
deal.closed_won
An opportunity moves to closed won. Needs View all deals and Deal margin.
deal.closed_lost
An opportunity moves to closed lost. Needs View all deals and Deal margin.
campaign.launched
A campaign is launched. Needs no permission beyond Manage API keys.
sequence.completed
An enrollment reaches the completed state through a manual advance. See the limits below. Needs View all records.
call.completed
A call with an AI leg has ended: an inbound call the AI receptionist answered, or an outbound call the AI agent placed. A call with no AI leg, such as a rep's ordinary dialer call, does not fire it. It is queued by the webhook dispatch sweep, which runs every minute, and for inbound receptionist calls again by the post-call summary job, which runs every five minutes; both carry the same key, so a subscription gets one delivery, and the payload fields depend on which of the two queued it first. Needs Listen to recordings and View all records.
receptionist.message_taken
The AI receptionist captured a message from a caller. A message the content check refused, or one that failed to save, does not fire it. Queued only by the webhook dispatch sweep. Needs Listen to recordings and View all records.
receptionist.callback_scheduled
The AI receptionist promised a caller a callback and recorded it. A callback a person schedules in the dialer does not fire it. Queued only by the webhook dispatch sweep. Needs Listen to recordings and View all records.
receptionist.escalation
A caller asked the AI receptionist for a human or reported an emergency, and the escalation was recorded. The payload says whether it was an emergency. Queued only by the webhook dispatch sweep. Needs Listen to recordings and View all records.

Note

Two limits worth knowing before you design against these. Writes through the public REST API do not emit events at all: a contact created with POST /api/v1/contacts produces no contact.created. And sequence.completed is emitted only from the manual completion path, the one a rep triggers by completing a task or logging a LinkedIn send; the scheduler's own timer-driven completion is deliberately not wired to it. If you need to observe either, poll rather than wait for a webhook.

The AI events, and the contact.created for a caller the receptionist added, are gated. Only a workspace that runs the AI receptionist or the AI agent produces them. And the webhook dispatch sweep that queues them runs every minute, looks back 15 minutes, only for workspaces that have an active subscription at that moment, and reads at most 200 rows of each kind per pass, oldest first. Subscriptions must be active when delivery is queued. Events within the lookback window can precede registration. In a burst of more than 200 within 15 minutes the newer rows can be missed. For an inbound receptionist call, call.completed can still arrive from the post-call summary job, which looks back a day.

Emission is best effort by design, and never part of the transaction it reports. A failure to enqueue is swallowed rather than rolled back, on the reasoning that a webhook problem must never undo or block the business write that succeeded.

What arrives at your endpoint

A POST with a JSON body and three headers alongside the content type.

x-sagaris-signature
The HMAC of the raw body, in the form sha256=<hex>.
x-sagaris-event
The event type, so you can route without parsing the body first.
x-sagaris-delivery
The delivery id. Every retry of the same event carries the same id, which is what makes it usable as a de-duplication key.

The body is a normalized envelope carrying a schema version, a unique event id, a deterministic idempotency key, the event type, the workspace id, and the resource the event is about. The idempotency key is derived from the logical event, so the same underlying occurrence produces the same key even if it is emitted twice.

Verifying the signature

Compute an HMAC-SHA256 of the exact raw request body using your subscription secret, hex-encode it, prefix it with sha256=, and compare against the header. Compare in constant time. Do this before you parse or trust anything in the payload: the signature is the only thing distinguishing a genuine delivery from anyone who guessed your url.

JavaScript
Node
import crypto from "node:crypto";

const expected =
  "sha256=" + crypto.createHmac("sha256", secret).update(rawBody, "utf8").digest("hex");

const a = Buffer.from(expected, "utf8");
const b = Buffer.from(req.headers["x-sagaris-signature"] ?? "", "utf8");
const valid = a.length === b.length && crypto.timingSafeEqual(a, b);

Note

Sign the raw body, not a re-serialized copy of the parsed JSON. Re-serializing can reorder keys or change whitespace, and the signature will then never match. Capture the body as text before your framework parses it.

Delivery, retries and dead letters

Emitting an event does not POST anything. It inserts one durable delivery row per active subscription that wants that type. Event deliveries are queued and sent by a background worker, which claims the rows whose next attempt is due and POSTs them; Test and Replay deliver immediately.

  • Any 2xx is success. Everything else, including a timeout or a connection failure, is a failure.
  • Each POST is given 10 seconds. A slow endpoint is treated as a transient failure and retried, never dropped.
  • There are six attempts. The wait doubles from one minute: the retries after the first five attempts fall roughly one, two, four, eight and sixteen minutes later.
  • After the sixth failed attempt the delivery is marked failed and stops being retried. The last response code and error text stay on the row so you can see why.

A delivery is claimed with a lease before it is sent, so two overlapping worker passes cannot both POST the same row. Your endpoint should still be idempotent: the delivery id is stable across retries precisely so you can discard one you have already processed.

Note

Two conditions end a delivery immediately rather than retrying it, because retrying would be pointless or unsafe. If the subscription has been deleted or deactivated since the event was queued, the delivery is failed rather than sent into nothing. If the target url no longer passes the safety check at send time, the delivery is failed with no request made at all, rather than retried against a host that has been re-pointed somewhere private.

Operating a subscription

Listing your subscriptions returns each one with its latest delivery and its ten most recent deliveries, each carrying status, attempt count, response code, last error and the time of the next attempt. That is the first place to look when a subscriber has gone quiet.

test
Queue a delivery to the subscription so you can confirm the endpoint receives and verifies it.
replay
Requeue a specific delivery that ended in failed, once the receiver is fixed.
rotate
Issue a new signing secret, returned once. The only action permitted on an inactive subscription.

All three need Manage API keys and all three are scoped to your own workspace: a delivery is addressed by id together with the workspace and subscription that own it, so a replay can never reach another workspace's queue. Creating, rotating and deleting a subscription are each written to the workspace audit.

Building on it? Bring your use case.

Book a demo