You're reading "Content Management API"

API token

An API token allows access to our API. It is linked to a Role, which describes what actions can be performed.

The API token object

A API token object is returned as part of the response body of each successful Index, Show, Create, Update or Delete API call. The following table contains the list of all its fields along with their type, description and example values.

Object fields:
can_access_cdaboolean

Whether this access token can access the Content Delivery API published content endpoint

This attribute is required
can_access_cda_previewboolean

Whether this access token can access the Content Delivery API draft content endpoint

This attribute is required
can_access_cmaboolean

Whether this access token can access the Content Management API

This attribute is required
hardcoded_typestring
namestring

Name of access token

This attribute is required
tokenstring

The actual API token

This attribute is required

List all access tokens

To list all access tokens, send a GET request to the /access_tokens endpoint. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
GET https://site-api.datocms.com/access_tokens HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": [ { "type": "access_token", "id": "312", "attributes": { "name": "Read-only API token", "token": "XXXXXXXXXXXXXXX", "can_access_cda": true, "can_access_cda_preview": true, "can_access_cma": true, "hardcoded_type": null }, "relationships": { "role": { "data": { "type": "role", "id": "34" } } } } ] }

Retrieve a access tokens

To retrieve a access tokens, send a GET request to the /access_tokens/:access_token_id endpoint. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
GET https://site-api.datocms.com/access_tokens/:access_token_id HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": { "type": "access_token", "id": "312", "attributes": { "name": "Read-only API token", "token": "XXXXXXXXXXXXXXX", "can_access_cda": true, "can_access_cda_preview": true, "can_access_cma": true, "hardcoded_type": null }, "relationships": { "role": { "data": { "type": "role", "id": "34" } } } } }

Create a new access token

To create a new access token, send a POST request to the /access_tokens endpoint, passing the resource arguments in the request body. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
POST https://site-api.datocms.com/access_tokens HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Content-Typeapplication/json
{ "data": { "type": "access_token", "attributes": { "name": "Read-only API token", "can_access_cda": true, "can_access_cda_preview": true, "can_access_cma": true }, "relationships": { "role": { "data": { "type": "role", "id": "34" } } } } }
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": { "type": "access_token", "id": "312", "attributes": { "name": "Read-only API token", "token": "XXXXXXXXXXXXXXX", "can_access_cda": true, "can_access_cda_preview": true, "can_access_cma": true, "hardcoded_type": null }, "relationships": { "role": { "data": { "type": "role", "id": "34" } } } } }

Update an access token

To update an access token, send a PUT request to the /access_tokens/:access_token_id endpoint, passing the resource arguments in the request body. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
PUT https://site-api.datocms.com/access_tokens/:access_token_id HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Content-Typeapplication/json
{ "data": { "type": "access_token", "id": "312", "attributes": { "name": "Read-only API token", "can_access_cda": true, "can_access_cda_preview": true, "can_access_cma": true }, "relationships": { "role": { "data": { "type": "role", "id": "34" } } } } }
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": { "type": "access_token", "id": "312", "attributes": { "name": "Read-only API token", "token": "XXXXXXXXXXXXXXX", "can_access_cda": true, "can_access_cda_preview": true, "can_access_cma": true, "hardcoded_type": null }, "relationships": { "role": { "data": { "type": "role", "id": "34" } } } } }

Delete an access token

To delete an access token, send a DELETE request to the /access_tokens/:access_token_id endpoint. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
DELETE https://site-api.datocms.com/access_tokens/:access_token_id HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": { "type": "access_token", "id": "312", "attributes": { "name": "Read-only API token", "token": "XXXXXXXXXXXXXXX", "can_access_cda": true, "can_access_cda_preview": true, "can_access_cma": true, "hardcoded_type": null }, "relationships": { "role": { "data": { "type": "role", "id": "34" } } } } }