Quickstart
From zero to a working relay in under five minutes: get an API key, request credentials server-side, paste the returned iceServers into your client, and confirm relay candidates appear.
Get an API key
Sign in to the dashboard, create a project, and copy its API key. The key is a long-lived Bearer token scoped to that one project — it stays on your server.
Request credentials (server-side)
Call the credentials endpoint with your project key. You get back one short-lived username/credential pair and a ready-to-use
iceServersarray.curl# your project key from the dashboard curl -X POST https://api.usebaton.io/v1/credentials \ -H "Authorization: Bearer $BATON_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "ttl": 3600, "region": "eu-central" }'Paste
iceServersinto your clientHand only the returned credential object to the browser — never the API key. The ICE agent picks the best transport that connects.
client.js// fetched from YOUR server, which called Baton with the API key const { iceServers } = await fetch("/api/ice").then(r => r.json()); const pc = new RTCPeerConnection({ iceServers });Verify the relay works
Open
chrome://webrtc-internals(or the Trickle ICE test tool), start a connection, and look for an ICE candidate withtyp relay. If you see one and media flows, you're done. If you only seehost/srflx, jump to Troubleshooting.