RelayrtcDocs
Get started
Documentation
Node SDK

tokens.renew

Renew the token for an existing active participant/session.

On this page

Import and client

Set RELAYRTC_API_URL and RELAYRTC_SECRET_KEY in your backend environment. Keep the secret key on the server.

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

Example

TypeScript
// Inputs come from the authenticated caller's stored participant session.
export async function renewParticipant(roomId: string, currentToken: string, sessionId: string) {
  return relay.tokens.renew(roomId, {
    participantToken: currentToken,
    sessionId,
    ttlSeconds: 600,
  })
}

Requires a scoped secret key with tokens:create. Authenticate the application user, bind them to this participant/session and recheck their room access before calling. Keep current tokens in server-side session storage, not logs. Persist the returned token as the next current credential and return it to the requesting browser. No management key belongs in a browser.

RenewParticipantTokenInput requires participantToken and sessionId. Optional ttlSeconds defaults to 600 (60–3600). Returns Promise<ParticipantToken> with the same participant ID, a new token ID and extended expiry. Identity and permissions come from the verified current token and cannot be changed by this input.

Accepts RequestOptions as the final argument. Errors throw RelayApiError; renewal does not fall back to tokens.create. Expired tokens, removed participants, inactive sessions and denied scope cannot renew. A changed application entitlement must be denied by your backend as well. Streaming guests retain their separate join-grant renewal API.

Wire the result into the browser/React refreshToken callback. See connection recovery and the REST contract. Use compatible API/SDK builds; see installation for package availability.