Skip to content

API Endpoints

Complete reference for all HTTP API endpoints.

Authentication

The system supports two authentication methods, tried in order of priority:

1. Bearer Token

http
Authorization: Bearer <token>

2. X-Auth-Token Header

http
X-Auth-Token: <token>

Authentication Priority

  1. Room-level Token (ROOM_TOKENS)
  2. Global Token (AUTH_TOKEN)
  3. JWT (JWT_SECRET)
  4. No authentication (when not configured)

Streaming Endpoints

WHIP Publish

Publish media stream to a specified room.

http
POST /api/whip/publish/{room}
Content-Type: application/sdp
Authorization: Bearer <token>

Parameters

ParameterLocationTypeRequiredDescription
roompathstringYesRoom name, matches ^[A-Za-z0-9_-]{1,64}$

Request Body: SDP Offer (text/plain)

Response

Status CodeDescription
201Success, returns SDP Answer
400Invalid SDP or room name
401Authentication failed
409Room already has a publisher
429Rate limit exceeded
bash
curl -X POST "http://localhost:8080/api/whip/publish/demo" \
  -H "Content-Type: application/sdp" \
  -H "Authorization: Bearer mytoken" \
  --data-binary @offer.sdp

WHEP Play

Subscribe to media stream from a specified room.

http
POST /api/whep/play/{room}
Content-Type: application/sdp
Authorization: Bearer <token>

Parameters

ParameterLocationTypeRequiredDescription
roompathstringYesRoom name

Request Body: SDP Offer (text/plain)

Response

Status CodeDescription
201Success, returns SDP Answer
400Invalid SDP or room name
401Authentication failed
403Subscriber limit reached (MAX_SUBS_PER_ROOM)
404No active publisher in room
429Rate limit exceeded
bash
curl -X POST "http://localhost:8080/api/whep/play/demo" \
  -H "Content-Type: application/sdp" \
  -H "Authorization: Bearer mytoken" \
  --data-binary @offer.sdp

Query Endpoints

Get Bootstrap Configuration

Returns runtime configuration required by the frontend application.

http
GET /api/bootstrap

Response

json
{
  "authEnabled": true,
  "recordEnabled": true,
  "iceServers": [
    {
      "urls": ["stun:stun.l.google.com:19302"]
    }
  ],
  "features": {
    "rooms": true,
    "records": true
  }
}

Get Room List

Returns all active rooms and their status.

http
GET /api/rooms

Response

json
[
  {
    "name": "demo",
    "hasPublisher": true,
    "tracks": 2,
    "subscribers": 5
  }
]

Get Recording List

Returns metadata for all recording files.

http
GET /api/records

Response

json
[
  {
    "name": "demo_video0_1710123456.ivf",
    "size": 1048576,
    "modTime": "2024-03-10T12:34:56Z",
    "url": "/records/demo_video0_1710123456.ivf"
  }
]

Admin Endpoints

Close Room

Forcefully close a specified room, disconnecting all connections.

http
POST /api/admin/rooms/{room}/close
Authorization: Bearer <admin-token>

Response

Status CodeDescription
200Successfully closed
401Authentication failed (requires Admin Token)
404Room not found

Health and Metrics

Health Check

http
GET /healthz

Returns ok with status code 200.

Prometheus Metrics

http
GET /metrics
Metric NameTypeLabelsDescription
live_roomsGauge-Active room count
live_subscribersGaugeVecroomSubscribers per room
live_rtp_bytes_totalCounterVecroomTotal RTP bytes
live_rtp_packets_totalCounterVecroomTotal RTP packets

Error Responses

Domain-specific WHIP/WHEP errors use this JSON format:

json
{
  "error": "Error description"
}

Common Error Codes

Status CodeError MessageReason
400invalid room nameInvalid room name format
400invalid SDPInvalid SDP format
401unauthorizedAuthentication failed or not provided
403subscriber limit reachedMAX_SUBS_PER_ROOM limit hit
404no active publisher in roomNo publisher in room
409publisher already exists in this roomRoom already has a publisher
429too many requestsRate limit triggered
500internal server errorInternal server error

Request Limits

LimitValueConfiguration
SDP request body size1 MBHardcoded
Room name length1-64 charactersRegex ^[A-Za-z0-9_-]{1,64}$
Request rateConfigurableRATE_LIMIT_RPS, RATE_LIMIT_BURST
Subscribers per roomConfigurableMAX_SUBS_PER_ROOM

CORS Configuration

All API responses include CORS headers:

http
Access-Control-Allow-Origin: <ALLOWED_ORIGIN>
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization, X-Auth-Token

Released under the MIT License.