Media Webhooks
Session, participant, track, ingest and recording events pushed to your backend, signed with Standard Webhooks.
Beam pushes what happens in a project's sessions to HTTPS endpoints you register: when a session starts and ends, who joins and leaves, which tracks are published, when an encoder connects, and when a recording is ready.
beam media webhook create mprj_... --url https://your-backend.example/beam/media \
--events session.started,session.ended,participant.joined,participant.leftOr POST /v1/media/projects/{project_id}/webhooks with {url, events}. The
response holds the signing secret (whsec_…) once; keep it in your
backend's secret store.
Delivery
Each event is a POST with Content-Type: application/json, following
Standard Webhooks (symmetric, v1):
webhook-id: evt_01hz8k3m4n5p6q7r8s9t0v1w2x
webhook-timestamp: 1798761600
webhook-signature: v1,<base64 HMAC-SHA256(secret bytes, "<webhook-id>.<webhook-timestamp>.<raw body>")>- Answer
2xxwithin 10 seconds. Otherwise Beam retries after 10 s, 1 min, 10 min, 1 h and 6 h, then drops the delivery; an endpoint failing for 3 days is disabled. - Delivery is at least once: deduplicate on
webhook-id. - During a secret rotation,
webhook-signaturelists onev1,<signature>per active secret, separated by spaces; accept any of them.
Verify a delivery
The secret is whsec_ followed by standard base64 of 32 bytes: the HMAC key is
the decoded bytes. Compare in constant time, and refuse timestamps more than 300
seconds from your clock:
import { createHmac, timingSafeEqual } from "node:crypto";
export function verifyMediaWebhook(secret, headers, rawBody) {
const id = headers["webhook-id"], timestamp = headers["webhook-timestamp"];
if (!id || !/^\d+$/.test(timestamp ?? "") || Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
if (!secret.startsWith("whsec_")) throw new Error("not a Beam webhook secret (whsec_…)");
const key = Buffer.from(secret.slice("whsec_".length), "base64");
const expected = createHmac("sha256", key).update(`${id}.${timestamp}.`).update(rawBody).digest();
return (headers["webhook-signature"] ?? "").split(" ").some((entry) => {
const [version, signature] = entry.split(",");
const given = Buffer.from(signature ?? "", "base64");
return version === "v1" && given.length === expected.length && timingSafeEqual(given, expected);
});
}Verify the raw bytes you received, before parsing them. The server SDKs do all
of this: verifyMediaWebhook and createMediaWebhookHandler in
@beam-network/web-sdk-server/media, verify_media_webhook in
beam_network_sdk.media.
Body
{
"id": "evt_01hz8k3m4n5p6q7r8s9t0v1w2x",
"type": "participant.joined",
"created_at": "2027-01-01T00:00:00Z",
"project_id": "mprj_...",
"data": { "session_id": "msn_...", "participant_id": "p_7Q2x…", "identity": "user-42", "role": "publish", "node_id": "sfu-1" }
}Events
| Event | data |
|---|---|
session.started | {session_id, delivery_profile, started_at} |
session.ended | {session_id, ended_at, reason: "deleted" | "idle" | "project_deleted"} |
participant.joined | {session_id, participant_id, identity, role, node_id} |
participant.left | {session_id, participant_id, identity, reason} |
track.published | {session_id, participant_id, identity, track_id, kind, source} |
track.unpublished | {session_id, participant_id, track_id} |
ingest.connected | {session_id, stream_key_id, protocol: "whip" | "rtmp" | "rtmps" | "srt", node_id} |
ingest.disconnected | {session_id, stream_key_id, reason: "ended" | "revoked" | "timeout" | "replaced" | "source_incompatible"} (source_incompatible: a source-ladder broadcast got a stream it cannot copy, see the broadcast quickstart) |
recording.started | {session_id, recording_id} |
recording.ready | {session_id, recording_id, duration_ms, bytes} |
recording.failed | {session_id, recording_id, reason} |
- Every field is present;
stream_key_idisnullwhen a WHIP publisher used a token instead of a stream key. participant.leftreasons:left,kicked,timeout,token_revoked,token_expired,moved.- A participant is one identity:
participant.joinedfires for an identity's first connection on any Worker of the session, andparticipant.leftafter its last one has left, so listeners served by relays in several regions count once. - Beam's own quality auditors never produce webhooks.
Media API Reference
Every Media API route: projects, signing keys, tokens, sessions, topology, participants, stream keys, recordings, usage, the directory join and QoE beacons.
Room Media Channels
Media channels of a Room: secure defaults, settings, member tokens and their client identities, guests through a token audience, recordings and the Studio routes.