Delivery
How events reach you, by stream or webhook, and how to handle retries, replays and repeats.
Every moment goes out as a moment.detected event. You can receive it three ways, and use more than
one at once:
| Use | When | How |
|---|---|---|
| The conversation's event stream | A live UI, or a worker that follows one conversation. | GET /conversations/{id}/stream, server-sent events. |
| The conversation's own webhook | Whoever starts the conversation handles its events. | Pass webhook_url when you create it. |
| A webhook subscription | One backend handles every conversation of the organization. | POST /webhooks, or Webhooks in the dashboard. |
The stream carries moment.detected only. Webhooks also get the conversation's lifecycle:
| Event | When |
|---|---|
conversation.created | A conversation was created. |
moment.detected | A moment was let go. |
conversation.ended | An ended conversation let go its last moment. data.summary counts what it produced. |
conversation.deleted | A conversation was deleted, with everything it held. Subscriptions only. |
The event
The same envelope travels on every path:
{
"id": "evt_2kd7qd8k2p6t0x4a7c1f",
"object": "event",
"type": "moment.detected",
"livemode": false,
"created_at": "2026-12-03T15:00:31Z",
"data": {
"id": "mom_2kd7qb3f7j1n5r9v2y6d",
"object": "moment",
"kind": "request.do",
"text": "I'll get the SSO fix out by Friday.",
"…": "…"
}
}The event id is the one to deduplicate on. It's the same on the stream and in the webhook, on
every retry and replay, and when one event goes to several URLs. Store the IDs you've handled and
skip one you've seen.
The stream
The stream sends the moments already let go first, then each new one as it's let go, until you disconnect:
: connected
id: 1796310031377-0
event: moment.detected
data: {"id":"evt_2kd7qd8k2p6t0x4a7c1f","object":"event","type":"moment.detected","livemode":false,"data":{…}}
: heartbeat- Lines starting with
:are comments that keep the connection open. Ignore them. - Each event's
id:line is its position in the stream, not the event ID. To resume after a dropped connection, send the last one back in theLast-Event-IDheader and the stream continues after it. BrowserEventSourcedoes this for you. - The stream needs your API key, so open it from your server, never from a browser, and relay what your UI needs.
@sparkle/sdk is in private beta
The TypeScript tabs use @sparkle/sdk, which isn't on npm yet. To try it, ask us for
access. Python and Go have no SDK yet: the cURL, Python and Go tabs
call the HTTP API directly.
curl -N https://api.sparkle.ai/public/v1/conversations/$CONVERSATION_ID/stream \
-H "X-API-Key: $SPARKLE_API_KEY" \
-H "Last-Event-ID: 1796310031204-0"Webhooks
Each delivery is a POST with the event as its body and three headers: Sparkle-Event (the type),
Sparkle-Delivery (the delivery, the same on every retry) and Sparkle-Signature. Check the
signature before you trust the body: Verify the signature has
the code.
- Answer
2xxwithin 30 seconds. Do slow work after you answer. - Retries. A network error, a timeout, a
429or a5xxis retried: up to 5 attempts, the first at once and the next after 1, 2, 4 and 8 minutes. Any other4xxfails the delivery at once. - Replay.
POST /webhooks/{id}/deliveries/{deliveryId}/replaysends a delivery again, for example after you fix your endpoint. The replay carries the same eventid. - Order. Each delivery is sent and retried on its own, so events can arrive out of order.
conversation.endedis emitted after a conversation's last moment; treat the conversation as complete once you holdsummary.moments_countof its moments.
A conversation's own webhook and a subscription are independent. When both exist, each event goes
to both, with the same event id. Webhooks covers subscriptions, secrets,
deliveries and replay in full.
Catching up
If you missed events, GET /conversations/{id}/moments lists a conversation's moments in the order
they were let go. Each one has the moment id that was inside its event's data.
Safe retries on your side
Every POST and PUT you send needs an Idempotency-Key header, such as a UUID. Sending the same
key again returns the first request's response and does nothing twice, so when a request times out,
retry it with the same key. Use a new key for each new request. A retry that arrives while the first
is still running gets 409 conflict.idempotency_key: wait, then send
it again.