RelayrtcDocs
Get started
Documentation
REST API v1

Issue TURN credentials

Create temporary STUN/TURN ICE server credentials.

POST/v1/turn/credentials
On this page

Requirements

A secret API key with tokens:create. Resources are restricted to the key's project and environment.

Request body

NameTypeRequired / defaultDescription
roomIdstringOptional with sessionIdRoom of the active session.
sessionIdstringOptional with roomIdActive participant session.
participantIdstringOptional; requires roomId and sessionIdRequire the session to belong to this participant.

Example

Set RELAYRTC_API_URL to your API base including /v1, such as http://localhost:8080/v1.

Shell
curl -X POST "$RELAYRTC_API_URL/turn/credentials" \
  -H "Authorization: Bearer $RELAYRTC_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"roomId":"room_example","sessionId":"session_example","participantId":"participant_example"}'

Response

201 with TURN credentials. URLs, username, lifetime and password depend on the deployment.

JSON
{
  "expiresAt": "2026-01-01T12:10:00.000Z",
  "username": "issued-turn-username",
  "ttlSeconds": 600,
  "iceServers": [
    {
      "urls": [
        "stun:turn.your-domain.example:3478"
      ]
    },
    {
      "urls": [
        "turn:turn.your-domain.example:3478?transport=udp"
      ],
      "username": "issued-turn-username",
      "credential": "issued-turn-password",
      "credentialType": "password"
    }
  ]
}

Notes

Supply both roomId and sessionId for session-bound credentials or send {} for environment-scoped credentials. The optional participantId adds an ownership match: the active session must belong to that participant in the key's project/environment. Omitting it preserves the existing room/session behavior.

Your backend must authenticate the caller and resolve the expected participant ID from a trusted application session or record. Accepting all three IDs from an unverified request does not establish caller ownership. Use an API build that supports this optional field.

Supply initial browser credentials through turnCredentials or refreshTurnCredentials; they are not automatically supplied by signaling. Keep the secret API key on your backend. See TURN configuration.

Errors

Invalid fields return 400. Invalid credentials return 401; a missing scope returns 403. A missing resource returns 404. See error responses.

Supplying participantId without both room/session IDs returns 400. A session that does not belong to the supplied participant returns 404.