Contentstack CLI offers support for export, import, and clone operations, including Marketplace apps, module-wise imports, error handling, and Personalize project integration.
This guide outlines these features to help you manage content migration operations with flexibility and control.
The CLI supports the following modules for export, import, and clone operations:
| Module | Export | Import | Clone | Notes |
|---|---|---|---|---|
| Content Types | ✅ | ✅ | ✅ | Schema definitions |
| Entries | ✅ | ✅ | ✅ | Content entries |
| Assets | ✅ | ✅ | ✅ | Media files |
| Environments | ✅ | ✅ | ✅ | Environment configurations |
| Extensions | ✅ | ✅ | ✅ | Experience extensions |
| Global Fields | ✅ | ✅ | ✅ | Global field definitions |
| Labels | ✅ | ✅ | ✅ | Content labels |
| Locales | ✅ | ✅ | ✅ | Locale configurations |
| Webhooks | ✅ | ✅ | ✅ | Webhook configurations |
| Workflows | ✅ | ✅ | ✅ | Workflow definitions |
| Custom Roles | ✅ | ✅ | ✅ | Custom role definitions |
| Taxonomies | ✅ | ✅ | ✅ | Taxonomy structures |
| Marketplace Apps | ✅ | ✅ | ✅ | Public and private apps |
| Personalize | ✅ | ✅ | ✅ | Personalize projects |
| Entry Variants | ✅ | ✅ | ✅ | Entry variant configurations |
| CS Assets | ✅ | ✅ | ❌ | Space-based assets (requires cs-assets region config) |
You can export/import public and private Marketplace apps into a stack using CLI commands.
Important Notes:
If a public Marketplace app with a specific configuration already exists in the destination organization, you will be prompted with the following options during import:
Update - Update the app with the new configuration from the source organization
Skip updating - Skip updating the app configuration
Warning: Skipping may result in issues with imported content.
Exit - Cancel the entire stack import process
Example:
# Export with Marketplace apps
csdx cm:stacks:export -a source-alias --data-dir ./export
# Import with Marketplace apps (interactive prompts)
csdx cm:stacks:import -a target-alias --data-dir ./export
If the imported app has the same name as an existing app in the destination stack:
Note: App names must be 3-20 characters long.
During Stack Import:
Skip App Recreation:
csdx cm:stacks:import \
-a target-alias \
--data-dir ./export \
--skip-app-recreation \
-y
Important: You cannot reuse any existing private apps during the import process.
If an error occurs while importing a public or private app:
When working with stacks that are synced with a Personalize project, certain modules and configurations are automatically handled during export and import operations.
If the stack you're exporting is linked to a Personalize project, the following items will be exported:
Example:
# Export stack with Personalize project
csdx cm:stacks:export -a source-alias --data-dir ./export
If the content you're importing is associated or synced with a Personalize project, a new Personalize project will be created and linked to the new stack. Additionally, the following items will be imported:
Options:
| Option | Description | Required |
|---|---|---|
| --personalize-project-name | Provide a unique name for the Personalize project | No |
Example:
# Import with Personalize project
csdx cm:stacks:import \
-a target-alias \
--data-dir ./export \
--personalize-project-name "My Personalize Project"
Note: Variants and Personalize currently support only basic authentication.
Important: The -a <alias> flag (management token) skips Personalize modules as they require an auth token for import and cannot be imported using a management token.
Workaround:
The CLI uses CS Assets for asset export and import only when both of the following conditions are met:
Note: Linked workspaces are CS Assets spaces in your Contentstack organization that are associated with a branch. The CLI reads them automatically from branch settings.
When only one condition is met, the CLI behaves as follows:
| Condition | Export behavior | Import behavior |
|---|---|---|
| CS Assets URL configured, no linked workspaces | Falls back to legacy asset export silently | Falls back to legacy asset export silently |
| Linked workspaces found, no CS Assets URL | Falls back to legacy asset export silently | Logs a message and skips the CS Assets step. Import continues for all other modules (content types, entries, locales). |
When both conditions are met, the CLI activates CS Assets mode automatically and writes assets under a spaces/ directory instead of assets/.
csdx cm:stacks:export -k <stack-api-key> --data-dir ./export
Note: Use csdx auth:login for CS Assets export. When using a management token, the CLI cannot read branch settings, so linked workspaces are never populated and CS Assets mode never activates. The export falls back to legacy asset export. See Management Token Behavior.
| Aspect | Legacy Asset Export | CS Assets |
|---|---|---|
| Export directory | assets/ at branch root | spaces/ at branch root |
| Asset organization | Single flat structure | Per-space directories (spaces/{space_uid}/) |
| Fields & asset types | Not exported | Exported once per run; org-level definitions shared across all spaces (spaces/fields/, spaces/asset_types/) |
| Space metadata | N/A | Exported to spaces/{space_uid}/space.json |
| Activation | Always on | Automatic when CS Assets URL is configured and linked workspaces exist |
| Management token | Supported | Falls back to legacy asset export. The CLI skips the stack-settings step and logs a debug message. |
CS Assets import works with all authentication methods, including management tokens.
csdx cm:stacks:import -k <stack-api-key> --data-dir ./export
The import command detects CS Assets mode when both the spaces/ directory and the am_v2 key in stack/settings.json are present in the export directory. No additional flags are required. See How CS Assets import is detected.
For full details on CS Assets export and import behavior, see CLI for CS Assets.
You can export, import, or clone specific modules instead of all modules.
# Export only entries
csdx cm:stacks:export -a <alias> --data-dir ./export --module entries
# Export multiple modules
csdx cm:stacks:export -a <alias> --data-dir ./export --module entries assets content-types
# Import only entries
csdx cm:stacks:import -a <alias> --data-dir ./export --module entries
# Import multiple modules
csdx cm:stacks:import -a <alias> --data-dir ./export --module entries assets content-types
# Clone structure only (no entries/assets)
csdx cm:stacks:clone \
--source-management-token-alias source-alias \
--destination-management-token-alias destination-alias \
--type a
# Clone structure with content (all modules)
csdx cm:stacks:clone \
--source-management-token-alias source-alias \
--destination-management-token-alias destination-alias \
--type b
The CLI provides comprehensive error handling for export, import, and clone operations:
For detailed troubleshooting, see the CLI Troubleshooting Guide.
For more best practices, see the CLI Best Practices Guide.
For detailed limitations, see the CLI Limitations Guide.
Key Limitations: