Cloning a Stack

View as Markdown
Last updated November 6, 2026

Overview

Contentstack enables you to clone a stack and its associated structure and content using the cm:stacks:clone CLI command. This process lets you export data from a source stack and import it into a new or existing stack, facilitating rapid setup, testing, or migration. This guide uses the latest Contentstack CLI commands to ensure a seamless cloning experience.

Note Before executing this command, ensure you have the required permissions for creating or accessing the destination stack. To know more about user roles and their permissions, refer to this documentation.

Prerequisites

Commands

The cm:stacks:clone command lets you export content from the source stack and import it into the destination stack instantly.

NoteBy default, an audit fix is performed on the exported content before import. This helps identify and address potential issues in the exported data.

Options

Use the following options while performing the clone operation:

FlagShort FlagTypeRequiredDefaultDescription
--source-branch-stringNo-Branch of the source stack. Cannot be used with --source-branch-alias.
--source-branch-alias-stringNo-Alias of the branch of the source stack. Cannot be used with --source-branch.
--target-branch-stringNo-Branch of the target stack. Cannot be used with --target-branch-alias.
--target-branch-alias-stringNo-Alias of the branch of the target stack. Cannot be used with --target-branch.
--source-management-token-alias-stringNo-Source management token alias.
--destination-management-token-alias-stringNo-Destination management token alias.
--stack-name-nstringNo. Prompted when creating a new stack-Provide a name for the new stack to store the cloned content.
--type-stringNo. Prompted if omitted- Type of data to clone.

Supported values: a, b

a: Structure (all modules except entries and assets).

b: Structure with content (all modules including entries and assets).

--source-stack-api-key-stringNo. Prompted to choose a stack if omitted-Source stack API key.
--destination-stack-api-key-stringNo. Prompted to create or choose a stack if omitted-Destination stack API key.
--import-webhook-status-stringNodisable [Optional] The status of the import webhook.

Supported values: disable, current

Default: disable

--yes-ybooleanNo-Force override all Marketplace prompts.
--skip-audit-booleanNo-[Optional] Skips the audit fix that occurs during an import operation.
--config-cstringNo-Path for the external configuration.

Below is an example of a config file

{
    "master_locale": {
        "name": "English - United States",
        "code": "en-us"
      },
    "export": { 
              // export specific configs
             "fetchConcurrency": 1
      } ,
    "import": { 
              // import specific configs
             "entriesPublish": false
      }
}

On passing the --config flag, the config will be passed to export and import in the --clone command. You can pass separate or common config for export and import as given in the above sample config file.

Note If the --yes flag is not passed, you’ll be prompted to enter an encryption key when cloning a Marketplace app with its configuration. You have three attempts to provide the correct key. After three failed attempts, the cloning process must be restarted from the beginning.

Steps to Clone a Stack

Follow the steps below to clone a stack using the cm:stacks:clone command:

  1. Run the following command in your terminal:
    csdx cm:stacks:clone
  2. Choose the organization from the displayed list.
  3. Select the stack you want to clone.
  4. Choose the branch of the stack.
  5. Choose whether to clone content to a new stack or use an existing one:
    • Y: Create a new stack.
      • Select the destination organization.
      • The default name format: Copy of {source_stack_name}.
      • You can provide a custom name for the new stack.
    • n: Use an existing stack.
      • Select the destination organization and stack (must have permissions).

    Tip To minimize errors, we recommend creating a new destination stack. If importing content into an existing stack, ensure that it is empty.

  6. Select one of the following types of content to clone:
    • Structure: Imports only the schema (no entries/assets).
    • Structure with content: Imports schema, entries, and assets.

After you complete these prompts, the source stack’s content will be cloned to the destination stack.

Alternatively, you can also run the entire operation using a single command with parameters as given below:

csdx cm:stacks:clone -n "<>" --source-management-token-alias "<>" --destination-management-token-alias "<>" --target-branch "<>" --source-branch "<>" --type a|b {choose either a or b} -y

Examples:

  • To clone content using management token aliases:
    csdx cm:stacks:clone --source-management-token-alias <<management token alias for source>> --destination-management-token-alias <<management token alias for destination>>
  • To clone content and force override all Marketplace prompts:
    csdx cm:stacks:clone --source-management-token-alias <<management token alias for source>> --destination-management-token-alias <<management token alias for destination>> --yes

Points to Remember

  • To import content into an existing stack, ensure you have permissions to create or update content in that stack.
  • Currently, we migrate only the latest version of entries and assets.
  • To create a new stack, you must have the owner or admin rights in the destination organization.
  • The clone republishes each taxonomy to the environments it was published to in the source stack. The cm:stacks:clone command has no option to turn this off. To import without publishing taxonomies, run cm:stacks:export and then cm:stacks:import with --skip-taxonomy-publish.
  • During workflow migration, admins and workflow stage users are not included. These must be manually reconfigured after cloning.
  • The clone function supports the same modules as the CLI export and import commands.

Additional ResourcesLearn more about the CLI-supported clone operations in the CLI-Supported Features for Export, Import, and Clone Operations document.

Examples

Clone both structure and content into a brand new stack, naming it as you go.

csdx cm:stacks:clone --source-stack-api-key <SOURCE_API_KEY> --stack-name <NEW_STACK_NAME> --type a

Clone into an existing destination stack using saved management token aliases rather than API keys.

csdx cm:stacks:clone --source-management-token-alias <SOURCE_ALIAS> --destination-management-token-alias <DEST_ALIAS>

Clone one branch into another, skipping the audit fix that otherwise runs during the import half of the operation.

csdx cm:stacks:clone --source-stack-api-key <SOURCE_API_KEY> --destination-stack-api-key <DEST_API_KEY> --source-branch <SOURCE_BRANCH> --target-branch <TARGET_BRANCH> --skip-audit

Limitations

  • --type a clones structure only. Entries and assets are not cloned unless --type b is used.
  • --source-branch and --source-branch-alias are mutually exclusive, as are --target-branch and --target-branch-alias.
  • The import webhook in the cloned stack is disabled by default (--import-webhook-status defaults to disable). Pass --import-webhook-status current to carry over the source webhook's status instead.