Automating Contentstack With the Content Management API
The Delivery API reads published content. The Content Management API (CMA) creates, updates, and publishes — everything editors do in the UI, but programmable.
Authentication
Use a management token scoped to specific branches and permissions — not a personal login — for scripts and integrations.
Create an Entry
import contentstack from '@contentstack/management';
const client = contentstack.client();
const stack = client.stack({ api_key: process.env.CS_API_KEY, management_token: process.env.CS_MGMT_TOKEN });
const entry = await stack.contentType('product').entry().create({
entry: { title: 'Filter Coffee Blend 500g', sku: 'FC-500', summary: 'Strong South Indian blend.' },
});
Publish
await entry.publish({
publishDetails: { environments: ['production'], locales: ['en-us'] },
});
Common Automation
- Import products from a PIM or spreadsheet
- Bulk-update fields after a rebrand
- Migrate content from another CMS
- Generate draft entries from AI pipelines for review
- Clean up old entries
Rate Limits
The CMA has rate limits. Batch operations, add delays, and handle 429 responses with retries.
Safety
- Run on a branch or test stack first
- Log every change
- Keep scripts idempotent (check before creating)
- Never auto-publish AI-generated content without review
The CMA is your bulk-edit superpower. Use it carefully, test on branches, and log everything.