Show examples in:
Javascript HTTP
Endpoint info
Available examples

Content Management API > API token

Create a new 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 accessToken = await client.accessTokens.create({
7
name: "Read-only API token",
8
can_access_cda: true,
9
can_access_cda_preview: true,
10
can_access_cma: true,
11
role: { type: "role", id: "34" },
12
});
13
14
// Check the 'Returned output' tab for the result ☝️
15
console.log(accessToken);
16
}
17
18
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
}