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
Returns
Returns a resource object of type access_token
Examples
import { buildClient } from "@datocms/cma-client-node";
async function run() { const client = buildClient({ apiToken: process.env.DATOCMS_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" }, });
// Check the 'Returned output' tab for the result ☝️ console.log(accessToken);}
run();
{ id: "312", name: "Read-only API token", hardcoded_type: "", can_access_cda: true, can_access_cda_preview: true, can_access_cma: true, role: { type: "role", id: "34" },}