# MoQ # Relays ## List relays `moq.relays.list(RelayListParams**kwargs) -> SyncSinglePage[RelayListResponse]` **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 - `account_id: str` Cloudflare account identifier. - `asc: Optional[bool]` Sort order by `created`. When true, results are returned oldest-first (ascending); otherwise newest-first (descending, the default). - `created_after: Optional[Union[str, datetime]]` 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: Optional[Union[str, datetime]]` 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: Optional[int]` Maximum number of relays to return per page. ### Returns - `class RelayListResponse: …` Abbreviated relay for list responses. - `created: datetime` - `modified: datetime` - `name: str` - `uid: str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.moq.relays.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) page = page.result[0] print(page.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 `moq.relays.get(strrelay_id, RelayGetParams**kwargs) -> RelayGetResponse` **get** `/accounts/{account_id}/moq/relays/{relay_id}` Retrieves a single MoQ relay including config and status. Tokens are NOT included. ### Parameters - `account_id: str` Cloudflare account identifier. - `relay_id: str` ### Returns - `class RelayGetResponse: …` Full relay details (no tokens). - `config: Config` origin_fallback and lingering_subscribe are mutually exclusive. - `lingering_subscribe: Optional[ConfigLingeringSubscribe]` - `enabled: Optional[bool]` - `max_timeout_ms: Optional[int]` Relay-level ceiling on lingering subscribe timeout (ms). Default 30000. - `origin_fallback: Optional[ConfigOriginFallback]` - `enabled: Optional[bool]` - `origins: Optional[List[ConfigOriginFallbackOrigin]]` 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: Optional[str]` Upstream origin relay URL. - `created: datetime` - `modified: datetime` - `name: str` - `uid: str` - `status: Optional[Literal["connected"]]` "connected" when active, omitted otherwise. - `"connected"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) relay = client.moq.relays.get( relay_id="a1b2c3d4e5f67890a1b2c3d4e5f67890", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(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 `moq.relays.create(RelayCreateParams**kwargs) -> 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 - `account_id: str` Cloudflare account identifier. - `name: str` Human-readable name for the relay. ### Returns - `class RelayCreateResponse: …` Relay with auto-generated tokens (shown once). - `config: Config` origin_fallback and lingering_subscribe are mutually exclusive. - `lingering_subscribe: Optional[ConfigLingeringSubscribe]` - `enabled: Optional[bool]` - `max_timeout_ms: Optional[int]` Relay-level ceiling on lingering subscribe timeout (ms). Default 30000. - `origin_fallback: Optional[ConfigOriginFallback]` - `enabled: Optional[bool]` - `origins: Optional[List[ConfigOriginFallbackOrigin]]` 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: Optional[str]` Upstream origin relay URL. - `created: datetime` - `modified: datetime` - `name: str` - `token_publish_subscribe: str` Full access token (publish + subscribe). Treat as sensitive. - `token_subscribe: str` Subscribe-only token. Treat as sensitive. - `uid: str` Server-generated unique identifier (32 hex chars). ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) relay = client.moq.relays.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", name="Production Live Stream", ) print(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 `moq.relays.update(strrelay_id, RelayUpdateParams**kwargs) -> 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 - `account_id: str` Cloudflare account identifier. - `relay_id: str` - `config: Optional[Config]` origin_fallback and lingering_subscribe are mutually exclusive. - `lingering_subscribe: Optional[ConfigLingeringSubscribe]` - `enabled: Optional[bool]` - `max_timeout_ms: Optional[int]` Relay-level ceiling on lingering subscribe timeout (ms). Default 30000. - `origin_fallback: Optional[ConfigOriginFallback]` - `enabled: Optional[bool]` - `origins: Optional[Iterable[ConfigOriginFallbackOrigin]]` 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: Optional[str]` Upstream origin relay URL. - `name: Optional[str]` ### Returns - `class RelayUpdateResponse: …` Full relay details (no tokens). - `config: Config` origin_fallback and lingering_subscribe are mutually exclusive. - `lingering_subscribe: Optional[ConfigLingeringSubscribe]` - `enabled: Optional[bool]` - `max_timeout_ms: Optional[int]` Relay-level ceiling on lingering subscribe timeout (ms). Default 30000. - `origin_fallback: Optional[ConfigOriginFallback]` - `enabled: Optional[bool]` - `origins: Optional[List[ConfigOriginFallbackOrigin]]` 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: Optional[str]` Upstream origin relay URL. - `created: datetime` - `modified: datetime` - `name: str` - `uid: str` - `status: Optional[Literal["connected"]]` "connected" when active, omitted otherwise. - `"connected"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) relay = client.moq.relays.update( relay_id="a1b2c3d4e5f67890a1b2c3d4e5f67890", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(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 `moq.relays.delete(strrelay_id, RelayDeleteParams**kwargs) -> object` **delete** `/accounts/{account_id}/moq/relays/{relay_id}` Soft-deletes a MoQ relay. ### Parameters - `account_id: str` Cloudflare account identifier. - `relay_id: str` ### Returns - `object` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) relay = client.moq.relays.delete( relay_id="a1b2c3d4e5f67890a1b2c3d4e5f67890", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(relay) ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "success": true, "result": {} } ``` ## Domain Types ### Relay List Response - `class RelayListResponse: …` Abbreviated relay for list responses. - `created: datetime` - `modified: datetime` - `name: str` - `uid: str` ### Relay Get Response - `class RelayGetResponse: …` Full relay details (no tokens). - `config: Config` origin_fallback and lingering_subscribe are mutually exclusive. - `lingering_subscribe: Optional[ConfigLingeringSubscribe]` - `enabled: Optional[bool]` - `max_timeout_ms: Optional[int]` Relay-level ceiling on lingering subscribe timeout (ms). Default 30000. - `origin_fallback: Optional[ConfigOriginFallback]` - `enabled: Optional[bool]` - `origins: Optional[List[ConfigOriginFallbackOrigin]]` 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: Optional[str]` Upstream origin relay URL. - `created: datetime` - `modified: datetime` - `name: str` - `uid: str` - `status: Optional[Literal["connected"]]` "connected" when active, omitted otherwise. - `"connected"` ### Relay Create Response - `class RelayCreateResponse: …` Relay with auto-generated tokens (shown once). - `config: Config` origin_fallback and lingering_subscribe are mutually exclusive. - `lingering_subscribe: Optional[ConfigLingeringSubscribe]` - `enabled: Optional[bool]` - `max_timeout_ms: Optional[int]` Relay-level ceiling on lingering subscribe timeout (ms). Default 30000. - `origin_fallback: Optional[ConfigOriginFallback]` - `enabled: Optional[bool]` - `origins: Optional[List[ConfigOriginFallbackOrigin]]` 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: Optional[str]` Upstream origin relay URL. - `created: datetime` - `modified: datetime` - `name: str` - `token_publish_subscribe: str` Full access token (publish + subscribe). Treat as sensitive. - `token_subscribe: str` Subscribe-only token. Treat as sensitive. - `uid: str` Server-generated unique identifier (32 hex chars). ### Relay Update Response - `class RelayUpdateResponse: …` Full relay details (no tokens). - `config: Config` origin_fallback and lingering_subscribe are mutually exclusive. - `lingering_subscribe: Optional[ConfigLingeringSubscribe]` - `enabled: Optional[bool]` - `max_timeout_ms: Optional[int]` Relay-level ceiling on lingering subscribe timeout (ms). Default 30000. - `origin_fallback: Optional[ConfigOriginFallback]` - `enabled: Optional[bool]` - `origins: Optional[List[ConfigOriginFallbackOrigin]]` 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: Optional[str]` Upstream origin relay URL. - `created: datetime` - `modified: datetime` - `name: str` - `uid: str` - `status: Optional[Literal["connected"]]` "connected" when active, omitted otherwise. - `"connected"` # Tokens ## Rotate a token `moq.relays.tokens.rotate(strrelay_id, TokenRotateParams**kwargs) -> 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 - `account_id: str` Cloudflare account identifier. - `relay_id: str` - `type: Literal["publish_subscribe", "subscribe"]` Which token type to rotate. - `"publish_subscribe"` - `"subscribe"` ### Returns - `class TokenRotateResponse: …` - `token: str` New token value (shown once). Treat as sensitive. - `type: Literal["publish_subscribe", "subscribe"]` - `"publish_subscribe"` - `"subscribe"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.moq.relays.tokens.rotate( relay_id="a1b2c3d4e5f67890a1b2c3d4e5f67890", account_id="023e105f4ecef8ad9ca31a8372d0c353", type="publish_subscribe", ) print(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 - `class TokenRotateResponse: …` - `token: str` New token value (shown once). Treat as sensitive. - `type: Literal["publish_subscribe", "subscribe"]` - `"publish_subscribe"` - `"subscribe"`