# Relays ## List relays `client.moq.relays.list(RelayListParamsparams, RequestOptionsoptions?): SinglePage` **get** `/accounts/{account_id}/moq/relays` Lists all MoQ relays for the account. Returns only metadata. Config, status, and tokens are omitted. Results are cursor-paginated (keyset on the `created` timestamp). Use `created_before` / `created_after` with the `created` value of the first/last item in a page to fetch the adjacent page. `result_info` reports the page `count` and the `total` matching the cursor filters. ### Parameters - `params: RelayListParams` - `account_id: string` Path param: Cloudflare account identifier. - `asc?: boolean` Query param: Sort order by `created`. When true, results are returned oldest-first (ascending); otherwise newest-first (descending, the default). - `created_after?: string` Query param: Cursor for pagination. Returns relays created strictly after this RFC 3339 timestamp (typically the `created` value of the last item on the current page, to fetch the next page). - `created_before?: string` Query param: Cursor for pagination. Returns relays created strictly before this RFC 3339 timestamp (typically the `created` value of the first item on the current page, to fetch the previous page). - `per_page?: number` Query param: Maximum number of relays to return per page. ### Returns - `RelayListResponse` Abbreviated relay for list responses. - `created: string` - `modified: string` - `name: string` - `uid: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const relayListResponse of client.moq.relays.list({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', })) { console.log(relayListResponse.uid); } ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "success": true, "result": [ { "created": "2019-12-27T18:11:19.117Z", "modified": "2019-12-27T18:11:19.117Z", "name": "name", "uid": "a1b2c3d4e5f67890a1b2c3d4e5f67890" } ], "result_info": { "count": 0, "total": 0 } } ``` ## Get a relay `client.moq.relays.get(stringrelayId, RelayGetParamsparams, RequestOptionsoptions?): RelayGetResponse` **get** `/accounts/{account_id}/moq/relays/{relay_id}` Retrieves a single MoQ relay including config and status. Tokens are NOT included. ### Parameters - `relayId: string` - `params: RelayGetParams` - `account_id: string` Cloudflare account identifier. ### Returns - `RelayGetResponse` Full relay details (no tokens). - `config: Config` origin_fallback and lingering_subscribe are mutually exclusive. - `lingering_subscribe?: LingeringSubscribe` - `enabled?: boolean` - `max_timeout_ms?: number` Relay-level ceiling on lingering subscribe timeout (ms). Default 30000. - `origin_fallback?: OriginFallback` - `enabled?: boolean` - `origins?: Array` Ordered list of upstream origin relays. Each entry is an object (not a bare string) so per-origin configuration can be added in the future without another breaking change. - `url?: string` Upstream origin relay URL. - `created: string` - `modified: string` - `name: string` - `uid: string` - `status?: "connected"` "connected" when active, omitted otherwise. - `"connected"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const relay = await client.moq.relays.get('a1b2c3d4e5f67890a1b2c3d4e5f67890', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(relay.uid); ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "success": true, "result": { "config": { "lingering_subscribe": { "enabled": true, "max_timeout_ms": 0 }, "origin_fallback": { "enabled": true, "origins": [ { "url": "url" } ] } }, "created": "2019-12-27T18:11:19.117Z", "modified": "2019-12-27T18:11:19.117Z", "name": "Production Live Stream", "uid": "a1b2c3d4e5f67890a1b2c3d4e5f67890", "status": "connected" } } ``` ## Create a relay `client.moq.relays.create(RelayCreateParamsparams, RequestOptionsoptions?): RelayCreateResponse` **post** `/accounts/{account_id}/moq/relays` Provisions a new MoQ relay instance. Auto-creates a publish+subscribe token and a subscribe-only token. Token values are included in the response (shown once). Config is set to defaults (lingering subscribe enabled, 30s ceiling, origin fallback off). Use PUT to modify. ### Parameters - `params: RelayCreateParams` - `account_id: string` Path param: Cloudflare account identifier. - `name: string` Body param: Human-readable name for the relay. ### Returns - `RelayCreateResponse` Relay with auto-generated tokens (shown once). - `config: Config` origin_fallback and lingering_subscribe are mutually exclusive. - `lingering_subscribe?: LingeringSubscribe` - `enabled?: boolean` - `max_timeout_ms?: number` Relay-level ceiling on lingering subscribe timeout (ms). Default 30000. - `origin_fallback?: OriginFallback` - `enabled?: boolean` - `origins?: Array` Ordered list of upstream origin relays. Each entry is an object (not a bare string) so per-origin configuration can be added in the future without another breaking change. - `url?: string` Upstream origin relay URL. - `created: string` - `modified: string` - `name: string` - `token_publish_subscribe: string` Full access token (publish + subscribe). Treat as sensitive. - `token_subscribe: string` Subscribe-only token. Treat as sensitive. - `uid: string` Server-generated unique identifier (32 hex chars). ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const relay = await client.moq.relays.create({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', name: 'Production Live Stream', }); console.log(relay.uid); ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "success": true, "result": { "config": { "lingering_subscribe": { "enabled": true, "max_timeout_ms": 0 }, "origin_fallback": { "enabled": true, "origins": [ { "url": "url" } ] } }, "created": "2019-12-27T18:11:19.117Z", "modified": "2019-12-27T18:11:19.117Z", "name": "Production Live Stream", "token_publish_subscribe": "eyJhbGciOiJFZDI1NTE5...", "token_subscribe": "eyJhbGciOiJFZDI1NTE5...", "uid": "a1b2c3d4e5f67890a1b2c3d4e5f67890" } } ``` ## Update a relay `client.moq.relays.update(stringrelayId, RelayUpdateParamsparams, RequestOptionsoptions?): RelayUpdateResponse` **put** `/accounts/{account_id}/moq/relays/{relay_id}` Updates a relay's name and/or configuration. Partial updates: omitted fields are preserved. Config sub-objects replace as whole objects when present. origin_fallback and lingering_subscribe are mutually exclusive. ### Parameters - `relayId: string` - `params: RelayUpdateParams` - `account_id: string` Path param: Cloudflare account identifier. - `config?: Config` Body param: origin_fallback and lingering_subscribe are mutually exclusive. - `lingering_subscribe?: LingeringSubscribe` - `enabled?: boolean` - `max_timeout_ms?: number` Relay-level ceiling on lingering subscribe timeout (ms). Default 30000. - `origin_fallback?: OriginFallback` - `enabled?: boolean` - `origins?: Array` Ordered list of upstream origin relays. Each entry is an object (not a bare string) so per-origin configuration can be added in the future without another breaking change. - `url?: string` Upstream origin relay URL. - `name?: string` Body param ### Returns - `RelayUpdateResponse` Full relay details (no tokens). - `config: Config` origin_fallback and lingering_subscribe are mutually exclusive. - `lingering_subscribe?: LingeringSubscribe` - `enabled?: boolean` - `max_timeout_ms?: number` Relay-level ceiling on lingering subscribe timeout (ms). Default 30000. - `origin_fallback?: OriginFallback` - `enabled?: boolean` - `origins?: Array` Ordered list of upstream origin relays. Each entry is an object (not a bare string) so per-origin configuration can be added in the future without another breaking change. - `url?: string` Upstream origin relay URL. - `created: string` - `modified: string` - `name: string` - `uid: string` - `status?: "connected"` "connected" when active, omitted otherwise. - `"connected"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const relay = await client.moq.relays.update('a1b2c3d4e5f67890a1b2c3d4e5f67890', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(relay.uid); ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "success": true, "result": { "config": { "lingering_subscribe": { "enabled": true, "max_timeout_ms": 0 }, "origin_fallback": { "enabled": true, "origins": [ { "url": "url" } ] } }, "created": "2019-12-27T18:11:19.117Z", "modified": "2019-12-27T18:11:19.117Z", "name": "Production Live Stream", "uid": "a1b2c3d4e5f67890a1b2c3d4e5f67890", "status": "connected" } } ``` ## Delete a relay `client.moq.relays.delete(stringrelayId, RelayDeleteParamsparams, RequestOptionsoptions?): RelayDeleteResponse | null` **delete** `/accounts/{account_id}/moq/relays/{relay_id}` Soft-deletes a MoQ relay. ### Parameters - `relayId: string` - `params: RelayDeleteParams` - `account_id: string` Cloudflare account identifier. ### Returns - `RelayDeleteResponse = unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const relay = await client.moq.relays.delete('a1b2c3d4e5f67890a1b2c3d4e5f67890', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(relay); ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "success": true, "result": {} } ``` ## Domain Types ### Relay List Response - `RelayListResponse` Abbreviated relay for list responses. - `created: string` - `modified: string` - `name: string` - `uid: string` ### Relay Get Response - `RelayGetResponse` Full relay details (no tokens). - `config: Config` origin_fallback and lingering_subscribe are mutually exclusive. - `lingering_subscribe?: LingeringSubscribe` - `enabled?: boolean` - `max_timeout_ms?: number` Relay-level ceiling on lingering subscribe timeout (ms). Default 30000. - `origin_fallback?: OriginFallback` - `enabled?: boolean` - `origins?: Array` Ordered list of upstream origin relays. Each entry is an object (not a bare string) so per-origin configuration can be added in the future without another breaking change. - `url?: string` Upstream origin relay URL. - `created: string` - `modified: string` - `name: string` - `uid: string` - `status?: "connected"` "connected" when active, omitted otherwise. - `"connected"` ### Relay Create Response - `RelayCreateResponse` Relay with auto-generated tokens (shown once). - `config: Config` origin_fallback and lingering_subscribe are mutually exclusive. - `lingering_subscribe?: LingeringSubscribe` - `enabled?: boolean` - `max_timeout_ms?: number` Relay-level ceiling on lingering subscribe timeout (ms). Default 30000. - `origin_fallback?: OriginFallback` - `enabled?: boolean` - `origins?: Array` Ordered list of upstream origin relays. Each entry is an object (not a bare string) so per-origin configuration can be added in the future without another breaking change. - `url?: string` Upstream origin relay URL. - `created: string` - `modified: string` - `name: string` - `token_publish_subscribe: string` Full access token (publish + subscribe). Treat as sensitive. - `token_subscribe: string` Subscribe-only token. Treat as sensitive. - `uid: string` Server-generated unique identifier (32 hex chars). ### Relay Update Response - `RelayUpdateResponse` Full relay details (no tokens). - `config: Config` origin_fallback and lingering_subscribe are mutually exclusive. - `lingering_subscribe?: LingeringSubscribe` - `enabled?: boolean` - `max_timeout_ms?: number` Relay-level ceiling on lingering subscribe timeout (ms). Default 30000. - `origin_fallback?: OriginFallback` - `enabled?: boolean` - `origins?: Array` Ordered list of upstream origin relays. Each entry is an object (not a bare string) so per-origin configuration can be added in the future without another breaking change. - `url?: string` Upstream origin relay URL. - `created: string` - `modified: string` - `name: string` - `uid: string` - `status?: "connected"` "connected" when active, omitted otherwise. - `"connected"` ### Relay Delete Response - `RelayDeleteResponse = unknown` # Tokens ## Rotate a token `client.moq.relays.tokens.rotate(stringrelayId, TokenRotateParamsparams, RequestOptionsoptions?): TokenRotateResponse` **post** `/accounts/{account_id}/moq/relays/{relay_id}/tokens/rotate` Generates a new token for the specified type. The old token is immediately invalidated. Token value is shown once in the response. ### Parameters - `relayId: string` - `params: TokenRotateParams` - `account_id: string` Path param: Cloudflare account identifier. - `type: "publish_subscribe" | "subscribe"` Body param: Which token type to rotate. - `"publish_subscribe"` - `"subscribe"` ### Returns - `TokenRotateResponse` - `token: string` New token value (shown once). Treat as sensitive. - `type: "publish_subscribe" | "subscribe"` - `"publish_subscribe"` - `"subscribe"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.moq.relays.tokens.rotate('a1b2c3d4e5f67890a1b2c3d4e5f67890', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', type: 'publish_subscribe', }); console.log(response.token); ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "success": true, "result": { "token": "eyJhbGciOiJFZDI1NTE5...", "type": "publish_subscribe" } } ``` ## Domain Types ### Token Rotate Response - `TokenRotateResponse` - `token: string` New token value (shown once). Treat as sensitive. - `type: "publish_subscribe" | "subscribe"` - `"publish_subscribe"` - `"subscribe"`