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. Theactive 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
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.
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
- 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
txHashin 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
Authentication
The endpoint accepts two forms of authentication, checked in this order:- Session token — pass the
accessTokenreturned byPOST /api/basefm/streamsas asessionTokenquery parameter or anx-basefm-sessionheader. - 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
active: false with a "Session expired." message.
Errors
End session
Query parameters
Headers
Response
success: true with "message": "No session".
Errors
Stream status
Query parameters
Headers
Response — active session
Response — no active session
Errors
Sync stream status
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
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"withnote: "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"withnote: null.
List relay destinations
Response
Errors
Create or update relay destination
Request body
Response
Errors
Probe relay destination
Path parameters
Response
Errors
Generate video
Request body
Response
Errors
Mux webhooks
Headers
Signature verification
The endpoint performs the following checks:- Rejects requests missing the
mux-signatureheader (401) - Rejects requests with a timestamp older than 5 minutes to prevent replay attacks (
403) - Computes HMAC-SHA256 over
<timestamp>.<body>using the signing secret - Performs a timing-safe comparison of the computed signature against the provided signature (
403on 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.