Update an API token
Updates an API token's name, role, or API surface flags. The token's secret value is not affected — to rotate it, use the Rotate API token endpoint.
If you omit relationships from the payload, the token's existing role is preserved. Send relationships.role only when you want to reassign the token to a different role.
Changes to the role or surface flags take effect immediately. A request that was permitted under the previous configuration may be rejected on the very next call once the new permissions have been written.
The project's built-in factory tokens (those whose attributes.hardcoded_type is non-null) reject this endpoint with NON_EDITABLE_ACCESS_TOKEN. They can still be deleted or rotated.
Body parameters
Must be exactly "access_token".
Name of API token
"Read-only API token"
Whether this API token can call the Content Delivery API (graphql.datocms.com) to fetch published content.
Whether this API token can call the Content Delivery API with the X-Include-Drafts: true header to fetch draft (current, unpublished) content. There is no separate endpoint — the CDA is a single GraphQL endpoint and this flag governs whether requesting drafts is allowed.
Whether this API token can access the Content Management API
Returns
Returns a resource object of type access_token.
Examples
PUT https://site-api.datocms.com/access_tokens/:access_token_id HTTP/1.1Authorization: Bearer YOUR-API-TOKENAccept: application/jsonX-Api-Version: 3Content-Type: application/vnd.api+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 } }}curl -g 'https://site-api.datocms.com/access_tokens/:access_token_id' \ -X PUT \ -H "Authorization: Bearer YOUR-API-TOKEN" \ -H "Accept: application/json" \ -H "X-Api-Version: 3" \ -H "Content-Type: application/vnd.api+json" \ --data-binary '{"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}}}'await fetch("https://site-api.datocms.com/access_tokens/:access_token_id", { method: "PUT", headers: { Authorization: "Bearer YOUR-API-TOKEN", Accept: "application/json", "X-Api-Version": "3", "Content-Type": "application/vnd.api+json", }, body: JSON.stringify({ 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, }, }, }),});HTTP/1.1 200 OKContent-Type: application/jsonCache-Control: cache-control: max-age=0, private, must-revalidateX-RateLimit-Limit: 30X-RateLimit-Remaining: 28
{ "data": { "type": "access_token", "id": "312", "attributes": { "name": "Read-only API token", "hardcoded_type": "", "can_access_cda": true, "can_access_cda_preview": true, "can_access_cma": true, "last_cma_access": "never", "last_cda_access": "never" }, "relationships": { "role": { "data": { "type": "role", "id": "34" } } } }}