Every DatoCMS project has one primary environment, and can have multiple sandbox environments. Sandbox environments are very useful to test changes in your schema/content, without interfering with the regular flow of content editors.
By default, every API request you perform will point to the current primary environment, but if you want to make changes to a specific sandbox environment, you can add an X-Environment
header.
curl \-H 'Authorization: Bearer <YOUR-API-TOKEN>' \-H 'Accept: application/json' \-H 'X-Api-Version: 3' \-H 'X-Environment: my-sandbox-environment' \https://site-api.datocms.com/site
If you're using our Javascript client, you can pass the sandbox environment in the initialization options:
import { buildClient } from '@datocms/cma-client-node';const client = buildClient({apiToken: '<YOUR_TOKEN>',environment: 'my-sandbox-environment',});
The legacy JS client has a similar option too:
const { SiteClient } = require('datocms-client');const client = new SiteClient('YOUR-API-TOKEN', {environment: 'my-sandbox-environment',});