Was this article helpful?
Thanks for your feedback
After you have exported the content from the source stack, the next step is to import it into the destination stack. To do this, you can use the import command in several ways.
Note: Before you try the import commands, make sure you have unzipped the exported content from the folder that contains the exported content.
Content can be imported in a stack for the following modules:
Note: The imported content, in the target stack, will be automatically published to the environment and locale in which it was previously published in the source stack. If any exported content wasn’t published on any environment, that particular content won’t get published to any environment after it is imported into the target stack.
The cm:stacks:import command lets you import content to your destination stack. Below we have listed down different ways in which you can use the cm:stacks:import command:
Let's discuss in detail how you can import content into your stack.
This command lets you import content using a management token. For ease, you can pass several parameters/options to this command at once.
Usage
csdx cm:stacks:import -a <<alias>>
Alternatively, refer to the following command to add several parameters/options in a single line:
csdx cm:stacks:import -a <<alias>> -d <<path_of_folder_where_content_is_stored>>
Options
Note: If the --yes flag is not passed, you are prompted to enter an encryption key while importing the Marketplace App for the app configurations. You have 3 attempts to enter the correct encryption key for the Marketplace App configurations while using the import command. You must start the import process from the beginning after 3 failed attempts.
After importing the first module, note the name of the backup folder that was created in the workspace or in the code editor’s CLI folder.
Note: The parent backup folder created after the first import can be used to save all the backups in a single folder as it gets updated after every import operation.
When importing modules using the import command, provide the backup flag (b) along with the backup folder name as follows:
csdx cm:stacks:import -a <<alias>> -d <<path_of_folder_where_content_is_stored>> --module <<module>> --backup-dir <<backup_dir>>
Including the backup flag is essential when repeatedly using the single module import command. As these modules have inter-dependency, using the backup flag helps avoid any errors while importing.
For every module import operation, all the latest mapping files are added to a single mapper folder, and the dependent modules use the latest UIDs of the dependency for efficient mapping.
Examples
csdx cm:stacks:import -a mytoken -d "C:\Users\Name\Desktop\cli\content"
csdx cm:stacks:import -a mytoken -d "C:\Users\Name\Desktop\cli\content" --branch develop
csdx cm:stacks:import -a mytoken -d "C:\Users\Name\Desktop\cli\content" --module locales
csdx cm:stacks:import -a mytoken -d "C:\Users\Name\Desktop\cli\content" --module entries
csdx cm:stacks:import -a mytoken -d "C:\Users\Name\Desktop\cli\content" --module environments --branch _backup_123
csdx cm:stacks:import -a mytoken -d "C:\Users\Name\Desktop\cli\content" –y
Note: - When importing modules individually, make sure you follow this module sequence: locales > environments > assets > extensions > marketplace-apps > webhooks > global-fields > content-types > workflows > entries > labels > roles. For example, before importing entries, you must have had imported assets, environments, locales, extensions, webhooks, global-fields, content-types, and workflows.
- You cannot import a single entry to a stack using CLI.
This command lets you import content to your stack by using a management token and a configuration file that contains the parameters/options and the associated values.
To get started with this command, download this config file, add values to this file, and note down the path where you have saved this file.
By doing so, you don’t need to separately provide parameters/options in the command.
Usage
csdx cm:stacks:import -a <<alias>> -c <<config_file_path>>
Options
Example
csdx cm:stacks:import -a mytoken -c “C:/Users/Name/Desktop/cli/config.json”
You can use this method to import content to your stack if you have logged in to the session using the Login command. Running the Login command generates an auth token, which is used in the command below.
Usage
Refer to the command below to add several parameters/options in a single line:
csdx cm:stacks:import -k <<stack_ApiKey>> -d <<path_of_folder_where_content_is_stored>>
Note: If the management token is not specified, by default import command uses Auth token.
Options
Note: If the --yes flag is not passed, you are prompted to enter an encryption key while importing the Marketplace App for the app configurations. You have 3 attempts to enter the correct encryption key for the Marketplace App configurations while using the import command. You must start the import process from the beginning after 3 failed attempts.
After importing the first module, note the name of the backup folder that was created in the workspace or in the code editor’s CLI folder.
Note: The parent backup folder created after the first import can be used to save all the backups in a single folder as it gets updated after every import operation.
When importing modules using the import command, provide the backup flag (b) along with the backup folder name as follows:
csdx cm:stacks:import -k <<stack_ApiKey>> -d <<path_of_folder_where_content_is_stored>> --module <<module>> --backup-dir <<backup_dir>>
Including the backup flag is essential when repeatedly using the single module import command. As these modules have inter-dependency, using the backup flag helps avoid any errors while importing.
For every import module operation, all the latest mapping files are added to a single mapper folder, and the dependent modules use the latest UIDs of the dependency for efficient mapping.
Examples
csdx cm:stacks:import -k bltxxxxxx -d "C:\Users\Name\Desktop\cli\content"
csdx cm:stacks:import -k bltxxxxxx -d "C:\Users\Name\Desktop\cli\content" --branch develop
csdx cm:stacks:import -k bltxxxxxx -d "C:\Users\Name\Desktop\cli\content" --module locales
csdx cm:stacks:import -k bltxxxxxx -d "C:\Users\Name\Desktop\cli\content" --module entries
csdx cm:stacks:import -k bltxxxxxx -d "C:\Users\Name\Desktop\cli\content" --module environments --branch _backup_123
csdx cm:stacks:import -a mytoken -d "C:\Users\Name\Desktop\cli\content" –y
Note: - When importing modules individually, make sure you follow this module sequence: locales > environments > assets > extensions > marketplace-apps > webhooks > global-fields > content-types > workflows > entries > labels > roles. For example, before importing entries, you must have had imported assets, environments, locales, extensions, webhooks, global-fields, content-types, and workflows.
- You cannot import a single entry to a stack using CLI.
This command lets you import content to your stack by using auth token and a configuration file that contains the parameters/options and the associated values.
To get started with this command, download this config file, add values to this file, and note down the path where you have saved this file.
By doing so, you don’t need to separately provide parameters/ options in the command.
Usage
csdx cm:stacks:import -c <<config_file_path>>
Options
Example
csdx cm:stacks:import -c “C:/Users/Name/Desktop/cli/config.json”
You can import public and private Marketplace Apps to a stack using CLI commands.
Note: You must be logged in to your Contentstack account to perform the import operation on Marketplace Apps.
- You must have owner or admin rights to perform Marketplace Apps import.
- The destination organization should have Marketplace Apps support enabled.
- If you use a region other than NA, EU, or Azure NA, you must provide the Developer Hub URL for the specific region when prompted.
- To override the default Marketplace App Encryption Key you can replace the config.json file.
Public apps:
If an app with a configuration already exists in the destination organization, then while importing it from one organization to another, you can:
Private apps:
Note: The app name must be 3-20 characters long.
Note: If an error occurs while importing a private or public app, you will be prompted to confirm whether or not you should proceed with the process. If you do not proceed, the import process stops. If you proceed, the entries/content types/global fields may be affected.
Additional Resources: Check out the Export Content documentation to learn how you can export content from your stack using CLI.
Was this article helpful?
Thanks for your feedback