Skip to content
Start here

Rotate a token

client.moq.relays.tokens.rotate(stringrelayId, TokenRotateParams { account_id, type } params, RequestOptionsoptions?): TokenRotateResponse { token, type }
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.

Security

API Token

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

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
ParametersExpand Collapse
relayId: string
params: TokenRotateParams { account_id, type }
account_id: string

Path param: Cloudflare account identifier.

type: "publish_subscribe" | "subscribe"

Body param: Which token type to rotate.

One of the following:
"publish_subscribe"
"subscribe"
ReturnsExpand Collapse
TokenRotateResponse { token, type }
token: string

New token value (shown once). Treat as sensitive.

type: "publish_subscribe" | "subscribe"
One of the following:
"publish_subscribe"
"subscribe"

Rotate a token

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);
{
  "errors": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "success": true,
  "result": {
    "token": "eyJhbGciOiJFZDI1NTE5...",
    "type": "publish_subscribe"
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "success": true,
  "result": {
    "token": "eyJhbGciOiJFZDI1NTE5...",
    "type": "publish_subscribe"
  }
}