Types
Public request, response and configuration types exported by the Node SDK.
On this page
Import
import type { CreateRoomInput, ParticipantPermission, Room } from '@relayrtc/node'
const input: CreateRoomInput = { name: 'Team call', maxParticipants: 10 }
const permissions: readonly ParticipantPermission[] = ['room:join', 'audio:publish']
function roomLabel(room: Room) {
return room.name
}Types are exported from the package root. Validation rules and defaults are listed on each method page. A type describes the shape; the API still validates the request.
JsonValue
A JSON value accepted in metadata or event data.
export type JsonValue = string | number | boolean | null | JsonObject | readonly JsonValue[]JsonObject
A JSON object with string keys.
export interface JsonObject { readonly [key: string]: JsonValue }RetryOptions
Retry settings for GET requests. Defaults and bounds are in Request options.
export interface RetryOptions {
readonly maxAttempts?: number
readonly initialDelayMs?: number
readonly maxDelayMs?: number
}RelayServerOptions
Constructor settings. See RelayServer for defaults and URL rules.
export interface RelayServerOptions {
readonly apiUrl: string
readonly apiKey: string
readonly timeoutMs?: number
readonly retry?: false | RetryOptions
readonly maxResponseBytes?: number
readonly fetch?: typeof globalThis.fetch
}RequestOptions
Overrides for one request. See Request options.
export interface RequestOptions {
readonly idempotencyKey?: string
readonly signal?: AbortSignal
readonly timeoutMs?: number
readonly retry?: false
}ApiContext
The project, environment and scopes of the configured key.
export interface ApiContext {
readonly apiVersion: string
readonly projectId: string
readonly environmentId: string
readonly keyId: string
readonly keyType: 'publishable' | 'secret'
readonly scopes: readonly string[]
}RoomStatus
The stored lifecycle of a room.
export type RoomStatus = 'created' | 'active' | 'ending' | 'ended' | 'failed'Room
The REST room record. This is different from a browser Room object.
export interface Room {
readonly id: string
readonly projectId: string
readonly environmentId: string
readonly name: string
readonly metadata: JsonObject
readonly status: RoomStatus
readonly maxParticipants: number
readonly createdAt: string
readonly startedAt: string | null
readonly endedAt: string | null
}CursorPage
A page of rooms or participants. When pageInfo.hasNextPage is true, pass pageInfo.endCursor as cursor in the next request.
export interface CursorPage<T> {
readonly nodes: readonly T[]
readonly pageInfo: { readonly endCursor: string | null; readonly hasNextPage: boolean }
}CreateRoomInput
The body for rooms.create.
export interface CreateRoomInput {
readonly name: string
readonly metadata?: JsonObject
readonly maxParticipants?: number
}ListRoomsQuery
Room list filters and cursor pagination.
export interface ListRoomsQuery {
readonly cursor?: string
readonly limit?: number
readonly status?: RoomStatus
readonly search?: string
readonly joinable?: boolean
}RuntimeOperation
The status of asynchronous runtime cleanup.
export interface RuntimeOperation {
readonly id: string
readonly kind: string
readonly status: 'pending' | 'running' | 'failed' | 'completed'
readonly attempts: number
readonly lastError: string | null
readonly completedAt: string | null
readonly [key: string]: unknown
}CleanupResult
A completed cleanup or a pending operation returned by rooms.end and participants.remove.
export type CleanupResult =
| { readonly status: 'completed'; readonly httpStatus: 204 }
| { readonly status: 'pending'; readonly httpStatus: 202; readonly operation: RuntimeOperation }ParticipantPermission
Capabilities granted by a participant token.
export type ParticipantPermission = typeof participantPermissions[number]CreateParticipantTokenInput
Participant identity, token lifetime and permissions.
export interface CreateParticipantTokenInput {
readonly participantName: string
readonly permissions?: readonly ParticipantPermission[]
readonly metadata?: JsonObject
readonly ttlSeconds?: number
}RenewParticipantTokenInput
The body for tokens.renew. The token and session must identify the caller's existing active participant; renewal cannot change their identity or permissions.
export interface RenewParticipantTokenInput {
readonly participantToken: string
readonly sessionId: string
readonly ttlSeconds?: number
}ParticipantToken
A newly issued participant token and its identity.
export interface ParticipantToken {
readonly token: string
readonly participantId: string
readonly tokenId: string
readonly expiresAt: string
}Participant
A participant record returned by room participant endpoints.
export interface Participant {
readonly id: string
readonly roomId: string
readonly externalId: string | null
readonly name: string
readonly metadata: JsonObject
readonly role: string
readonly joinedAt: string
readonly leftAt: string | null
}ListParticipantsQuery
Participant list filters and cursor pagination.
export interface ListParticipantsQuery {
readonly cursor?: string
readonly limit?: number
readonly status?: 'active' | 'left'
}CreateTurnCredentialsInput
Optional allocation scope. Provide roomId and sessionId together. Include participantId to require that session's participant to match a trusted backend identity. See turn.createCredentials.
export type CreateTurnCredentialsInput =
| { readonly roomId: string; readonly sessionId: string; readonly participantId?: string }
| { readonly roomId?: never; readonly sessionId?: never; readonly participantId?: never }TurnCredentials
Short-lived ICE configuration for TURN.
export interface TurnCredentials {
readonly expiresAt: string
readonly username: string
readonly ttlSeconds: number
readonly iceServers: readonly {
readonly urls: readonly string[]
readonly username?: string
readonly credential?: string
readonly credentialType?: 'password'
}[]
}WebhookEventType
An event that a webhook endpoint can subscribe to.
export type WebhookEventType = typeof webhookEventTypes[number]WebhookEndpointStatus
Whether new deliveries can be sent.
export type WebhookEndpointStatus = 'enabled' | 'disabled'WebhookDeliveryStatus
The current delivery state.
export type WebhookDeliveryStatus = 'pending' | 'delivering' | 'succeeded' | 'failed' | 'cancelled'WebhookScopeQuery
Optional project and environment scope. It must match the secret key.
export interface WebhookScopeQuery {
readonly projectId?: string
readonly environmentId?: string
}OffsetQuery
Scope and offset pagination for webhook endpoint lists.
export interface OffsetQuery extends WebhookScopeQuery {
readonly limit?: number
readonly offset?: number
}OffsetPagination
Offset pagination metadata.
export interface OffsetPagination {
readonly limit: number
readonly offset: number
readonly total: number
}CreateWebhookInput
The settings for a new receiver.
export interface CreateWebhookInput {
readonly url: string
readonly eventTypes: readonly WebhookEventType[]
readonly status?: WebhookEndpointStatus
}UpdateWebhookInput
The settings to replace on an existing receiver.
export interface UpdateWebhookInput {
readonly url?: string
readonly eventTypes?: readonly WebhookEventType[]
readonly status?: WebhookEndpointStatus
}WebhookEndpoint
A receiver record without its signing secret.
export interface WebhookEndpoint {
readonly id: string
readonly projectId: string
readonly environmentId: string
readonly url: string
readonly eventTypes: readonly WebhookEventType[]
readonly status: WebhookEndpointStatus
readonly signingSecretVersion: number
readonly signingSecretRotatedAt: string
readonly createdAt: string
readonly updatedAt: string
}RevealedWebhookEndpoint
A receiver returned by creation or rotation, including a signing secret to save securely.
export interface RevealedWebhookEndpoint extends WebhookEndpoint {
readonly signingSecret: string
readonly rotationPolicy: 'immediate replacement'
}WebhookEndpointList
A page of configured receivers.
export interface WebhookEndpointList {
readonly endpoints: readonly WebhookEndpoint[]
readonly pagination: OffsetPagination
}WebhookEvent
The event envelope sent as JSON to a receiver.
export interface WebhookEvent {
readonly id: string
readonly type: WebhookEventType
readonly projectId: string
readonly environmentId: string
readonly occurredAt: string
readonly data: JsonObject
}WebhookDelivery
A delivery record and its latest outcome.
export interface WebhookDelivery {
readonly id: string
readonly endpointId: string
readonly eventId: string
readonly projectId: string
readonly environmentId: string
readonly url: string
readonly status: WebhookDeliveryStatus
readonly attemptCount: number
readonly runAttemptCount: number
readonly replayCount: number
readonly lastError: string | null
readonly nextAttemptAt: string | null
readonly deliveredAt: string | null
readonly runStartedAt: string
readonly createdAt: string
readonly updatedAt: string
}WebhookDeliveryAttempt
One HTTP attempt, including its result.
export interface WebhookDeliveryAttempt {
readonly id: string
readonly attemptNumber: number
readonly replayCount: number
readonly status: 'started' | 'succeeded' | 'failed' | 'abandoned'
readonly signingSecretVersion: number
readonly signatureTimestamp: number
readonly httpStatus: number | null
readonly errorCode: string | null
readonly startedAt: string
readonly finishedAt: string | null
}WebhookDeliveryDetail
The delivery, event, original JSON body and attempt history.
export interface WebhookDeliveryDetail extends WebhookDelivery {
readonly event: WebhookEvent
readonly rawBody: string
readonly attempts: readonly WebhookDeliveryAttempt[]
}WebhookDeliveryList
A page of deliveries.
export interface WebhookDeliveryList {
readonly deliveries: readonly WebhookDelivery[]
readonly pagination: OffsetPagination
}ListWebhookDeliveriesQuery
Filters and pagination for delivery logs.
export interface ListWebhookDeliveriesQuery extends OffsetQuery {
readonly status?: WebhookDeliveryStatus
}ReplayWebhookDeliveryInput
The current replay counter required for an explicit replay.
export interface ReplayWebhookDeliveryInput { readonly expectedReplayCount: number }WebhookSignatureContract
The signature headers and delivery policy reported by the API.
export interface WebhookSignatureContract {
readonly version: 'v1'
readonly algorithm: 'HMAC-SHA256'
readonly signatureHeader: string
readonly deliveryIdHeader: string
readonly replayCountHeader: string
readonly secretVersionHeader: string
readonly signedContent: string
readonly signatureFormat: string
readonly secretEncoding: string
readonly toleranceSeconds: number
readonly attemptsPerRun: number
readonly maximumExplicitReplays: number
readonly backoffSeconds: readonly number[]
readonly maximumRunAgeDays: number
readonly terminalRetentionDays: number
readonly [key: string]: string | number | readonly number[]
}UsageCategory
The usage category to request.
export type UsageCategory = 'all' | 'rooms' | 'participants' | 'sfu' | 'turn' | 'signaling' | 'screen-share' | 'streaming'UsageRange
A preset reporting window.
export type UsageRange = '24h' | '7d' | '14d' | '30d'UsageQuery
A preset or explicit usage window. Do not combine range with startedAt and endedAt.
UsageWindowQuery is an internal helper used by this public type:
type UsageWindowQuery =
| { readonly range?: UsageRange; readonly startedAt?: never; readonly endedAt?: never }
| { readonly range?: never; readonly startedAt: string; readonly endedAt: string }export type UsageQuery = UsageWindowQuery & {
readonly projectId?: string
readonly environmentId?: string
readonly granularity?: 'hour' | 'day'
readonly category?: UsageCategory
}UsageMetric
A supported metric identifier.
export type UsageMetric =
| 'participantSeconds' | 'participantMinutesDerived' | 'audioParticipantSeconds'
| 'videoParticipantSeconds' | 'screenShareSeconds' | 'screenShareIngressBytes'
| 'screenShareEgressBytes' | 'sfuIngressBytes' | 'sfuEgressBytes' | 'turnIngressBytes'
| 'turnEgressBytes' | 'turnRelaySeconds' | 'turnSessions' | 'roomsCreated' | 'roomsStarted'
| 'roomSeconds' | 'averageConcurrentParticipants' | 'peakConcurrentParticipants'
| 'peakConcurrentRooms' | 'signalingConnections' | 'signalingConnectionSeconds'
| 'signalingMessagesIn' | 'signalingMessagesOut'UsageMetrics
All usage metric values.
export type UsageMetrics = Readonly<Partial<Record<UsageMetric, number>>>UsageMetricDefinition
The unit and meaning of one usage metric.
export interface UsageMetricDefinition {
readonly unit: 'seconds' | 'minutes' | 'bytes' | 'count' | 'participants'
readonly aggregation: 'sum' | 'union_seconds' | 'count' | 'peak' | 'time_weighted_average' | 'derived' | 'gauge'
readonly integer: boolean
readonly definition: string
readonly source: string
}UsageResponse
Scoped usage totals, buckets and data quality. See Usage schema.
export interface UsageResponse {
readonly scope: { readonly organizationId: string; readonly projectId: string; readonly environmentId: string }
readonly category: UsageCategory
readonly window: {
readonly range: UsageRange | 'custom'
readonly startedAt: string
readonly endedAt: string
readonly timezone: 'UTC'
readonly endExclusive: true
}
readonly bucketDefinition: {
readonly granularity: 'hour' | 'day'
readonly alignment: 'UTC calendar boundaries'
readonly partialEdges: 'clipped to requested window'
readonly durations: 'lifecycle intervals clipped to each bucket'
readonly events: 'attributed to occurrence time'
}
readonly metricDefinitions: Readonly<Partial<Record<UsageMetric, UsageMetricDefinition>>>
/** Included for all/streaming reports; service measurements are unpriced origin observations. */
readonly serviceUsage?: ServiceUsageReport
readonly summary: UsageMetrics
readonly buckets: readonly { readonly startedAt: string; readonly endedAt: string; readonly metrics: UsageMetrics }[]
readonly dataQuality: {
readonly sessionHistory: 'complete' | 'partial'
readonly messageHistory: 'complete' | 'partial'
readonly turnTraffic: 'unavailable' | 'partial' | 'authoritative'
readonly mediaDurations: 'observation_time'
}
}ServiceUsageReport
Matching SDK builds export ServiceUsageReport and its metric, coverage, definition, resource and project types. UsageResponse.serviceUsage is optional because RTC-only categories do not return this report. See service metrics and coverage.
export interface ServiceUsageReport {
readonly window: {
readonly startedAt: string
readonly endedAt: string
readonly timezone: 'UTC'
readonly endExclusive: true
readonly granularity: 'hour' | 'day'
}
readonly summary: ServiceUsageMetrics
readonly metricDefinitions: Readonly<Record<ServiceUsageMetric, ServiceUsageMetricDefinition>>
readonly rules: Readonly<Record<string, string>>
readonly buckets: readonly {
readonly startedAt: string
readonly endedAt: string
readonly metrics: ServiceUsageMetrics
}[]
readonly coverage: ServiceUsageMetricCoverage
readonly journalStartedAt: string
readonly historicalCoverage: 'complete' | 'partial'
readonly deliveryAuthority: 'origin'
readonly pricing: 'unpriced'
readonly resources: readonly ServiceUsageResource[]
readonly projects: readonly ServiceUsageProject[]
readonly resourceLimit: 100
readonly resourcesTruncated: boolean
}ServiceUsageCoverage is 'observed' | 'estimated' | 'partial' | 'unavailable'. Service metric values are separate from RTC UsageMetrics. They describe observed service quantities with pricing: 'unpriced', not plan allowances or computed charges.
Streaming contracts
Stream and playback types, including CreateIngestCredentialInput, IngestCredentialSummary, IngestCredentialList, RotatedIngestCredential, CreatePlaybackGrantInput and StreamPlaybackReadiness, are described with the stream methods. Install a release that includes these contracts before using them.
Webhook verification types
export type WebhookHeaders = Headers | Readonly<Record<string, string | readonly string[] | undefined>>
export interface WebhookVerificationOptions {
readonly now?: Date
readonly toleranceSeconds?: number
}See verifyWebhookRequest for raw body requirements and timestamp validation.
RelayApiErrorOptions
export interface RelayApiErrorOptions {
readonly status?: number | null
readonly requestId?: string | null
readonly retryable?: boolean
readonly retryAfterMs?: number | null
}See RelayApiError.
Additional public types
The package root also exports the following contracts. Import only the types your application needs. Input contracts describe management requests; result contracts describe returned data. Types do not grant authority or apply server validation.
Streaming
See the streaming contract for field requirements, defaults and errors.
| Export | Contract |
|---|---|
StreamSource | { kind: 'room'; roomId: string; videoTrackIds?: string[]; audioTrackIds?: string[] } | { kind: 'whip' | 'rtmp' } |
StreamProfile | audioOnly, width, height, fps, videoBitrate, audioBitrate, layout. |
CreateStreamInput | name, source, profile, maxDurationSeconds, retentionSeconds. |
UpdateStreamInput | version. |
StreamState | 'ready' | 'starting' | 'live' | 'reconnecting' | 'stopping' | 'ended' | 'failed' |
StreamSession | id, streamId, state, desiredState, generation, attempts, lastError, and additional fields. |
StreamResource | id, organizationId, projectId, environmentId, name, source, profile, and additional fields. |
StreamDetail | sessions. |
StreamListQuery | cursor, limit. |
StreamPage | data, nextCursor. |
IngestCredentialHandover | policy, status, retryAfterSeconds. |
StreamingOperation | id, streamId, kind, broadcastId, outputId, sessionId, status, and additional fields. |
StreamingUsage | streamId, sourceSeconds, ingressBytes, programBytes, coverage, samples. |
Broadcast
See the broadcast contract for field requirements, defaults and errors.
| Export | Contract |
|---|---|
BroadcastState | | "created" | "waiting_for_source" | "starting" | "live" | "reconnecting" | "degraded" | "stopping" | "stopped" | "failed" |
CreateBroadcastInput | streamId, name, destinationIds, outputs, waitTimeoutSeconds, maxDurationSeconds. |
BroadcastCommandInput | version. |
BroadcastResource | id, streamId, organizationId, projectId, environmentId, name, state, and additional fields. |
BroadcastOutput | id, broadcastId, kind, destinationId, destinationName, outputSeconds, bytes, and additional fields. |
BroadcastUsage | bytes, transcodeSeconds, runSeconds, outputSeconds, reservationSeconds, samples, coverage. |
BroadcastDetail | usage. |
ListBroadcastsQuery | cursor, limit, order, activeOnly, streamId, state. |
BroadcastPage | data, nextCursor, limits. |
Destination
See the destination contract for field requirements, defaults and errors.
| Export | Contract |
|---|---|
DestinationProfile | "remux" | "720p" | "1080p" |
StreamDestination | id, streamId, name, host, protocol, port, profile, and additional fields. |
DestinationSnapshot | id, version, credentialVersion, name, profile. |
CreateDestinationInput | name, endpoint, streamKey, profile, enabled. |
UpdateDestinationInput | version, name, endpoint, profile, enabled. |
RotateDestinationSecretInput | version, streamKey. |
DestinationPage | data, nextCursor. |
Recording
See the recording contract for field requirements, defaults and errors.
| Export | Contract |
|---|---|
RecordingPolicy | mode, maxDurationSeconds, retentionSeconds, region, allowPartial, exportMp4, segmentEvents, and additional fields. |
RecordingState | | "queued" | "recording" | "finalizing" | "ready" | "failed" | "deleting" | "deleted" |
RecordingResource | id, streamId, broadcastId, assetId, projectId, environmentId, state, and additional fields. |
MediaAsset | id, recordingId, streamId, broadcastId, state, partial, durationSeconds, and additional fields. |
AssetAccessGrant | assetId, action, url, expiresAt. |
RecordingPlayback | mode, recordingId, assetId, streamId, sourceSessionId, generation, state, and additional fields. |
StartRecordingInput | broadcastId, policy. |
RecordingPage | data, nextCursor. |
Schedule
See the schedule contract for field requirements, defaults and errors.
| Export | Contract |
|---|---|
ScheduleState | | "scheduled" | "starting" | "running" | "ending" | "completed" | "missed" | "failed" | "cancelled" |
ScheduleTiming | startsAt, endsAt, timeZone, sourceWaitSeconds, catchUpSeconds, publisherEarlySeconds, viewerEarlySeconds, and additional fields. |
ScheduledBroadcast | id, streamId, broadcastId, operationId, organizationId, projectId, environmentId, and additional fields. |
ScheduleOperation | id, scheduleId, broadcastId, broadcastOperationId, status, errorCode, createdAt, and additional fields. |
ScheduledPlayback | scheduleId, streamId, broadcastId, state, scheduleState, sourceSessionId, generation, and additional fields. |
CreateScheduleInput | broadcast, timing. |
UpdateScheduleInput | version, timing. |
SchedulePage | data, nextCursor, limits. |
Restream
See the restream contract for field requirements, defaults and errors.
| Export | Contract |
|---|---|
RestreamProtocol | "hls_pull" | "rtmp_push" | "whip_push" |
RestreamState | "created" | "probing" | "ready" | "connecting" | "live" | "recovering" | "stopped" | "failed" |
RestreamSource | id, streamId, projectId, environmentId, name, protocol, host, and additional fields. |
RestreamSession | id, sourceId, kind, state, attempts, fetchedBytes, processingSeconds, and additional fields. |
RestreamDetail | session, health, usage. |
CreateRestreamSourceInput | streamId, name, protocol, endpoint, authorization, redistributionAuthorized, reconnectBudget, and additional fields. |
UpdateRestreamSourceInput | version, name, endpoint, authorization, redistributionAuthorized, reconnectBudget, maxDurationSeconds, and additional fields. |
Clip
See the clip contract for field requirements, defaults and errors.
| Export | Contract |
|---|---|
ClipInterval | | { kind: "last"; seconds: number } | { kind: "media"; startSeconds: number; endSeconds: number } | { kind: "wall"; start: string; end: string } |
CreateClipInput | recordingId, interval, cutMode, retentionSeconds, label. |
ClipResource | id, streamId, broadcastId, sourceRecordingId, recordingId, assetId, label, and additional fields. |
ClipListQuery | cursor, limit. |
ClipPage | data, nextCursor. |
RollingBufferPolicy | enabled, durationSeconds, maxBytes, consentAcknowledged. |
ClipWindow | recordingId, broadcastId, kind, state, startSeconds, endSeconds, wallStart, and additional fields. |
Mixer
See the mixer contract for field requirements, defaults and errors.
| Export | Contract |
|---|---|
MixerSource | id, streamId. |
MixerLayer | sourceId, x, y, width, height, z, fit, and additional fields. |
MixerOverlayLayer | overlayId, x, y, width, height, z, opacity. |
MixerTextLayer | id, text, x, y, width, height, z, and additional fields. |
MixerAudio | sourceId, gainDb, muted. |
MixerScene | name, layout, background, layers, overlays, texts, audio, and additional fields. |
MixerSceneResource | id, mixerId, version, scene. |
MixerOverlay | id, name, width, height, sizeBytes. |
MixerResource | id, broadcastId, streamId, projectId, environmentId, state, version, and additional fields. |
MixerOperation | id, mixerId, kind, revision, status, errorCode, createdAt, and additional fields. |
MixerCommandResult | mixer, operation. |
CreateMixerInput | sources. |
PutMixerSceneInput | version, scene. |
ActivateMixerSceneInput | version, sceneId, sceneVersion. |
CreateMixerOverlayInput | name, contentType, dataBase64. |
Dvr
See the dvr contract for field requirements, defaults and errors.
| Export | Contract |
|---|---|
DvrPolicy | enabled, durationSeconds, maxBytes, endedRetentionSeconds, consentAcknowledged. |
DvrPolicyResource | policy, version, effective. |
DvrPlayback | streamId, broadcastId, windowId, sourceSessionId, generation, state, startSeconds, and additional fields. |
Guest
See the guest contract for field requirements, defaults and errors.
| Export | Contract |
|---|---|
GuestMedia | audio, video, screen. |
GuestRole | "host" | "cohost" | "moderator" | "guest" | "viewer" |
GuestDelegation | "invite" | "approve" | "moderate" |
GuestResource | id, kind, state, version, name, media, mutedAudio, and additional fields. |
GuestStage | enabled, version, maxGuests, occupied, layout, roomId. |
GuestRoster | data, nextCursor, stage. |
GuestJoinGrant | token, participantId, roomId, expiresAt, version, media, signalingUrl. |
GuestDecision | version, subject. |
InviteGuestInput | recipientSubject, media, ttlSeconds. |
RequestGuestInput | subject, media. |
AudienceGrantInput | subject, name, role, delegations, ttlSeconds. |
GuestStageInput | enabled, version, maxGuests, layout. |
Use live streaming to select the relevant workflow. Exact method inputs and results appear on the resource pages; limits and validation remain authoritative on the API.