Media API Reference
Every Media API route: projects, signing keys, tokens, sessions, topology, participants, stream keys, recordings, usage, the directory join and QoE beacons.
The Media API is part of the BeamCore public API, under /v1/media. It
authenticates with an organization API key, as Authorization: Bearer <key> or
X-Api-Key: <key>, and charges media usage to the key's organization. Reads
(GET) need the key's media:read or media:write permission; every change,
token minting and content keys need media:write. A key without them gets
403 forbidden. Two
routes take a media token instead: the directory join and the QoE beacons
(and the content-key license of protected broadcasts).
Conventions:
- JSON fields are
snake_case. Optional fields are listed with?; nullable fields are present withnull. - Ids are a prefix and 26 characters
[0-9a-z]: projectsmprj_, sessionsmsn_, stream keysmsk_, recordingsmrec_, webhook endpointsmwh_. - Resource times are ISO 8601 strings (
created_at); token claims are unix seconds; fields ending_msare unix milliseconds. - Errors are
{"error": "<code>", "detail": "<text>" | null}:invalid_request(400),unknown_field(400, withfield),unauthorized(401),insufficient_credits(402, withcredits_requiredandcredits_available),product_not_priced(402),forbidden(403),not_found(404),conflict(409),rate_limited(429, withretry_after_ms),price_book_unavailable(503, withretry_after_ms: a price the request needs cannot be read yet; temporary, retry after the delay). Token errors are listed in Media Tokens. - Request bodies and query strings are strict: a body key or query parameter
the route does not define is refused with
400 unknown_fieldandfield, the first such key (a dotted path in a body:client,protection.extra,rtt_hints.0.x). Keys match exactly. Branch onerrorandfield, never ondetail. - A refusal with
retry_after_msalso carries aRetry-Afterheader with the same delay in whole seconds (rounded up).
Projects
A project groups sessions, signing keys, a token audience and webhook endpoints.
| Route | Body → response |
|---|---|
POST /v1/media/projects | {name} → project (201) |
GET /v1/media/projects | {projects: [...], next_cursor} |
GET /v1/media/projects/{project_id} | project |
PATCH /v1/media/projects/{project_id} | {name?, token_audience?} → project |
DELETE /v1/media/projects/{project_id} | 204; ends its sessions |
Project: {id, name, token_audience, room_id, created_at}. token_audience is
the aud its tokens carry (default beam-media); a new audience applies to
tokens verified after the sessions' next topology revision. room_id is set on
the project Beam creates for a Room.
Signing keys
| Route | Body → response |
|---|---|
POST /v1/media/projects/{project_id}/keys | {public_key, kid?, label?}, or {managed: true, label?} to rotate the managed key → key (201) |
GET /v1/media/projects/{project_id}/keys | {keys: [...]} |
DELETE /v1/media/projects/{project_id}/keys/{kid} | 204; the key leaves the next topology revision |
Key: {kid, project_id, public_key, label, managed, status: "active" | "revoked", created_at, revoked_at}.
Refusals: invalid_public_key, kid_reserved.
Tokens
POST /v1/media/projects/{project_id}/tokens mints a token with the project's
managed key, for backends that do not sign their own:
{ "session_id": "msn_...", "role": "publish", "identity": "user-42", "name": "Ada", "tracks": ["camera", "microphone"], "ttl_s": 3600 }→ {token, expires_at}. name, tracks, region, meta and ttl_s
(default 3,600, at most 86,400) are optional.
Sessions
| Route | Body → response |
|---|---|
POST /v1/media/sessions | create-session request → session (201) |
GET /v1/media/sessions?project_id=&status=&cursor=&limit= | {sessions: [...], next_cursor} |
GET /v1/media/sessions/{session_id} | session |
DELETE /v1/media/sessions/{session_id} | 204; ends the session, nodes drain |
GET /v1/media/sessions/{session_id}/topology | the current topology document |
GET /v1/media/sessions/{session_id}/participants | {participants: [...]} |
GET /v1/media/sessions/{session_id}/live | live view |
POST /v1/media/sessions/{session_id}/deny | {nonce, exp} or {identity, until} → 204 |
POST /v1/media/sessions/{session_id}/kick | {participant_id} or {identity}, reason? → 204 |
Create-session request:
| Field | Type | Default |
|---|---|---|
project_id | string | required |
delivery_profile | interactive | stage | broadcast | required |
name | string | none |
protection | {mode, key_provider?} | interactive: {mode: "e2ee", key_provider: "customer"}; stage and broadcast: {mode: "public"} |
hls_output | boolean | false; refused with e2ee |
ladder | transcode ladder, or "source" (broadcast only) | the default ladder when transcoding |
recording | {enabled, dvr_window_s?} | disabled; DVR window 7,200 s |
regions | region codes | any |
max_participants | integer | none |
metadata | string, at most 2,048 bytes | none; echoed as is |
start_grace_s | integer, 600 to 604,800 seconds | broadcast only (refused for other profiles): 86,400 (24 h) |
Session: the request's fields plus {id, room, status: "idle" | "live" | "ended", topology_epoch, start_grace_s, created_at, started_at, ended_at} (start_grace_s
is null except on broadcasts). A session is idle until
its first connection, live while any node serves it, and ended after
DELETE or 10 minutes without connections. A broadcast created ahead of
its start (a scheduled event) is not ended while it waits for its encoder: it
stays idle until start_grace_s after its creation, and ends only if nothing
connected by then, so its stream keys stay valid until the encoder goes live.
Once it has connected, the 10-minute rule applies. Calls and stages keep the
10-minute rule from creation. DELETE ends a session at any time.
Ladder: {video: [{rendition_id, codec: "h264" | "h265" | "av1", width, height, fps_max, bitrate_bps, passthrough?}] (at most 8), audio: [{rendition_id, codec: "aac" | "opus", bitrate_bps, channels, sample_rate}] (at most 4), gop_ms}.
Without ladder, a transcoded session uses the environment's default ladder
(1080p60, 720p60, 480p30, 360p30 H.264 and AAC, GPU transcode). Beam never
switches ladders on its own.
Source ladder (ladder: "source", broadcasts only): no GPU anywhere. The
transcode node copies the encoder's H.264 video as one rendition source
(no re-encode, no lower qualities) and converts the audio to AAC on the CPU;
packaging, the CDN, signed segment manifests, protected mode and recordings
are the same as for any ladder. The keyword stands for the default source
ladder, and the session shows that object:
{
"video": [{ "rendition_id": "source", "codec": "h264", "width": 1920, "height": 1080,
"fps_max": 60, "bitrate_bps": 8000000, "passthrough": true }],
"audio": [{ "rendition_id": "audio", "codec": "aac", "bitrate_bps": 128000, "channels": 2, "sample_rate": 48000 }],
"gop_ms": 2000
}width, height and fps_max are the largest source accepted (either
orientation: 1920×1080 and 1080×1920 both fit), bitrate_bps the advertised
peak. For other caps (for example 3840×2160), send such an object instead of
the keyword: exactly one video rendition, rendition_id: "source",
codec: "h264", passthrough: true, and at most one aac audio rendition
(none: the source audio is dropped). passthrough is present only as true,
and the id source is reserved for it. A source ladder for a stage or a call's
HLS output is refused with 400 invalid_request: their transcoder composes a
program from several publishers. The encoder settings it needs are in the
broadcast quickstart.
Participant: {participant_id, identity, name, role, meta, joined_at_ms, connected_node_id}.
Live view: {session_id, status, topology, participants, viewers_by_region: [{region, viewers}], qoe: {stall_ratio_ppm, latency_ms_p50, latency_ms_p95, packet_loss_ppm_p50}, bytes: {ingress, egress}, failures: [{node_id, at_ms, reason}], updated_at_ms}.
Topology
GET …/topology returns the session's media-topology/v1 document: the nodes
Beam placed (sfu, relay, ingest, transcode, package, shield,
edge), their region, state (planned, starting, active, draining),
Worker and endpoints, the links between them, and the keys and deny list
Workers verify tokens with. epoch changes when the tree changes, revision on
every change. It is for display and debugging: your app never connects to a
node from it, only through the directory. beam media session topology prints it
as a tree.
Stream keys
| Route | Body → response |
|---|---|
POST /v1/media/sessions/{session_id}/stream-keys | {label?} → stream key with key (201) |
GET /v1/media/sessions/{session_id}/stream-keys | {stream_keys: [...]}, without key |
POST /v1/media/sessions/{session_id}/stream-keys/{stream_key_id}/rotate | → stream key with a new key; the old one is refused at once |
DELETE /v1/media/sessions/{session_id}/stream-keys/{stream_key_id} | 204; a live encoder using it is disconnected |
Stream key: {id, session_id, label, status, created_at, revoked_at, last_used_at, ingest: {whip_url, rtmp_server_url, rtmps_server_url, srt_url}, key?}. The key
(bsk_ and 43 base64url characters) is returned only by create and rotate; the
srt_url holds it only there (s={stream_key} elsewhere). Ingest ports are
fixed: WHIP 443, RTMP 1935, RTMPS 1936, SRT 9000/udp.
Recordings
| Route | Response |
|---|---|
GET /v1/media/sessions/{session_id}/recordings | {recordings: [...]} |
GET /v1/media/recordings/{recording_id} | recording |
DELETE /v1/media/recordings/{recording_id} | 204 |
Recording: {id, session_id, status: "recording" | "processing" | "ready" | "failed" | "deleted", started_at, ended_at, duration_ms, bytes, created_at}. Play one with a token
whose session is the recording id.
A recording is one recording for players even when the Worker writing it was
replaced during the session: Beam then continues it on another Worker as a new
generation, and playback stitches the generations in order, behind the same
recording id. Nothing changes on the player's side. duration_ms and bytes
are the sums over the generations that finished. A recording holds at most 64
generations; past that, Beam starts a new recording of the session.
Usage
| Route | Response |
|---|---|
GET /v1/media/sessions/{session_id}/usage | {usage: [...]} |
GET /v1/media/usage?project_id=&from=&to= | {usage: [...]} |
Usage row: {project_id, session_id, product, unit, quantity, period_start, period_end}:
verified usage, the values billing charges. Products and units:
| Product | Units |
|---|---|
beam.media.interactive.v1 | participant_minute, gb, ingest_gb, peak_participant |
beam.media.stage.v1 | participant_minute, listener_minute, gb, ingest_gb, peak_participant |
beam.media.broadcast.v1 | viewer_minute, ingest_minute, gb, ingest_gb, peak_viewer |
beam.media.transcode.v1 | rendition_minute: transcode minutes × encoded renditions; a copied passthrough rendition is not encoded, so a source broadcast bills only its audio rendition |
beam.media.recording.v1 | gb_month |
beam.media.vod.v1 | gb, viewer_minute |
gb is media sent to clients and ingest_gb media received from them (1 GB =
10⁹ bytes). A unit a session did not use, or that your environment does not
measure yet, has no row. What each unit measures.
Webhook endpoints
| Route | Body → response |
|---|---|
POST /v1/media/projects/{project_id}/webhooks | {url, events} → endpoint with secret (201) |
GET /v1/media/projects/{project_id}/webhooks | {webhooks: [...]} |
DELETE /v1/media/projects/{project_id}/webhooks/{webhook_id} | 204 |
POST /v1/media/projects/{project_id}/webhooks/{webhook_id}/rotate-secret | → endpoint with the new secret; both secrets sign for 24 h |
Endpoint: {id, project_id, url, events, status: "active" | "disabled", created_at, secret?}.
Events and payloads: Media Webhooks.
Content keys (protected broadcasts)
GET /v1/media/sessions/{session_id}/content-keys(API key) →{keys: [{key_id, key, iv}]}for your backend.POST /v1/media/content-keys(media token): the EME ClearKey license exchange. Body{"kids": ["<base64url key id>"], "type": "temporary"}→{"keys": [{"kty": "oct", "kid": "…", "k": "…"}], "type": "temporary"}. Your backend may serve the same contract instead.
Join
POST {BEAM_MEDIA_DIRECTORY_URL}/v1/media/join on the media directory of your environment (from its configuration; there is no default), with Authorization: Bearer <media token>.
The SDKs call it; you only need it for your own client or a third-party player.
{
"schema_version": "media-join/v1",
"transport": "auto",
"rtt_hints": [{ "region": "weur", "rtt_ms": 23 }],
"exclude_node_ids": [],
"client": { "sdk": "beam-web/0.4.0", "platform": "browser" }
}transport is rtc, hls or auto (WebRTC for calls and stages, HLS for
broadcasts and recordings). rtt_hints, exclude_node_ids (nodes that just
failed for this client) and client are optional. The response:
{
"schema_version": "media-join/v1",
"session_id": "msn_...", "project_id": "mprj_...", "delivery_profile": "stage",
"role": "subscribe", "identity": "user-42", "topology_epoch": 3, "expires_at_ms": 1798762200000,
"protection": { "mode": "public", "frame_scheme": null, "key_provider": null, "segment_encryption": null },
"rtc": {
"publish": [],
"subscribe": [{ "node_id": "relay-weur-1", "role": "relay", "region": "weur", "url": "https://…/v1/rtc/msn_.../whep", "rank": 1 }],
"ice_servers": [{ "urls": ["stun:…"], "username": null, "credential": null }]
},
"hls": null,
"beacon": { "url": "https://…/v1/media/beacons", "interval_ms": 10000 }
}rtc.publishlists WHIP endpoints forpublishandadmintokens;rtc.subscribelists ranked WHEP endpoints (rank 1 is best). TURN credentials come from the chosen node:GET /v1/rtc/<session_id>/icewith the same token.hls(broadcasts, recordings, HLS output) is{edges: [ranked endpoints whose url is …/master.m3u8], manifest_keys: [{node_id, session_id, public_key}], content_key_url}. Append?token=<token>to the multivariant playlist URL only; media playlists carry a playback credential the edge adds.- Re-join after
expires_at_ms, after amigrateevent and after a failure, trying the next endpoint of the list first.
Errors: the token errors, invalid_request (400), unknown_field (400, with
field), session_not_found (404),
session_ended (410), topology_pending (503, with retry_after_ms: the first
nodes are starting), no_capacity (503), rate_limited (429),
e2ee_members_only (403), protected_unsupported (409).
QoE beacons
POST <beacon.url> with the media token, every beacon.interval_ms (at most
once per 5 seconds per token) → 204. The SDKs send them; a custom player should
too, since beacons are one of the sources that verify delivery:
{
"schema_version": "beam-media-qoe/v1",
"session_id": "msn_...", "node_id": "edge-weur-1", "transport": "hls",
"period_start_ms": 1798761600000, "period_end_ms": 1798761610000,
"bytes_received": 3750000, "media_ms": 10000, "stalls": 0, "stall_ms": 0,
"rtt_ms": null, "jitter_ms": null, "packet_loss_ppm": null, "latency_ms": 3100,
"frames_decoded": 600, "frames_dropped": 0, "bitrate_bps": 3000000, "rendition_id": "720p",
"edge_switches": 0, "errors": [{ "code": "segment_hash_mismatch", "count": 1 }],
"client": { "sdk": "beam-web/0.4.0", "platform": "browser" }
}