Webhooks
How GaiaDesk delivers webhooks: the headers, verifying the signature in Node.js or Python, what counts as delivered, the retry schedule, and handling each event once.
GaiaDesk tells your server when something happens (a support session was created, an agent joined, a session ended, a desk went offline) by POSTing a signed JSON event to your endpoint. This page is everything a receiver needs. The events and their fields are in the webhook events reference.
Subscribe
With a secret key scoped webhooks:
curl -s -X POST https://api.gaiadesk.net/v1/webhooks \
-H "Authorization: Bearer $GAIADESK_API_KEY" -H "Content-Type: application/json" \
-d '{"url": "https://example.com/hooks/gaiadesk", "events": ["support.session.ended"]}'The answer carries the signing secret (whsec_…). It is shown only then: store it. Endpoints must be https:// on the public internet; an account holds at most 20.
Send a test event
Send test on an endpoint in the console (Settings → AI agents & API → Webhooks), or POST /v1/webhooks/{id}/test, POSTs a signed webhook.test event to it right away and shows what your endpoint answered:
{"event_id": "evt_1b2c3d4e5f60718293a4b5c6", "type": "webhook.test", "delivered": true,
"status": 200, "body": "{\"ok\":true}", "duration_ms": 143, "error": null}status is your endpoint's HTTP status (null if it never answered), body the first 2 KB of its answer, and error why it is not delivered (answered 500, timed out, could not connect). It is one try with the usual 10-second limit, and it shows up in the deliveries list; a failed test is not retried by itself (test again, or Re-send it). GET /v1/webhooks/{id}/deliveries lists recent deliveries with each one's state, attempts, your endpoint's last status and the first 2 KB of its last answer (last_body).
What a delivery looks like
POST /hooks/gaiadesk
Content-Type: application/json
User-Agent: GaiaDesk-Webhooks/1
GaiaDesk-Event-Id: evt_3d4e5f60718293a4b5c6d7e8
GaiaDesk-Event-Type: support.session.ended
GaiaDesk-Signature: t=1791300960,v1=5f8e…(64 hex characters)
{"id":"evt_3d4e5f60718293a4b5c6d7e8","type":"support.session.ended", …}Verify the signature
v1 is the hex HMAC-SHA256 of <t>.<raw body>, keyed with your secret. Check it on every delivery, over the raw request body (before any JSON parsing: re-serialised JSON will not match), compare in constant time, and refuse a t more than five minutes from now (a replay).
With the server SDK:
import { GaiaDesk } from '@gaiadesk/node';
const event = GaiaDesk.webhooks.verify(secret, req.headers['gaiadesk-signature'], rawBody); // throws if it failsNode.js, by hand:
import { createHmac, timingSafeEqual } from 'node:crypto';
function verify(secret, header, rawBody, now = Math.floor(Date.now() / 1000)) {
const parts = Object.fromEntries(header.split(',').map((p) => p.trim().split('=')));
const t = Number(parts.t);
if (!Number.isInteger(t) || Math.abs(now - t) > 300) return false;
const want = createHmac('sha256', secret).update(`${t}.`).update(rawBody).digest();
const got = Buffer.from(parts.v1 ?? '', 'hex');
return got.length === want.length && timingSafeEqual(got, want);
}Python:
import hashlib, hmac, time
def verify(secret: str, header: str, raw_body: bytes, tolerance: int = 300) -> bool:
parts = dict(p.strip().split("=", 1) for p in header.split(",") if "=" in p)
try:
t = int(parts["t"])
except (KeyError, ValueError):
return False
if abs(time.time() - t) > tolerance:
return False
want = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(want, parts.get("v1", ""))To test your code: with the secret whsec_test, the body {"a":1} and t=1791300000, v1 is 5932a440433e064a555c1fb4432732b7b6bafb7a9fe2c00d134944288c70fef3.
Answering, retries and order
Success is any
2xxanswer within 10 seconds. Answer first and do slow work afterwards (a queue). Redirects are not followed: a3xxis a failure.Anything else is retried: another status, a timeout, a refused connection. The waits double from 10 seconds (10 s, 20 s, 40 s … up to one hour between tries), for 24 hours after the event, then that event is given up (
failedin the deliveries list). That is about 30 tries.Re-send one that was given up: Re-send on its row in the console's deliveries list, or
POST /v1/webhooks/{webhook_id}/deliveries/{event_id}/redeliver(202). It goes again with the same event id and body, a new signature timestamp and a fresh 24-hour retry schedule. Only afaileddelivery is re-sent (409delivery_not_failedotherwise).Each try is signed afresh: a retry has a new
t, the same body and the same event id.Nothing is lost on our side. Events wait in a durable outbox, so a GaiaDesk restart delays deliveries and never drops them.
A failing endpoint is not switched off. Each event is retried on its own schedule; fix the endpoint and the pending ones arrive. Deleting the subscription drops what is still pending.
Order is not guaranteed. Deliveries run concurrently and a retry can arrive after a later event. Use each event's
created(Unix seconds) and the object's own timestamps (ended_at,joined_at), not arrival order.GET /v1/support/sessions/{id}always has the current state.
Handle each event once
Delivery is at least once: the same event can arrive twice (a timeout after you had already processed it, for example). Every delivery of one event carries the same GaiaDesk-Event-Id (the body's id). Record the ids you have handled and skip a repeat:
if (await db.seenEvent(event.id)) return res.sendStatus(200); // already done
await db.recordEvent(event.id);
// … handle it …An event filed for several of your subscriptions has the same id at each.
The end of a support session
support.session.ended carries the whole session as it ended, including the agents' private notes and outcome as they were then. The customer can rate a session only after it ends, so .ended has "csat": null; the rating arrives in support.session.rated, whose session carries csat. Notes changed later are in GET /v1/support/sessions/{id}.
{
"id": "evt_9a8b7c6d5e4f30211a2b3c4d",
"type": "support.session.ended",
"created": 1791300960,
"livemode": true,
"data": {
"support_session": {
"id": "ss_4f1c2a9b7d3e5f60",
"object": "support_session",
"livemode": true,
"state": "ended",
"mode": "cobrowse",
"customer": {"name": "Ada Lovelace", "plan": "pro"},
"customer_verified": true,
"external_id": "ticket-4411",
"metadata": {"region": "eu"},
"origin": "https://app.example.com",
"owner": "support@acme.example",
"created_at": 1791300000,
"expires_at": 1791303600,
"connected_at": 1791300012,
"joined_at": 1791300042,
"joined_by": "agent@acme.example",
"ended_at": 1791300960,
"end_reason": "stopped",
"duration_seconds": 960,
"client": {"os": "macos", "os_version": "15.1", "app_version": "4.2.0", "sdk": "tauri", "sdk_version": "0.5.0"},
"admin_url": "https://admin.acme.example/customers/4411",
"notes": "Re-sent the invoice; customer confirmed.",
"outcome": "resolved",
"csat": null,
"consent": {
"id": "cr_01JCZ8Y3K9W2Q4V6T8R0M1N3P5", "decision": "accepted", "at": "2026-11-12T16:04:05.123Z",
"surface": "native_dialog", "locale": "en", "wording_version": "gaiadesk-0.4.0-en",
"wording_sha256": "9f2c4e1a7b3d5f60819a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f70",
"choices": {"guided": true, "share_logs": false, "capture": "window"},
"os_user": "jane", "os": "macos", "app_name": "Horus", "app_version": "2.4.1",
"sdk": "libgaiadesk_embed/0.4.0"
}
}
}
}support.session.rated then carries the same session with the rating in csat (comment is null when the customer left none):
{
"id": "evt_0f1e2d3c4b5a69788796a5b4",
"type": "support.session.rated",
"created": 1791301020,
"livemode": true,
"data": {
"support_session": {
"id": "ss_4f1c2a9b7d3e5f60",
"object": "support_session",
"livemode": true,
"state": "ended",
"mode": "cobrowse",
"customer": {"name": "Ada Lovelace", "plan": "pro"},
"customer_verified": true,
"external_id": "ticket-4411",
"metadata": {"region": "eu"},
"origin": "https://app.example.com",
"owner": "support@acme.example",
"created_at": 1791300000,
"expires_at": 1791303600,
"connected_at": 1791300012,
"joined_at": 1791300042,
"joined_by": "agent@acme.example",
"ended_at": 1791300960,
"end_reason": "stopped",
"duration_seconds": 960,
"client": {"os": "macos", "os_version": "15.1", "app_version": "4.2.0", "sdk": "tauri", "sdk_version": "0.5.0"},
"admin_url": "https://admin.acme.example/customers/4411",
"notes": "Re-sent the invoice; customer confirmed.",
"outcome": "resolved",
"csat": {"rating": 5, "comment": "Quick and kind.", "rated_at": 1791301020},
"consent": null
}
}
}Both examples are checked against real deliveries in GaiaDesk's tests: a field shown here is a field you receive.
end_reason is stopped (the customer stopped sharing), customer_cancelled (the customer, or their app, stopped while still waiting: no agent had joined), disconnected, expired, ended_by_api, customer_declined (the customer said no at the consent step) or consent_timeout (nobody answered it in time); treat a value you do not know as ended. A test session's events arrive the same way with "livemode": false.
Proof of consent
When the customer answers the SDK's consent step, its receipt is stored on the session and sent as support.session.consent (data.consent is the receipt, data.support_session the session). From then on every support event carries it as support_session.consent: customer_connected, joined and ended included. support.session.created always has "consent": null: it fires when the session is made, before the customer is asked. A declined or timeout receipt for a session no agent has joined is followed by support.session.ended with end_reason customer_declined or consent_timeout. See In-app support for what the receipt holds.
A support.session.consent delivery for a customer who accepted in your app's webview, before an agent joined:
{
"id": "evt_1b2c3d4e5f60718293a4b5c6",
"type": "support.session.consent",
"created": 1791300010,
"livemode": true,
"data": {
"support_session": {
"id": "ss_4f1c2a9b7d3e5f60",
"object": "support_session",
"livemode": true,
"state": "waiting",
"mode": "cobrowse",
"customer": {"name": "Ada Lovelace", "plan": "pro"},
"customer_verified": true,
"external_id": "ticket-4411",
"metadata": {"region": "eu"},
"origin": "https://app.example.com",
"owner": "support@acme.example",
"created_at": 1791300000,
"expires_at": 1791303600,
"connected_at": null,
"joined_at": null,
"joined_by": null,
"ended_at": null,
"end_reason": null,
"duration_seconds": null,
"client": {"os": "macos", "os_version": "15.1", "app_version": "4.2.0", "sdk": "tauri", "sdk_version": "0.5.0"},
"admin_url": "https://admin.acme.example/customers/4411",
"notes": null,
"outcome": null,
"csat": null,
"consent": {
"id": "cr_01JCZ8Y3K9W2Q4V6T8R0M1N3P5", "decision": "accepted", "at": "2026-11-12T16:04:05.123Z",
"surface": "embedded", "locale": "en", "wording_version": "acme-2026-11",
"wording_sha256": "9f2c4e1a7b3d5f60819a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f70",
"choices": {"guided": false, "share_logs": true, "capture": "window"},
"os_user": "jane", "os": "macos", "app_name": "Horus", "app_version": "2.4.1",
"sdk": "libgaiadesk_embed/0.4.0"
}
},
"consent": {
"id": "cr_01JCZ8Y3K9W2Q4V6T8R0M1N3P5", "decision": "accepted", "at": "2026-11-12T16:04:05.123Z",
"surface": "embedded", "locale": "en", "wording_version": "acme-2026-11",
"wording_sha256": "9f2c4e1a7b3d5f60819a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f70",
"choices": {"guided": false, "share_logs": true, "capture": "window"},
"os_user": "jane", "os": "macos", "app_name": "Horus", "app_version": "2.4.1",
"sdk": "libgaiadesk_embed/0.4.0"
}
}
}os_user is null in a receipt a plain web page made (the web component's server-only bridge). The receipt's id is cr_ and 26 characters; a session takes one receipt (a second POST /v1/support/sessions/{id}/consent answers 409 already_recorded).
A customer is waiting
When a connected customer has waited your wait_seconds (Waiting alerts, default 30) and no agent has joined, GaiaDesk sends the waiting alert to your Slack, Discord, email and push channels and, at the same moment, support.session.waiting to your endpoint. data.alert is the alert itself (ApiSupportWaitingAlert): session_id, the console's join_url, who is waiting (customer.name, and customer.external_id when you set one), how long (waiting_seconds) and the summary sentence every channel shows. It fires once per live session (never for a test key's), whether or not any channel is set.
{
"id": "evt_5f60718293a4b5c6d7e8f901",
"type": "support.session.waiting",
"created": 1791300107,
"livemode": true,
"data": {
"support_session": {
"id": "ss_4f1c2a9b7d3e5f60",
"object": "support_session",
"livemode": true,
"state": "waiting",
"mode": "cobrowse",
"customer": {"name": "Ada Lovelace", "plan": "pro"},
"customer_verified": true,
"external_id": "ticket-4411",
"metadata": {"plan": "pro"},
"origin": null,
"owner": "support@acme.example",
"created_at": 1791300000,
"expires_at": 1791301800,
"connected_at": 1791300012,
"joined_at": null,
"joined_by": null,
"ended_at": null,
"end_reason": null,
"duration_seconds": null,
"client": null,
"admin_url": null,
"notes": null,
"outcome": null,
"csat": null,
"consent": null
},
"alert": {
"object": "support_waiting_alert",
"session_id": "ss_4f1c2a9b7d3e5f60",
"join_url": "https://gaiadesk.net/app/support.html#session=ss_4f1c2a9b7d3e5f60",
"customer": {"name": "Ada Lovelace", "external_id": "ticket-4411"},
"waiting_seconds": 95,
"summary": "Ada Lovelace (ticket-4411) has been waiting 1 min 35 s for support."
}
}
}This example is checked against a real delivery in GaiaDesk's tests, as are the channels: Slack gets summary and a Join the session button, Discord summary with the link and a linked embed, email summary with a button and the URL written out, and push summary as the notification's text, opening join_url when tapped.
Server SDK
@gaiadesk/node (Node.js 18+, no dependencies) verifies deliveries and calls the support API with typed requests and answers. See In-app support.