Skip to content
Start here

Rotate a token

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
Path ParametersExpand Collapse
account_id: string

Cloudflare account identifier.

relay_id: string
Body ParametersJSONExpand Collapse
type: "publish_subscribe" or "subscribe"

Which token type to rotate.

One of the following:
"publish_subscribe"
"subscribe"
ReturnsExpand Collapse
errors: array of object { code, message }
code: optional number
message: optional string
messages: array of object { code, message }
code: optional number
message: optional string
success: boolean
result: optional object { token, type }
token: string

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

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

Rotate a token

curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/moq/relays/$RELAY_ID/tokens/rotate \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
    -d '{
          "type": "publish_subscribe"
        }'
{
  "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"
  }
}