Skip to main content

Streaming API

Endpoints for live video and audio streaming via Mux, DJ session management, video generation, and streaming webhook processing.

Session lifecycle

A DJ session transitions through several statuses during its lifecycle. The active and live statuses are both treated as current sessions — meaning the session is considered in-progress and occupies a streaming slot for the wallet. Endpoints that check for an existing session, end sessions, or authorize session access treat both statuses uniformly.

List live streams

Returns all currently active Mux live streams. No authentication required. The availability field reflects the station state:
  • live — Mux is healthy and at least one DJ is currently broadcasting.
  • idle — Mux is healthy but no DJs are live (for example, after the most recent set ended).
  • degraded — Mux credentials are missing or the Mux API returned an error. The response falls back to cached session data from the database.
When Mux is available, active streams are enriched with metadata from the corresponding DJ session record (matched by stream ID). This means fields like name, wallet, playbackId, and startedAt can resolve from session data even when Mux stream metadata is sparse or missing.

Response

When the response has "availability": "degraded", it may also include an error field with a human-readable description of why the Mux API could not be reached. An "availability": "idle" response is the normal off-air state and does not include an error field.

Errors

When Mux credentials are missing or the Mux API is unreachable, the endpoint returns cached live sessions from the database with "availability": "degraded" and HTTP status 200 (as long as cached data exists). A 500 is only returned when both the Mux API and the session cache are unavailable.

Create live stream

Creates a new Mux live stream. Access is granted if the caller meets any of the following conditions:
  • The wallet holds at least 2,500,000 BASEFM tokens on the Base network, or
  • The caller has an active community guest pass (available to Builder and Whale tier claimed holders via the community program), or
  • The caller pays a $5 USDC session fee on Base by including a verifying txHash in the request
Mux live stream creation only arms the stream — it is not actually live until OBS or ffmpeg connects to the RTMP ingest. Use the Stream status endpoint to confirm ingest is up.
The wallet address used for BASEFM token verification must be a Coinbase Smart Wallet on Base. The platform enforces smartWalletOnly as its connector policy — injected wallets (such as MetaMask) are not supported for DJ streaming.

Request body

Response (200) — new stream

Response (200) — recovery (existing session)

When the authenticated caller already owns a non-expired current session, the endpoint returns the existing stream control payload instead of creating a duplicate stream. This lets DJs recover after a refresh without losing their controls or accidentally creating a new stream.
The deprecated stream.accessGrantedBy, obsSettings, streamType, and playback response fields have been removed. Use the Stream status endpoint to read playback URLs and Mux state during a session.

Errors

When access is granted via a community guest pass (not BASEFM tokens), the stream is created using the caller’s claimed Agentbot wallet address regardless of the wallet value in the request. The stream.wallet and session.wallet fields in the response reflect the claimed wallet.
Before checking for a blocking session, the endpoint automatically ends any expired current sessions for the wallet. This means that if a previous session exceeded the 2-hour maximum but was never explicitly stopped, it is cleaned up and the caller can start a new stream without manual intervention.
Admin cooldown bypass: When the request is made by an authenticated user whose email is on the platform admin allowlist, the 24-hour post-session cooldown is skipped. This lets admins run same-day stream tests. The bypass is tied to the authenticated session — it cannot be triggered from the request body or query parameters. All other access checks (BASEFM token balance, community guest pass, or USDC payment) still apply, and normal DJs remain rate-limited by the cooldown.

Check session status

Returns the active DJ session for the authenticated caller. Authentication is resolved from either a session token or a user session (see authentication below).

Authentication

The endpoint accepts two forms of authentication, checked in this order:
  1. Session token — pass the accessToken returned by POST /api/basefm/streams as a sessionToken query parameter or an x-basefm-session header.
  2. User session — a standard authenticated session (cookie-based). The endpoint looks up the most recent active session for the authenticated user.

Query parameters

Headers

Response — active session

Response — no active session

If the session has expired (exceeded the 2-hour maximum), it is automatically ended and the response returns active: false with a "Session expired." message.

Errors

The wallet query parameter is no longer used. Session lookup is now based on the authenticated caller (session token or user session). Requests using the old ?wallet= parameter are ignored — you must provide authentication instead.

End session

Ends the authenticated caller’s current DJ session and retires the corresponding Mux live stream. Replay assets are deleted by default to avoid ongoing storage costs. Uses the same authentication as the check session endpoint (session token or user session).

Query parameters

Headers

Response

If no active session exists, the endpoint still returns success: true with "message": "No session".
Deprecated: The archive request body field and the ended, muxStopped, archived, archiveCreditCost, deletedAssetIds, and retainedAssetIds response fields are no longer returned. The DJ archive flow is currently unavailable through this endpoint — replay assets are always cleaned up when a session ends.

Errors

The wallet query parameter is no longer used. Session lookup is now based on the authenticated caller (session token or user session). Requests using the old ?wallet= parameter are ignored — you must provide authentication instead.

Stream status

Returns detailed stream health information for the authenticated caller’s active session, including the real-time Mux stream status, distribution state, and a health assessment. Uses the same authentication as the check session and end session endpoints.

Query parameters

Headers

Response — active session

Response — no active session

Errors

Sync stream status

Manually syncs the DJ session status with the Mux stream. If the Mux stream is active, the session is transitioned to live and the playback ID is updated. Uses the same authentication as the other session endpoints.

Query parameters

Headers

Response — synced

Response — not yet active

Errors

Get distribution state

Returns the current distribution state for the baseFM station, including the origin stream health, first-party page status, and relay destination statuses. No authentication required. The distribution.origin.status field reflects the live origin state:
  • active — Mux is healthy and a DJ is currently broadcasting.
  • idle — Mux is healthy but no DJ is live (for example, after a set ended). This is the normal off-air state and does not indicate a problem.
  • degraded — Mux credentials are missing or the Mux API returned an error. The response falls back to cached session data.

Response

Errors

When Mux credentials are missing or the Mux API is unreachable, the endpoint returns a degraded distribution state based on cached session data with HTTP status 200 (as long as cached data exists). A 500 is only returned when both the Mux API and the session cache are unavailable.

Relay playback verification

When building the distribution state, the platform verifies that each relay destination is serving the current Agentbot playback ID. For relays with a configured probe URL, the platform fetches the relay’s live API and checks whether any of the returned streams include the current Mux playback ID.
  • If the relay’s live API returns a stale or mismatched playback ID, the relay is marked status: "degraded" with note: "Relay live API is not serving the current Agentbot playback id."
  • If the relay’s live API includes the current playback ID, the relay stays status: "healthy" with note: null.
This verification ensures that downstream consumers (such as basefm.space) are actually serving the same stream that Agentbot is broadcasting, and prevents the distribution state from reporting a relay as healthy when its content is stale.

List relay destinations

Returns all configured relay destinations for the baseFM station. No authentication required. Default relay destinations are created automatically if they do not exist.

Response

See the distribution endpoint for full field descriptions of relay objects.

Errors

Create or update relay destination

Creates a new relay destination or updates an existing one. Requires admin session authentication.

Request body

Response

Errors

Probe relay destination

Runs a health check against a relay destination’s probe URL and updates the relay’s health status in the database. Requires admin session authentication.

Path parameters

Response

Errors

Generate video

Generates a video and uploads it to blob storage. Requires session authentication. This endpoint has a 5-minute timeout.

Request body

Response

Errors

Mux webhooks

Receives and processes Mux webhook events. This endpoint verifies the request signature using HMAC-SHA256 and rejects unsigned, expired, or tampered requests.
This endpoint is intended to be called by Mux only. You must configure the MUX_SIGNING_SECRET (or MUX_WEBHOOK_SECRET) environment variable for signature verification. When the signing secret is not configured, all requests are rejected.

Headers

Signature verification

The endpoint performs the following checks:
  1. Rejects requests missing the mux-signature header (401)
  2. Rejects requests with a timestamp older than 5 minutes to prevent replay attacks (403)
  3. Computes HMAC-SHA256 over <timestamp>.<body> using the signing secret
  4. Performs a timing-safe comparison of the computed signature against the provided signature (403 on mismatch)

Handled event types

The webhook handler now syncs DJ session state to the database when live stream events are received. This enables the session cache used by the GET /api/basefm/live endpoint for degraded-mode fallback.

Response

Errors