Show examples in:
Create a new API token

Body Parameters

name  Required  string  Example: "Read-only API token"

Name of API token

can_access_cda  Required  boolean  Example: true

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

can_access_cda_preview  Required  boolean  Example: true

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

can_access_cma  Required  boolean  Example: true

Whether this API token can access the Content Management API

role  Required  { type: "role", id: role.id }, null

Role

Returns

Returns a access_token resource object.

Examples

Example Basic example
import { buildClient } from '@datocms/cma-client-node';
async function run() {
const client = buildClient({ apiToken: '<YOUR_API_TOKEN>' });
const accessToken = await client.accessTokens.create({
name: 'Read-only API token',
can_access_cda: true,
can_access_cda_preview: true,
can_access_cma: true,
role: {
type: 'role',
id: '34'
}
});
console.log(accessToken);
}
run();