Import Content using CLI

After you have exported the content from the stack, the next step is to import it into the destination stack. To do this, you can use the import command.

Note: Before you try the import commands, make sure you have unzipped the exported content's folder. 

Content can be imported in a stack for the following modules:

Prerequisites

Commands

The cm:import command lets you import content to your destination stack. Below we have listed down the ways in which you can use the import command:

Let's discuss in detail how you can import content in your stack.

Import Content Using Management Token and Parameters

Usage

csdx cm:import -a <management_token_alias>

You can add options/parameters to this command in a single line, as shown below:

csdx cm:import -a <management_token_alias> -l <master_language_code> -d <file_path> 

Options

  • -a, --management-token-alias=management-token-alias: The management token of the destination stack to which you will import the content
  • -l, --master-lang=master-lang: The code of the target stack’s master language
  • -d, --data=data: The path or the location in your file system where the content, you intend to import, is stored. For example, -d "C:\Users\Name\Desktop\cli\content"
  • -m, --module=module: (optional) Specify the module to import into the target stack. If not specified, the import command will import all the modules into the stack. The available modules are assets, content-types, entries, environments, extensions, global-fields, labels, locales, and webhooks

    Note: When importing  modules individually, make sure you follow this module sequence: locales > environments > extensions > webhooks > global-fields > assets > content-types > entries > labels.  For example, before importing entries, you must have had imported assets, environments, locales, extensions, webhooks, global-fields, and content-types.

Import Content Using Management Token and Config file

Usage

 csdx cm:import -a <management_token_alias> -c <config_file_path> 

Options

  • -a, --management-token-alias=management-token-alias: The management token of the destination stack to which you will import the content
  • -c, -config: The path of the JSON file containing all the options for a single run. You can refer to an example config file here

Import Content Using Auth Token and Parameters

Usage

csdx cm:import -A

You can add options/parameters to this command in a single line, as shown below:

csdx cm:import -A -s <stack_ApiKey> -l <master_language_code> -d <file_path> 

Options

  • -A, --auth-token: To use the auth token of the current session. It is automatically generated and stored in the session after running the login command.
  • -l, --master-lang=master-lang: The code of the target stack’s master language
  • -d, --data=data: The path or the location in your file system where the content, you intend to migrate, is stored. For example, -d "C:\Users\Name\Desktop\cli\content"
  • -s, --stack-uid-stack-uid: The API key of the target stack
  • -m, --module=module: (optional) Specify the module to import into the target stack. If not specified, the import command will import all the modules into the stack. The available modules are assets, content-types, entries, environments, extensions, global-fields, labels, locales, and webhooks.

    Note: When importing modules individually, make sure you follow this module sequence: locales > environments > extensions > webhooks > global-fields > assets > content-types > entries > labels. For example, before importing entries, you must have had imported assets, environments, locales, extensions, webhooks, global-fields, and content-types.

Import Content Using Auth Token and Config file

Usage

csdx cm:import -A -c <config_file_path> 

Options

  • -A, --auth-token: To use the auth token of the current session. It is automatically generated and stored in the session after running the login command.
  • -c, -config: The path of the configuration JSON file containing all the options for a single run. You can refer to an example config file here.

Limitations

  • The import commands will import only the latest version of a published entry/asset.
  • Currently, you cannot import content for the following modules:

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 feedbackSmile-icon

On This Page

^