Docs
Node SDK

turn.createCredentials

Create temporary STUN/TURN ICE server credentials.

Import and client

TypeScript
import { RelayServer } from '@relayrtc/node'
 
const relay = new RelayServer({
  apiUrl: process.env.RELAYRTC_API_URL!,
  apiKey: process.env.RELAYRTC_SECRET_KEY!,
})

Requirements

A secret key with tokens:create. The requested resource must belong to that key's project environment.

Parameters

OptionTypeDefault / requirementPurpose
roomIdstringOptional with sessionIdRoom of the active session.
sessionIdstringOptional with roomIdActive participant session.

Every method accepts RequestOptions as its final argument.

Example

TypeScript
const roomId = 'room_example'
const sessionId = 'session_example'
const result = await relay.turn.createCredentials({ roomId, sessionId })

Returns

Promise<TurnCredentials>. Returns TURN credentials. URLs, username, lifetime and password depend on the deployment.

Behavior

Supply both IDs for session-bound credentials or send {} for environment-scoped credentials. A browser joining through the SDK receives initial TURN credentials from signaling. Keep the secret API key on the backend when renewing them.

REST equivalent

POST /v1/turn/credentials. Failures throw RelayApiError.