batondocs← SiteSign in
Getting started/Quickstart

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.

  1. 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.

  2. 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 iceServers array.

    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" }'
  3. Paste iceServers into your client

    Hand 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 });
  4. Verify the relay works

    Open chrome://webrtc-internals (or the Trickle ICE test tool), start a connection, and look for an ICE candidate with typ relay. If you see one and media flows, you're done. If you only see host/srflx, jump to Troubleshooting.

What's next