RelayrtcDocs
Get started
Documentation
Node SDK

RelayServer

Configure a server-side management client.

On this page

Import

TypeScript
import { RelayServer } from '@relayrtc/node'

Requirements

Node.js 22 or newer, a configured HTTP(S) API URL and a secret API key. The key must have the scope required by each method.

Constructor options

OptionTypeDefault / requirementPurpose
apiUrlstringRequiredHTTP(S) base URL. /v1 is appended when absent.
apiKeystringRequiredSecret RelayRTC key. Publishable keys are rejected.
timeoutMsinteger10,000Total request deadline, 1–300,000 ms, including retries.
retryfalse or RetryOptionsEnabledGET retries only. false allows one attempt.
retry.maxAttemptsinteger3From 1 to 5, including the initial attempt.
retry.initialDelayMsinteger250From 0 to 30,000 ms.
retry.maxDelayMsinteger2,000From initialDelayMs to 30,000 ms.
maxResponseBytesinteger8 MiBFrom 1 KiB to 32 MiB.
fetchtypeof fetchglobalThis.fetchCustom fetch implementation.

Example

TypeScript
const relay = new RelayServer({
  apiUrl: process.env.RELAYRTC_API_URL!,
  apiKey: process.env.RELAYRTC_SECRET_KEY!,
  timeoutMs: 15000,
  retry: { maxAttempts: 3, initialDelayMs: 250, maxDelayMs: 2000 },
})

URL rules

URLs cannot contain embedded credentials, a query or a fragment. The SDK sends bearer authorization, accepts JSON and rejects redirects.

Retry policy

GET retries cover network errors and HTTP 408, 425, 429 and 5xx. Retry-After is respected within the request deadline. Other errors fail immediately.

Retry-After can contain seconds or an HTTP date. When the required wait would exhaust the deadline, the original HTTP error is returned with its status and retryAfterMs instead of being replaced by a timeout.

Write methods do not retry automatically. Check the resource state after a lost write response before repeating it.