Skip to content
Start here

Create a relay

client.moq.relays.create(RelayCreateParams { account_id, name } params, RequestOptionsoptions?): RelayCreateResponse { config, created, issuers, 3 more }
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 (upstreams off). Use PUT to modify.

Security

API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
ParametersExpand Collapse
params: RelayCreateParams { account_id, name }
account_id: string

Path param: Cloudflare account identifier.

name: string

Body param: Human-readable name for the relay.

ReturnsExpand Collapse
RelayCreateResponse { config, created, issuers, 3 more }

Relay with its auto-created default token pair (one full-access [publish, subscribe] and one [subscribe]-only), each with its one-time secret, wrapped in the issuers envelope.

config: Config { upstreams }
upstreams?: Upstreams { enabled, upstreams }

Upstreams are external MOQT server publishers that a relay falls back to when it has no local publisher for a requested namespace/track.

enabled?: boolean
upstreams?: Array<Upstream>

Ordered list of upstream MOQT server publishers. Each entry is an object (not a bare string) so per-upstream configuration can be added in the future without another breaking change.

url?: string

Upstream MOQT server publisher URL.

created: string
formatdate-time
issuers: Array<Issuer>

Token collection (discriminated union on type). On create this holds the auto-created default pair, each including its one-time secret.

cloudflare_tokens: Array<CloudflareToken>

Always present ([] when empty).

created: string
formatdate-time
expires: string

Mandatory; no more than 1 year after created.

formatdate-time
jti: string

Token identity and registry key (32 hex chars).

operations: Array<"publish" | "subscribe">

Signed allowlist of what the token may do. V1 coarse roles; the array form extends to fine-grained MoQT message names later without a breaking change.

One of the following:
"publish"
"subscribe"
label?: string

Optional, customer-set.

secret?: string

The signed JWT. Present ONLY in create / auto-create responses (shown once); never returned by list, never stored.

issuer: "cloudflare"
type: "cloudflare_jwt"
modified: string
formatdate-time
name: string
uid: string

Server-generated unique identifier (32 hex chars).

Create a relay

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);
{
  "errors": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "success": true,
  "result": {
    "config": {
      "upstreams": {
        "enabled": true,
        "upstreams": [
          {
            "url": "url"
          }
        ]
      }
    },
    "created": "2019-12-27T18:11:19.117Z",
    "issuers": [
      {
        "cloudflare_tokens": [
          {
            "created": "2019-12-27T18:11:19.117Z",
            "expires": "2019-12-27T18:11:19.117Z",
            "jti": "f3a1b2c3d4e5f67890a1b2c3d4e5f678",
            "operations": [
              "publish",
              "subscribe"
            ],
            "label": "primary-encoder",
            "secret": "eyJhbGciOiJFZDI1NTE5..."
          }
        ],
        "issuer": "cloudflare",
        "type": "cloudflare_jwt"
      }
    ],
    "modified": "2019-12-27T18:11:19.117Z",
    "name": "Production Live Stream",
    "uid": "a1b2c3d4e5f67890a1b2c3d4e5f67890"
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "success": true,
  "result": {
    "config": {
      "upstreams": {
        "enabled": true,
        "upstreams": [
          {
            "url": "url"
          }
        ]
      }
    },
    "created": "2019-12-27T18:11:19.117Z",
    "issuers": [
      {
        "cloudflare_tokens": [
          {
            "created": "2019-12-27T18:11:19.117Z",
            "expires": "2019-12-27T18:11:19.117Z",
            "jti": "f3a1b2c3d4e5f67890a1b2c3d4e5f678",
            "operations": [
              "publish",
              "subscribe"
            ],
            "label": "primary-encoder",
            "secret": "eyJhbGciOiJFZDI1NTE5..."
          }
        ],
        "issuer": "cloudflare",
        "type": "cloudflare_jwt"
      }
    ],
    "modified": "2019-12-27T18:11:19.117Z",
    "name": "Production Live Stream",
    "uid": "a1b2c3d4e5f67890a1b2c3d4e5f67890"
  }
}