turn.createCredentials
Create temporary STUN/TURN ICE server credentials.
Import and client
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
| Option | Type | Default / requirement | Purpose |
|---|---|---|---|
| roomId | string | Optional with sessionId | Room of the active session. |
| sessionId | string | Optional with roomId | Active participant session. |
Every method accepts RequestOptions as its final argument.
Example
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.