Playground key
create a key →

API reference

Access tokens.

Tokens are short-lived (15 min) credentials that let a browser or device connect directly to the DroidHub media edge. There are two minting paths: your backend mints end-user tokens (viewer / controller) with an API key, and devices exchange their stream key for camera / robot tokens.

Mint an end-user token

Your backend calls this for each viewer or controller, then hands the returned token and url to that user's browser to connect with livekit-client.

BodyTypeDescription
identityrequiredstringParticipant identity, 1–256 chars. Promote this identity to give the connection control. Identities are unique in a room: a second connection with the same one replaces the first.
rolerequired"viewer" | "controller"viewer is watch-only. controller requires this identity to already be the assigned controller (else 409, or 409 estopped during an e-stop). Either way, control arrives when the assigned identity joins.
200 response
{
  "token": "eyJhbGciOi…",        // hand to the browser
  "url": "wss://sfu.droidhub.cloud",   // connect to this, don't hardcode it
  "room": "dh_…",
  "expiresInSeconds": 900
}
POST/v1/streams/:id/tokenstokens:mintTry it

Control comes from the assignment, not the token

No token carries control. DroidHub grants it to the assigned identity when that identity is connected, and takes it back the moment control moves on. The typical flow: mint viewer tokens for everyone, then promote one identity. Connected viewers upgrade to control live, no reconnect.

Device token exchange

Authenticated by the stream key, not an API key: the key is the credential, so this endpoint takes no Authorization header. A camera or robot presents its dh_sk_… key and gets a token for its room. A stream takes up to eight cameras, each under its own camera name. A ninth gets 409 too_many_cameras, and is removed from the room if it connects with a token issued earlier.

BodyTypeDescription
streamKeyrequiredstringThe stream's dh_sk_… key.
rolerequired"camera" | "robot" | "operator"camera publishes video; robot receives control and publishes telemetry; operator publishes a person's webcam and mic over WebRTC only, so the stream does not go live and nothing is recorded. During an e-stop, camera tokens can't send data.
identitystringOptional participant identity. Defaults to <role>_<streamId>, and to camera_<streamId>_<camera> for a named camera. A new connection under the same identity replaces the old one.
camerastringCameras: the name within the stream, such as front or arm (lowercase letters, digits, - and _, starting with a letter or digit, up to 32). Without it the camera is main. The stream's hls setting decides whether it's recorded.
orientation"portrait" | "landscape"Cameras: which way the picture is turned. The HLS recording sizes its canvas to match, so a portrait phone is delivered as 720×1280 rather than cropped to a landscape strip. Without it the published track's dimensions decide.
POST/v1/streams/tokenstream keyTry it

Browser test publisher

Want to see a camera go live without wiring up hardware? The test publisher runs this exact exchange from your webcam.

Connecting with the token

Hand token and url to livekit-client in the browser:

browser.ts
import { Room, RoomEvent } from "livekit-client";

const room = new Room();
await room.connect(url, token); // from POST /v1/streams/:id/tokens

room.on(RoomEvent.TrackSubscribed, (track) => {
  if (track.kind === "video") el.appendChild(track.attach());
});

// Fires when your backend promotes this user to controller.
room.on(RoomEvent.ParticipantPermissionsChanged, () => {
  setCanDrive(room.localParticipant.permissions?.canPublishData ?? false);
});

See the control-queue recipe for the full viewer-to-controller flow, including high-rate input and RPC commands.