RelayrtcDocs
Get started
Documentation
Node SDK

turn.createCredentials

Create temporary STUN/TURN ICE server credentials.

On this page

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.
participantIdstringOptional; requires roomId and sessionIdRequire the session to belong to this participant.

Every method accepts RequestOptions as its final argument.

Example

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

Resolve participantId from your authenticated application session or a trusted backend record. Do not forward an unverified participant ID from the caller. Omitting it preserves the existing room/session scope without the additional participant match.

Returns

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

Behavior

Supply both roomId and sessionId for session-bound credentials or send {} for environment-scoped credentials. When supplied, participantId must match the participant owning that active session in the key's project/environment. A mismatch returns 404; supplying it without room/session IDs is invalid.

Use matching Node SDK and API builds that support the optional participant check. The check does not replace application authentication or authorize the caller on its own.

Supply initial browser credentials through turnCredentials or fetch them with refreshTurnCredentials. Signaling alone does not supply them automatically. Keep the secret API key on your backend. See TURN configuration.

REST equivalent

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