The WebRTC Bridge replaces the WebRTC Gateway. The gateway endpoint (
wss://webrtc-gateway.<region>.platform.polyai.app/api/v1/webrtc/signal) is retired and does not accept calls. The WebRTC token that you used with the gateway also works with the bridge.Before you start
- A WebRTC token for your project. See Authentication.
- A browser or WebRTC library that supports Unified Plan SDP and renegotiation. Current versions of Chrome, Edge, Firefox and Safari do.
- Permission to use the microphone. Browsers allow
getUserMediaonly on HTTPS pages and onlocalhost.
How a call works
- Provision. Your backend creates the call with your WebRTC token. The bridge returns a call ID, a call token and the ICE servers.
- Connect the microphone. The client sends an SDP offer for its microphone track. The bridge returns the answer.
- Open the events socket. The client opens a WebSocket for call events. It keeps the socket open for the whole call.
- Pull the agent audio. When the peer connection is connected, the client asks for the agent track. The bridge returns a new offer, and the client answers it.
- Hang up. Close the events socket, or send
DELETE /api/v1/call/{callId}.
Time limits
If setup fails at any step, send
DELETE /api/v1/call/{callId}. If you do not, the call holds resources until a time limit ends it.
Call the bridge from your backend
The bridge only accepts cross-origin browser requests from PolyAI origins. A page on your own domain cannot read the bridge’s HTTPS responses. Send every HTTPS request from your backend:POST /api/v1/calluses your WebRTC token. Do not send the WebRTC token to the browser.- The signaling routes (
/sdp,/sdp/pull,/sdp/renegotiate) andDELETEuse the call token. Your backend relays them for the browser. - Authenticate your own users before you provision a call. If you do not, anyone can start calls on your account.
- The WebRTC peer connection, to Cloudflare.
- The events WebSocket, to the bridge. WebSocket connections are not subject to CORS. If your page has a Content Security Policy, add your bridge host from Endpoints to
connect-srcwith thewss://scheme, for examplewss://webrtc-bridge.us-1.platform.polyai.app.
Authentication
Keep the WebRTC token on your server. The call token is safe to give to the browser.
Endpoints
Use the host in the region where your project is deployed.
See the API reference for each route.
Example
This example has two parts: a Node.js backend that relays requests, and the browser code. It usesus-1. Change the host for your region. It is a starting point, not production code.
Backend (Node.js 22 or later, Express 5)
Browser
Load this as a module:<script type="module" src="call.js"></script>. Start it from a click, so that the browser lets the page play audio. To cancel during setup, pass an AbortSignal and abort it.

