Skip to main content

WHEP

WHEP pulls WebRTC media out of a room. It uses the same local-builder pattern as WHIP. whep.create builds a URL and token with no network call, and your WebRTC client uses them to complete the SDP exchange and start receiving media. An active session in the room is required.

// 1. Build the playback credential (local, no network call).
const play = client.whep.create(roomId, { source: { participantId: "presenter" } });

// 2. POST your SDP offer to the WHEP URL and read back the SDP answer.
const answer = await fetch(play.url, {
method: "POST",
headers: { "Content-Type": "application/sdp", Authorization: play.token },
body: sdpOffer, // the SDP offer from your WebRTC client
}).then((res) => res.text());
// apply `answer` as the remote description to start receiving media

// 3. Tear down when finished.
await client.whep.delete(play);

The SDP offer comes from your WebRTC client. POST it to url with Content-Type: application/sdp and Authorization: <token>, then apply the SDP answer from the response to start receiving media.

Options: participantId, source (which remote peer to pull), expiresIn.

The playback object​

Returned by whep.create (built locally, no network call).

FieldTypeDescription
urlstringWHEP endpoint. POST your SDP offer here.
tokenstringToken authorizing the pull. Sensitive and short-lived.
roomIdstringRoom being pulled from.
participantIdstringThe subscriber's own participant id.
remotePeerIdstringRemote participant being pulled, when a source was given.

Got a Question? Ask us on discord


Was this helpful?