Skip to content

Live transcription callbacks (webhooks)

With callbacks, the API also POSTs a session’s messages to your server: to store transcripts as they come, or process them away from the client that streams the audio. Your firewall filters by address? The calls leave from your cluster’s IP addresses.

{
"callback": true,
"callback_config": {
"url": "https://hooks.example.com/gladia",
"receive_final_transcripts": true,
"receive_post_processing_events": true,
"receive_lifecycle_events": true
}
}

callback_config chooses the messages independently of the WebSocket’s messages_config; its defaults differ (final transcripts, post-processing and lifecycle events on, the rest off). The URL must be https, on a public address.

Each POST carries the session id, the event and the WebSocket message:

{
"id": "0199d7a2-5c3e-7b41-9f0a-3c2d1e4f5a6b",
"event": "live.transcript",
"payload": { "type": "transcript", "session_id": "0199d7a2-...", "data": { "id": "00_00000003", "is_final": true, "utterance": { "text": "..." } } }
}

event is live. followed by the message type: live.start_session (callbacks only, when the WebSocket opens), live.start_recording, live.transcript, live.speech_start, live.speech_end, live.translation, live.named_entity_recognition, live.sentiment_analysis, live.speculation, live.audio_chunk, live.stop_recording, live.end_recording, live.post_transcript, live.post_summarization (with summarization), live.post_final_transcript, live.end_session, live.error, and live.session_config (the answer to a session change, with the acknowledgments). The payloads are the WebSocket messages. pii and end_of_turn messages are not sent to callbacks.

Each POST is signed with your workspace’s callback signing secret the Standard Webhooks way, as the account webhooks are, with three headers:

Header Value
webhook-id The message’s id (msg_…): one per message, the same on every retry of it. Deduplicate on it
webhook-timestamp When this attempt was signed, in Unix seconds
webhook-signature v1, and the base64 HMAC-SHA256 of <webhook-id>.<webhook-timestamp>.<raw body>, keyed with the bytes of the secret: the base64 after whsec_

The same three values are also sent as svix-id, svix-timestamp and svix-signature. Any Standard Webhooks or Svix library verifies them with your secret; without one:

import base64, hashlib, hmac, time
def verify(secret: str, headers: dict[str, str], raw_body: bytes, window_s: int = 300) -> bool:
msg_id, ts = headers.get("webhook-id", ""), headers.get("webhook-timestamp", "")
if not ts.isdigit() or abs(time.time() - int(ts)) > window_s:
return False
key = base64.b64decode(secret.removeprefix("whsec_"))
mac = hmac.new(key, f"{msg_id}.{ts}.".encode() + raw_body, hashlib.sha256).digest()
expected = "v1," + base64.b64encode(mac).decode()
return any(hmac.compare_digest(expected, s) for s in headers.get("webhook-signature", "").split())
import { createHmac, timingSafeEqual } from "node:crypto";
export function verify(secret, headers, rawBody, windowS = 300) {
const id = headers["webhook-id"] ?? "";
const ts = headers["webhook-timestamp"] ?? "";
if (!/^\d+$/.test(ts) || Math.abs(Date.now() / 1000 - Number(ts)) > windowS) return false;
const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
const mac = createHmac("sha256", key).update(`${id}.${ts}.`).update(rawBody).digest("base64");
const expected = Buffer.from(`v1,${mac}`);
return (headers["webhook-signature"] ?? "")
.split(" ")
.some((s) => s.length === expected.length && timingSafeEqual(Buffer.from(s), expected));
}
  • Sign the raw body, the bytes as received, before any JSON parsing.
  • webhook-signature may hold several signatures, separated by spaces: accept the request when one matches.
  • Refuse a webhook-timestamp older than your replay window (5 minutes is a good default).

The secret (whsec_…) is created at your workspace’s first callback. Owners and admins rotate it in Gladia Workspace, Settings → Security → Callback signing secret: the new secret is shown once, and the previous one stops signing at once.

Each POST also carries the signature Gladia Connect sent before the Standard Webhooks headers, unchanged, so a receiver written for it keeps working. Prefer the headers above in new code: they carry a message id.

x-gladia-signature: t=<unix seconds>,v1=<hex>

v1 is the hex HMAC-SHA256, keyed with the whole secret string (whsec_ included), of <t>. followed by the raw request body. To verify it: split the header on ,, compute HMAC-SHA256(secret, "<t>." + raw body), compare it with v1 in constant time, and refuse a t older than your replay window.

import hashlib, hmac, time
def verify_legacy(secret: str, header: str, raw_body: bytes, window_s: int = 300) -> bool:
parts = dict(p.split("=", 1) for p in header.split(","))
t, v1 = parts.get("t", ""), parts.get("v1", "")
if not t.isdigit() or abs(time.time() - int(t)) > window_s:
return False
expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, v1)
import { createHmac, timingSafeEqual } from "node:crypto";
export function verifyLegacy(secret, header, rawBody, windowS = 300) {
const parts = Object.fromEntries(header.split(",").map((p) => p.split("=", 2)));
if (!/^\d+$/.test(parts.t ?? "") || Math.abs(Date.now() / 1000 - Number(parts.t)) > windowS) return false;
const expected = createHmac("sha256", secret).update(`${parts.t}.`).update(rawBody).digest("hex");
return expected.length === parts.v1?.length && timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
}
  • Messages are sent in order, one at a time per connection; a slow or failing receiver never slows the session.
  • Network errors and 5xx answers are retried, 3 attempts in all with a growing delay; 4xx answers are not.
  • Each POST times out after 5 seconds.
  • After a session ends, its remaining messages are delivered for up to 30 seconds.
  • Up to 1,024 messages wait per connection; beyond, messages are dropped.
  • After a reconnection, messages of the old and new connections may interleave: order them by the utterance id.

Answer 2xx quickly and process the message afterwards.

A receiver written for Gladia’s cloud API reads these callbacks unchanged: the same POST, the same application/json body {id, event, payload}, the same live.<type> events, the same messages in payload and the same callback_config flags and defaults. What differs:

Gladia’s cloud API Gladia Connect
Signature none the Standard Webhooks headers (webhook-id, webhook-timestamp, webhook-signature, and their svix-* copies) and x-gladia-signature on every POST (verify it); a receiver that ignores them still works
Retries up to 10 attempts, 1 second apart, 4xx answers included, for up to 5 minutes 3 attempts with a growing delay, network errors and 5xx only
Time to answer up to 5 minutes per POST 5 seconds per POST: answer first, process afterwards
live.post_llm_prompts, live.post_diarization, live.emotion_analysis sent when the add-on runs not sent: these add-ons do not run on live sessions here
Account webhooks (live.start_session, live.start_recording, live.end_recording, live.end_session sent to the account’s webhook endpoints, with the session id only) yes yes, on the Enterprise plan where your cluster offers them, per workspace (Account webhooks); else set callback_config on each session, with receive_lifecycle_events
A failed live.translation error set, data: null error set, data kept (which final, which languages) with translated_utterance: null: check error first
Extensions live.session_config, live.speculation

translation messages always carry strings in utterance_id, original_language and target_language, as on the cloud API: utterance_id is empty when the final is no longer known (a long session’s oldest finals).