Rotate a token
client.MoQ.Relays.Tokens.Rotate(ctx, relayID, params) (*RelayTokenRotateResponse, error)
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:
Rotate a token
package main
import (
"context"
"fmt"
"github.com/stainless-sdks/cloudflare-go"
"github.com/stainless-sdks/cloudflare-go/moq"
"github.com/stainless-sdks/cloudflare-go/option"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
response, err := client.MoQ.Relays.Tokens.Rotate(
context.TODO(),
"a1b2c3d4e5f67890a1b2c3d4e5f67890",
moq.RelayTokenRotateParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Type: cloudflare.F(moq.RelayTokenRotateParamsTypePublishSubscribe),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", 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"
}
}