Request

Creates a query token. The scope and permissions of the token are specified through the request TokenParameters object that includes a required label and expiration date and time (such as "expiration": "2025-01-15T15:30:00Z"), an optional description, along with other restrictions, such as:

  • Publish State - the publish state the token is restricted to (either Preview, Published, or both), for example, "publishState": ["Published"]. This property can be empty, but cannot be Unknown.
  • Branches - the name of the branches that token access is restricted to, for example, "branches": "main, dev, release/*"]. For a prefix match, use /*. This property can be empty.
  • Source IPs - the source IP addresses that token access is restricted to, for example, "sourceIPs": ["192.168.20.101"]. This property can be empty.
  • Origins - the origins that the token access is restricted to. This is a CORS feature and takes effect only when a request includes the Origin header. This property can be empty.
  • Introspection - whether GraphQL introspection is allowed when using this token. It is recommended that introspection only be enabled for development environments.

Note
We recommend an expiration date of one year at the most. You cannot change the expiration date after you create a token without generating a new token.

Security
Bearer
Bodyapplication/json

The token creation parameters details.

labelstring

The label of the token.

descriptionstring or null

The description of the token.

managePersistedQueriesboolean or null

Whether the token can manage persisted queries.

expirationstring, (date-time)

The expiration date and time of the token.

restrictionsobject(TokenRestriction)

Represents the restrictions associated with a token.

Example:
{ "publishState": [ "Published" ], "branches": [ "main" ], "origins": [ "https://myapp.com" ], "sourceIPs": [ "127.0.0.1" ], "introspection": true }
curl -i -X POST \
  https://cs-tokenapi.sitecorecloud.io/api/token/v2 \
  -H 'Authorization: Bearer <YOUR_JWT_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "label": "string",
    "description": "string",
    "managePersistedQueries": true,
    "expiration": "2019-08-24T14:15:22Z",
    "restrictions": {
      "publishState": [
        "Published"
      ],
      "branches": [
        "main"
      ],
      "origins": [
        "https://myapp.com"
      ],
      "sourceIPs": [
        "127.0.0.1"
      ],
      "introspection": true
    }
  }'

Responses

The token was successfully created. Token details are returned with the token value.

Bodyapplication/json
idstring

The unique identifier of the token.

labelstring

The label of the token.

descriptionstring

The description of the token.

managePersistedQueriesboolean or null

Whether the token can manage persisted queries.

tokenstring

The token string.

expirationstring, (date-time)

The expiration date and time of the token.

restrictionsobject(TokenRestriction)

Represents the restrictions associated with a token.

Example:
{ "publishState": [ "Published" ], "branches": [ "main" ], "origins": [ "https://myapp.com" ], "sourceIPs": [ "127.0.0.1" ], "introspection": true }
systemobject(BaseTokenSystemProperties)

Contains system metadata and tracking information for a token. This includes creation details that are automatically populated by the system.

Response
{ "id": "string", "label": "string", "description": "string", "managePersistedQueries": true, "token": "string", "expiration": "2019-08-24T14:15:22Z", "restrictions": { "publishState": [ … ], "branches": [ … ], "origins": [ … ], "sourceIPs": [ … ], "introspection": true }, "system": { "createdAt": "2019-08-24T14:15:22Z", "createdBy": { … } } }