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.
- Node.js
- Go
// 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);
// 1. Build the playback credential (local, no network call).
play, err := client.WHEP.Create(roomID, videosdk.CreateWhepParams{
Source: &videosdk.WhepSource{ParticipantID: "presenter"},
})
// 2. POST your SDP offer to the WHEP URL and read back the SDP answer.
req, _ := http.NewRequest("POST", play.URL, strings.NewReader(sdpOffer))
req.Header.Set("Content-Type", "application/sdp")
req.Header.Set("Authorization", play.Token)
resp, _ := http.DefaultClient.Do(req)
answer, _ := io.ReadAll(resp.Body) // SDP answer, apply it to start receiving media
// 3. Tear down when finished.
client.WHEP.Delete(ctx, *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).
| Field | Type | Description |
|---|---|---|
url | string | WHEP endpoint. POST your SDP offer here. |
token | string | Token authorizing the pull. Sensitive and short-lived. |
roomId | string | Room being pulled from. |
participantId | string | The subscriber's own participant id. |
remotePeerId | string | Remote participant being pulled, when a source was given. |
Got a Question? Ask us on discord

