After exporting content from a source stack, unzip the exported file and then use the Contentstack CLI to import it into the destination stack.
This guide covers how to use the cm:stacks:import command with:
Note: Imported content gets published to the same environment and locale as in the source stack. Unpublished content in the source stack remains unpublished after import.
The cm:stacks:import command lets you import content into your destination stack.
Note: By default, an audit fix is performed on the exported content before import. This helps identify and address potential issues in the exported data.
Usage
csdx cm:stacks:import -k <<stack_ApiKey>> --data-dir <<path_of_folder_where_content_is_stored>>Use the following options with any applicable import command:
| Flag | Short Flag | Description |
|---|---|---|
| --config | -c | [Optional] Path to the configuration JSON file containing all options for a single run. |
| --stack-api-key | -k | API key of the target stack. |
| --data-dir | - | Path in your file system where the content to be imported is stored. Example: --data-dir "C:\Users\Name\Desktop\cli\content" Point this at the export folder itself. The export writes content flat, with no per-branch subfolder, so the same path works for both the export and the import. |
| --alias | -a | Management token alias of the destination stack. |
| --module | - | [Optional] Specify a module to import into the target stack. If not specified, all modules are imported. Supported values: stack, assets, locales, environments, extensions, webhooks, global-fields, entries, content-types, custom-roles, workflows, publishing-rules, labels, marketplace-apps, taxonomies, personalize, variant-entries, composable-studio The CLI validates this value before the import starts and fails immediately if the module name is not in the list above. |
| --backup-dir | - | [Optional] Backup directory name when importing a specific module. |
| --branch | - | Name of the branch into which content is imported. Default: main |
| --branch-alias | - | Alias of the branch into which content is imported. |
| --import-webhook-status | - | [Optional] Maintain webhook state configuration from the source stack. Supported values: disable, current Default: disable |
| --yes | -y | [Optional] Force override all Marketplace prompts. |
| --replace-existing | - | Replaces the existing module in the target stack. |
| --skip-existing | - | [Optional] Skips the module exists warning messages. |
| --personalize-project-name | - | [Optional] Provide a unique name for the Personalize project. |
| --skip-audit | - | Skips the audit fix that occurs during the import operation. |
| --exclude-global-modules | - | Excludes branch-independent modules from the import operation. |
| --skip-assets-publish | - | Skips asset publishing during the import process. |
| --skip-entries-publish | - | Skips entry publishing during the import process. |
| --skip-taxonomy-publish | - | Skips taxonomy publishing during the import process. |
Note:
Use the --module flag in the import command to import individual modules into the target stack. If you do not use the flag, the import command includes all available modules by default.
Two behaviours differ when the folder you pass to --data-dir was produced by CLI V1 rather than V2. Both fail quietly, so check for them before you rely on the result.
Warning: Importing a V1 export skips every global field, with no error and no warning. The global fields step reports success having created zero items.
The cause is a change in file layout. The V2 importer reads one file per UID and ignores the aggregate files that V1 wrote:
| Module | A V1 export writes | The V2 importer reads | Result |
|---|---|---|---|
| Content types | Individual <uid>.json files and schema.json | Per-UID files only | Imports correctly, because the per-UID files exist |
| Global fields | globalfields.json only, with no individual files | Per-UID files only | Silently skipped, because no per-UID files exist |
To resolve it, re-export the source stack with the current CLI before importing.
The second difference affects multi-branch V1 exports. V1 wrote a branches.json file at the export root and the V1 importer used it to navigate into the correct branch subfolder automatically. The current importer does not do this. Point --data-dir at the branch subfolder yourself:
csdx cm:stacks:import --stack-api-key bltxxxxxx --data-dir ./my-v1-export/mainPointing it at the export root instead finds no content files there, and the command completes and reports success having imported nothing.
Some modules depend on others. When importing modules individually, follow this sequence to avoid errors:
Locales → Environments → Assets → Taxonomies → Extensions → Marketplace Apps → Webhooks → Global Fields → Content Types → Workflows → Entries → Labels → Custom Roles → Publishing Rules → Personalize → Composable Studio.
Note: Before importing a module, ensure all its dependencies have been imported.
Example:
csdx cm:stacks:import --stack-api-key bltxxxxxx --data-dir "C:\Users\Name\Desktop\cli\content" --module localesWhen importing modules individually with the import command, include the --backup-dir flag to prevent errors caused by inter-module dependencies. This flag stores mapping files that are required by dependent modules in future imports.
csdx cm:stacks:import --stack-api-key <<stack_ApiKey>> --data-dir <<path_of_folder_where_content_is_stored>> --module <<module>> --backup-dir <<backup_dir>>During each module import, the system saves updated mapping files in the specified backup folder. These mappings are reused by dependent modules to ensure consistent and successful imports.
Note: The parent backup folder created during the initial import can be reused for subsequent module imports. To avoid errors, always include the --backup-dir flag when importing modules one at a time.
Examples
You can also import content using a configuration file that stores all required parameters and values.
To get started, follow the steps below:
Usage
csdx cm:stacks:import -c <<config_file_path>>Example
Note:
Using a configuration file simplifies the import process by storing all required parameters and values in one place. This removes the need to enter each option manually and is helpful for repeated or complex imports.
Use a management token to import content into a stack when you prefer token-based authentication instead of CLI login. You can pass the token directly through the command line or reference it from a configuration file.
Usage
csdx cm:stacks:import -a <<alias>>Optional Parameters:
Examples:
Use the --replace-existing flag in the import command to overwrite the existing content in the target stack. This prevents import failures caused by module collisions and ensures that existing items are overwritten while new items are added.
When the import process detects a module that already exists in the target stack, the CLI replaces it instead of throwing an error. If the module does not exist, the CLI creates it as a new item.
Example:
csdx cm:stacks:import --replace-existing --backup-dir <backup-dir-path> --stack-api-key <value> --data-dir <content-dir-path>For more details, refer Overwrite Existing Content using CLI Import document.
Contentstack CLI lets you toggle between the raw console logs and the visual Progress Manager UI during import or plugin workflows.
Default Usage:
csdx cm:stacks:import --data-dir "./export-data" --stack-api-key bltxxxxxxNote: By default, the Progress Manager UI displays when you run the import command and does not require any configuration.
Example for Progress Manager View (Default Mode):
LOCALES:
├─ Master Locale |████████████████████████████████████████| 100% | 1/1 | ✓ Complete (1/1)
├─ Locales Create |████████████████████████████████████████| 100% | 1/1 | ✓ Complete (0/1)
├─ Locales Update |████████████████████████████████████████| 100% | 1/1 | ✓ Complete (1/1)
ENVIRONMENTS:
└─ Environments |████████████████████████████████████████| 100% | 2/2 | ✓ Complete (2/2)
STACK:
└─ Stack |██��█████████████████████████████████████| 100% | 1/1 | ✓ Complete (1/1)
ASSETS:
├─ Folders |████████████████████████████████████████| 100% | 2/2 | ✓ Complete (2/2)
├─ Upload |████████████████████████████████████████| 100% | 12/12 | ✓ Complete (12/12)
├─ Publish |████████████████████████████████████████| 100% | 12/12 | ✓ Complete (12/12)
TAXONOMIES:
└─ Taxonomies |████████████████████████████████████████| 100% | 1/1 | ✓ Complete (1/1)
EXTENSIONS:
├─ Extensions Create |████████████████████████████████████████| 100% | 1/1 | ✓ Complete (1/1)
Steps to Switch to Console Logs (Optional):
csdx config:set:log --show-console-logscsdx cm:stacks:import --data-dir "./export-data" --stack-api-key bltxxxxxxThe screen displays the console logs for the import operation.
Tip: Use --show-console-logs for detailed debugging when troubleshooting import issues.
csdx config:set:log --no-show-console-logsOptions:
| Option | Description |
|---|---|
| --show-console-logs | Displays the console logs for the operation. |
| --no-show-console-logs | Hides the console logs and displays the Progress Manager view for the operation. |
Example for Console Log Mode:
[2025-09-10 19:19:02] INFO: Audit process completed
[2025-09-10 19:19:03] INFO: Starting to import content version 2
[2025-09-10 19:19:03] INFO: Starting import of locales module
[2025-09-10 19:19:05] INFO: Created locale: 'fr-fr'
[2025-09-10 19:19:07] INFO: Updated locale: 'fr-fr'
[2025-09-10 19:19:07] SUCCESS: Languages have been imported successfully!
[2025-09-10 19:19:07] INFO: Starting import of environments moduleAdditional Resource: Learn more about the CLI-supported import operations in the Support for CLI-Based Stack Import Operations document.