Show examples in:
Javascript HTTP
Endpoint info
Available examples

Content Management API > API token

Update an API token

Body parameters

name string Required

Name of API token

Example: "Read-only API token"
can_access_cda boolean Required

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

can_access_cda_preview boolean Required

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

can_access_cma boolean Required

Whether this API token can access the Content Management API

role Required

Role

Returns

Returns a resource object of type access_token

Examples

1
import { buildClient } from "@datocms/cma-client-node";
2
3
async function run() {
4
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
5
6
const accessTokenId = "312";
7
8
const accessToken = await client.accessTokens.update(accessTokenId, {
9
id: "312",
10
name: "Read-only API token",
11
can_access_cda: true,
12
can_access_cda_preview: true,
13
can_access_cma: true,
14
role: { type: "role", id: "34" },
15
});
16
17
// Check the 'Returned output' tab for the result ☝️
18
console.log(accessToken);
19
}
20
21
run();
1
{
2
id: "312",
3
name: "Read-only API token",
4
hardcoded_type: "",
5
can_access_cda: true,
6
can_access_cda_preview: true,
7
can_access_cma: true,
8
role: { type: "role", id: "34" },
9
}