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 beUnknown. - 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
Originheader. 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
The token creation parameters details.
- https://cs-tokenapi.sitecorecloud.iohttps://cs-tokenapi.sitecorecloud.io/api/token/v2
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
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
}
}'The token was successfully created. Token details are returned with the token value.
Represents the restrictions associated with a token.
Example:
{ "publishState": [ "Published" ], "branches": [ "main" ], "origins": [ "https://myapp.com" ], "sourceIPs": [ "127.0.0.1" ], "introspection": true }
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": { … } } }