Contentstack CLI Configuration Reference

View as Markdown

This reference outlines all configuration options available in Contentstack CLI plugins for export, import, audit, and content migrations tasks. It helps developers and administrators configure and manage CLI-based workflows across stacks.

Prerequisites

Before you begin, ensure that:

  • The CLI is installed and authenticated
  • You have stack access with the necessary permissions
  • You understand how configuration values are loaded (via config files, environment variables, or CLI flags)

What You’ll Learn

After reading this reference, you can:

  • Choose the correct CLI command and configuration for your task
  • Understand how configuration values are resolved across environment variables, root settings, module overrides, and defaults
  • Configure required and optional settings, including module-specific options
  • Optimize performance and avoid common configuration errors

Quick Reference

  • Export a stack or content:
    csdx cm:stacks:export
  • Import content into a stack:
    csdx cm:stacks:import
  • Export specific content only:
    csdx cm:stacks:export-query
  • Audit schema and entries:
    csdx cm:stacks:audit
  • Set up mapping and dependencies before import:
    csdx cm:stacks:import-setup
  • Run custom content transformations:
    csdx cm:stacks:migration

Environment Variables

The CLI supports environment variables that override config files and defaults. This is especially useful for CI/CD pipelines, local overrides, and handling sensitive settings such as encryption keys.

Note Environment variables have the highest priority in the configuration resolution order. Refer to the Configuration Precedence section for the complete hierarchy.

Supported CLI Configuration Environment Variables

VariableTypeDefaultDescription
CS_CLI_CONFIG_PATHstring-Custom path to the CLI configuration directory
CS_CLI_LOG_PATHstringprocess.cwd()Custom path for CLI log files
CONFIG_NAMEstringcontentstack_cliBase name of the configuration file (without extension)
ENC_CONFIG_NAMEstringcontentstack_cli_obfuscateName of the encrypted configuration file
ENC_KEYstringencryptionKeyEncryption key used for configuration files
ENCRYPT_CONFbooleantrueEnable/disable configuration encryption

Usage Examples

The following examples focus on environment variables that significantly impact CLI behavior or are commonly used in real-world workflows.

Change the default location for CLI log files

export CS_CLI_LOG_PATH="/path/to/logs"
csdx cm:stacks:export

Disable configuration file encryption

export ENCRYPT_CONF=false
csdx cm:stacks:import

NoteDisabling encryption is useful in CI environments where secrets are managed externally.

Use a custom directory for CLI configuration files

export CS_CLI_CONFIG_PATH="/path/to/config"
csdx cm:stacks:export

Configuration Precedence

Refer to this section when your CLI config includes both root and module-level values, and you need to understand which setting takes precedence.

Precedence Order

  1. Module-specific configuration (highest priority)
  2. Root-level configuration
  3. Default values (lowest priority)

How It Works

The CLI uses a recursive merge strategy (merge.recursive()) when loading configuration files. This means:

  • Module config overrides root config: If a key exists at both <module>.<key> and root-level <key>, the module-specific value is used.
  • Root config acts as a fallback: If a key is not defined at the module level, the CLI uses the root-level value.
  • Defaults are a last resort: If neither module nor root includes the key, the CLI falls back to default values.

Examples

Import Configuration Precedence

Example 1: importConcurrency for Entries Module

{
  "importConcurrency": 5,
  "modules": {
    "entries": {
      "importConcurrency": 10
    }
  }
}

Result: Entries module uses importConcurrency: 10 (module config), while other modules use importConcurrency: 5 (root config).

Code Reference: Refer to the entries.ts in the CLI repository.

Example 2: writeConcurrency for Content Types Module

{
  "writeConcurrency": 5,
  "modules": {
    "content-types": {
      "writeConcurrency": 8
    }
  }
}

Result: Content Types module uses writeConcurrency: 8 (module config), while other modules use writeConcurrency: 5 (root config).

Code Reference: See content-types.ts in the CLI repository.

Export Configuration Precedence

Example 3: chunkFileSize for Entries Module

{
  "modules": {
    "entries": {
      "chunkFileSize": 20
    }
  }
}

Result: Entries module uses chunkFileSize: 20 (module config). If not specified, it defaults to 10 (FsUtility default).

Example 4: fetchConcurrency for Assets Module

{
  "fetchConcurrency": 5,
  "modules": {
    "assets": {
      "fetchConcurrency": 10
    }
  }
}

Result: Assets module uses fetchConcurrency: 10 (module config), while other modules use fetchConcurrency: 5 (root config).

Common Keys with Precedence

The following table lists configuration keys that can be defined at both the root level and module level, along with their corresponding module override paths.

Root-Level KeyModule Override PathApplicable Commands
importConcurrencymodules.entries.importConcurrencyImport
fetchConcurrencymodules.<module>.fetchConcurrencyImport, Export
writeConcurrencymodules.<module>.writeConcurrencyImport, Export
chunkFileSizemodules.<module>.chunkFileSizeImport, Export
limitmodules.<module>.limitExport
batchLimitmodules.<module>.batchLimitExport

Best Practices

  • Define shared configuration values at the root level to apply them consistently across all modules.
  • Use module-specific configuration only when a module requires behavior that differs from the global defaults.
  • Avoid repeating the same configuration value at both root and module levels unless different behavior is intentionally required.
  • When validating or troubleshooting CLI behavior, review module-level configuration first.
  • Be aware that environment variables override configuration file values and can affect CLI behavior across commands.

Example – Recommended Pattern:

The following example demonstrates a recommended configuration pattern that balances shared defaults with targeted module overrides.

{
  "fetchConcurrency": 5,
  "writeConcurrency": 5,
  "modules": {
    "entries": {
      "importConcurrency": 10,
      "chunkFileSize": 20
    },
    "assets": {
      "fetchConcurrency": 10
    }
  }
}

In this example:

  • Most modules use fetchConcurrency: 5 and writeConcurrency: 5 from the root
  • The Entries module uses importConcurrency: 10 and chunkFileSize: 20 (module-specific overrides)
  • The Assets module overrides the root value with fetchConcurrency: 10

Export Configuration

Use this configuration to export stack content and metadata for backups, migrations, or moving content between stacks.

Command:

csdx cm:stacks:export

Default Configuration: See the default export configuration file in the CLI repository.

Basic Settings

OptionTypeDefaultRequiredDescription
contentVersionnumber2NoVersion of the export format
versioningbooleanfalseNoExport versioned entries
hoststring"https://api.contentstack.io/v3"NoBase URL for Content Management API
preserveStackVersionbooleanfalseNoPreserve stack version information
source_stackstring-YesAPI key of the source stack
datastring-YesPath to export directory
exportDirstring-NoAlias for data (export directory path)

Note The source_stack and data fields are required unless they are provided through CLI flags or an alias.

Path & Directory Settings

OptionTypeDefaultRequiredDescription
cliLogsPathstring-NoCustom path for CLI logs
branchNamestring-NoBranch name to export from
branchAliasstring-NoBranch alias to export from

Content Filtering

OptionTypeDefaultRequiredDescription
moduleNamestring-NoSpecific module to export
contentTypesstring[]-NoArray of content type UIDs
filteredModulesstring[]-NoAn array of module names to filter
queryobject|string-NoQuery object or file path for filtering

Performance Settings

OptionTypeDefaultRequiredDescription
fetchConcurrencynumber5NoNumber of parallel fetch operations
writeConcurrencynumber5NoNumber of parallel write operations
delayMsnumber-NoDelay in milliseconds between API requests
maxContentLengthnumber100000000NoMax content length in bytes (100 MB)
maxBodyLengthnumber100000000NoMax body length in bytes (100 MB)

Feature Flags

OptionTypeDefaultRequiredDescription
securedAssetsbooleanfalseNoExport secured assets
personalizationEnabledbooleanfalseNoEnable personalization features
skipStackSettingsbooleanfalseNoSkip exporting stack settings (not in default config, but supported)
skipDependenciesbooleanfalseNoSkip dependency resolution (not in default config, but supported)

Authentication

OptionTypeDefaultRequiredDescription
emailstring-NoEmail for basic authentication
passwordstring-NoPassword for basic authentication
management_tokenstring-NoManagement token (use --alias flag instead)

Advanced Settings

OptionTypeDefaultRequiredDescription
master_localeobject-NoMaster locale configuration
developerHubBaseUrlstring-NoBase URL for Developer Hub API
marketplaceAppEncryptionKeystring"nF2ejRQcTv"NoEncryption key for Marketplace apps

Note If a configuration value is defined at both the root level and a module level, the module-level value takes precedence for that module. See Configuration Precedence for more information.

Module-Specific Configuration

Assets Module

OptionTypeDefaultDescription
modules.assets.batchLimitnumber20Asset objects fetched per API call
modules.assets.chunkFileSizenumber1Size in MB for chunking large metadata JSON files (assets.json)
modules.assets.downloadLimitnumber5Parallel asset file downloads
modules.assets.fetchConcurrencynumber5Parallel fetch operations for asset metadata
modules.assets.includeVersionedAssetsbooleanfalseInclude versioned assets
modules.assets.securedAssetsbooleanfalseExport secured assets (adds auth token to asset URLs)
modules.assets.displayExecutionTimebooleanfalseDisplay execution time for batch operations
modules.assets.enableDownloadStatusbooleanfalseEnable download progress display for asset files
modules.assets.assetsMetaKeysstring[][uid, url, filename, parent_uid]Additional metadata keys to include
modules.assets.hoststringhttps://images.contentstack.ioCDN host for asset URLs

Entries Module

OptionTypeDefaultDescription
modules.entries.limitnumber100Entries fetched per API call per content type/locale
modules.entries.batchLimitnumber20Parallel entry version fetches when exportVersions is set to true (only used for version export)
modules.entries.exportVersionsbooleanfalseExport all versions of each entry
modules.entries.chunkFileSizenumber10Size in MB for chunking large entry JSON files (defaults to FsUtility default of 10 if not specified)
modules.entries.invalidKeysstring[]See the default below the tableKeys to exclude from exported entries
modules.entries.dependenciesstring[]['locales', 'content-types']Required modules that must be exported first

Default invalidKeys for Entry Module:

  • stackHeaders
  • content_type_uid
  • urlPath
  • created_at
  • updated_at
  • created_by
  • updated_by
  • _metadata
  • published

Note The downloadLimit is not used for entries export. It applies only to the assets module.

Precedence: Module-specific chunkFileSize, limit, and batchLimit are module-specific only and don't have root-level equivalents.

Content Types Module

OptionTypeDefaultDescription
modules.content-types.limitnumber100Content types fetched per API call
modules.content-types.validKeysstring[]See the default below the tableValid keys to export
modules.content-types.writeConcurrencynumber5Parallel file write operations (overrides root writeConcurrency if set)

Default validKeys for Content Type Module:

  • title
  • uid
  • field_rules
  • schema
  • options
  • singleton
  • description

Precedence: modules.content-types.writeConcurrency takes precedence over root-level writeConcurrency. If not set, falls back to the root writeConcurrency (default: 5).

Global Fields Module

OptionTypeDefaultDescription
modules.global-fields.limitnumber100Global fields fetched per API call
modules.global-fields.validKeysstring[]See the default below the tableValid keys to export

Default validKeys for Global Field Module:

  • title
  • uid
  • schema
  • options
  • singleton
  • description

Taxonomies Module

OptionTypeDefaultDescription
modules.taxonomies.limitnumber100Taxonomies fetched per API call
modules.taxonomies.invalidKeysstring[]See the default below the tableKeys to exclude from exported taxonomies

Default invalidKeys for Taxonomies Module:

  • updated_at
  • created_by
  • updated_by
  • stackHeaders
  • urlPath
  • created_at

Personalize Module

OptionTypeDefaultDescription
modules.personalize.baseURLobjectRegion-specificBase URLs for Personalize API by region
modules.personalize.exportOrderstring[]['attributes', 'audiences', 'events', 'experiences']Export order

Base URLs by Region:

  • AWS-NA: https://personalize-api.contentstack.com
  • AWS-EU: https://eu-personalize-api.contentstack.com
  • AWS-AU: https://au-personalize-api.contentstack.com
  • AZURE-NA: https://azure-na-personalize-api.contentstack.com
  • AZURE-EU: https://azure-eu-personalize-api.contentstack.com
  • GCP-NA: https://gcp-na-personalize-api.contentstack.com
  • GCP-EU: https://gcp-eu-personalize-api.contentstack.com

Locales Module

OptionTypeDefaultDescription
modules.locales.limitnumber100Locales fetched per API call
modules.locales.requiredKeysstring[]See the default below the tableRequired keys to export for locales

Default requiredKeys for Locales module:

  • code
  • uid
  • name
  • fallback_locale

Environments Module

OptionTypeDefaultDescription
modules.environments.limitnumber100Environments fetched per API call

Extensions Module

OptionTypeDefaultDescription
modules.extensions.limitnumber100Extensions fetched per API call

Stack Module

OptionTypeDefaultDescription
modules.stack.limitnumber100Stack data fetched per API call

Webhooks Module

OptionTypeDefaultDescription
modules.webhooks.limitnumber100Webhooks fetched per API call

Workflows Module

OptionTypeDefaultDescription
modules.workflows.limitnumber100Workflows fetched per API call
modules.workflows.invalidKeysstring[]See the default below the tableKeys to exclude from exported workflows

Default invalidKeys for Workflows module:

  • stackHeaders
  • urlPath
  • created_at
  • updated_at
  • created_by
  • updated_by

Labels Module

OptionTypeDefaultDescription
modules.labels.limitnumber100Labels fetched per API call
modules.labels.invalidKeysstring[]See the default below the tableKeys to exclude from exported labels

Default invalidKeys for Labels module:

  • stackHeaders
  • urlPath
  • created_at
  • updated_at
  • created_by
  • updated_by

Complete Export Configuration Example

The following example shows a complete export configuration, including commonly used options and module-level overrides.

{
  "contentVersion": 2,
  "versioning": false,
  "host": "https://api.contentstack.io/v3",
  "preserveStackVersion": false,
  "master_locale": {
    "name": "English - United States",
    "code": "en-us"
  },
  "source_stack": "bltXXXXXXXXXX",
  "data": "./export-data",
  "branchName": "main",
  "moduleName": null,
  "contentTypes": [],
  "securedAssets": false,
  "fetchConcurrency": 5,
  "writeConcurrency": 5,
  "delayMs": 1000,
  "maxContentLength": 100000000,
  "maxBodyLength": 100000000,
  "personalizationEnabled": false,
  "skipStackSettings": false,
  "skipDependencies": false,
  "developerHubBaseUrl": "",
  "marketplaceAppEncryptionKey": "nF2ejRQcTv",
  "modules": {
    "assets": {
      "batchLimit": 20,
      "chunkFileSize": 1,
      "downloadLimit": 5,
      "fetchConcurrency": 5,
      "includeVersionedAssets": false,
      "securedAssets": false,
      "displayExecutionTime": false,
      "enableDownloadStatus": false,
      "assetsMetaKeys": ["uid", "url", "filename", "parent_uid"],
      "host": "https://images.contentstack.io"
    },
    "entries": {
      "limit": 100,
      "batchLimit": 20,
      "exportVersions": false,
      "chunkFileSize": 10
    },
    "content-types": {
      "limit": 100,
      "validKeys": ["title", "uid", "field_rules", "schema", "options", "singleton", "description"]
    },
    "global-fields": {
      "validKeys": ["title", "uid", "schema", "options", "singleton", "description"]
    },
    "taxonomies": {
      "limit": 100
    },
    "personalize": {
      "baseURL": {
        "AWS-NA": "https://personalize-api.contentstack.com",
        "AWS-EU": "https://eu-personalize-api.contentstack.com",
        "AWS-AU": "https://au-personalize-api.contentstack.com",
        "AZURE-NA": "https://azure-na-personalize-api.contentstack.com",
        "AZURE-EU": "https://azure-eu-personalize-api.contentstack.com",
        "GCP-NA": "https://gcp-na-personalize-api.contentstack.com",
        "GCP-EU": "https://gcp-eu-personalize-api.contentstack.com"
      },
      "exportOrder": ["attributes", "audiences", "events", "experiences"]
    }
  }
}

Import Configuration

Use this configuration to import content and stack metadata into a target stack, typically after an export or as part of a migration workflow. This section describes the root-level and module-specific options that control how content is imported and published.

Command: csdx cm:stacks:import

Default Configuration: Refer to the default import configuration file in the CLI repository.

Basic Settings

OptionTypeDefaultRequiredDescription
versioningbooleanfalseNoImport versioned entries
hoststring"https://api.contentstack.io/v3"NoBase URL for Content Management API
extensionHoststring"https://app.contentstack.com"NoBase URL for Contentstack application
contentVersionnumber-NoVersion of the import format
preserveStackVersionbooleanfalseNoPreserve stack version information
target_stackstring-Yes*API key of target stack
datastring-Yes*Path to import directory
contentDirstring-NoAlias for data

Note The target_stack and data fields are required unless they are provided through CLI flags or a management token alias.

Path & Directory Settings

OptionTypeDefaultRequiredDescription
cliLogsPathstring-NoCustom path for CLI logs
backupDirstring-NoPath to backup directory
branchNamestring"main"NoBranch name to import into
branchAliasstring-NoBranch alias to import into

Content Filtering

OptionTypeDefaultRequiredDescription
moduleNamestring-NoSpecific module to import
contentTypesstring[]-NoArray of content type UIDs
modulesstring[]-NoArray of module names to import

Performance Settings

OptionTypeDefaultRequiredDescription
concurrencynumber1NoGeneral concurrency level
importConcurrencynumber5NoNumber of parallel import operations
fetchConcurrencynumber5NoNumber of parallel fetch operations
writeConcurrencynumber5NoNumber of parallel write operations
delayMsnumber-NoDelay in milliseconds between requests
maxContentLengthnumber100000000NoMax content length in bytes (100 MB)
maxBodyLengthnumber100000000NoMax body length in bytes (100 MB)

Recommended starting point: Start by tuning importConcurrency, which controls overall import parallelism. Use module-level overrides for targeted optimization, and treat fetchConcurrency and writeConcurrency as advanced tuning options.

Publish Settings

OptionTypeDefaultRequiredDescription
skipAssetsPublishboolean-NoSkip asset publishing
skipEntriesPublishboolean-NoSkip entry publishing
entriesPublishbooleantrueNoPublish entries after import

Feature Flags

OptionTypeDefaultRequiredDescription
skipAuditboolean-NoSkip audit fix during import
skipExistingboolean-NoSkip "module exists" warnings
replaceExistingboolean-NoReplace existing modules
exclude-global-modulesbooleanfalseNoExclude branch-independent modules (global modules are shared across all branches in a stack; see Contentstack documentation)
skipPrivateAppRecreationIfExistboolean-NoSkip recreation of existing private apps

Advanced Settings

OptionTypeDefaultRequiredDescription
importWebhookStatusstring"disable"NoWebhook state: "disable" or "current"
personalizeProjectNamestring-NoUnique name for the Personalize project
developerHubBaseUrlstring-NoBase URL for Developer Hub API
marketplaceAppEncryptionKeystring"nF2ejRQcTv"NoEncryption key for Marketplace apps
getEncryptionKeyMaxRetrynumber3NoMax retry attempts for encryption key
auditConfigobject-NoConfiguration for audit process
master_localeobject-NoMaster locale configuration

Authentication

OptionTypeDefaultRequiredDescription
emailstring-NoEmail for basic authentication
passwordstring-NoPassword for basic authentication
management_tokenstring-NoManagement token (use --alias flag instead)

Configuration Precedence

Note When the same configuration key exists at both the root level and module level, module-specific configuration takes precedence.

For example, if you set importConcurrency: 5 at root and modules.entries.importConcurrency: 10, the entries module uses 10.

Additional Resource Refer to the Configuration Precedence section for a detailed explanation and examples.

Module-Specific Configuration

Assets Module

OptionTypeDefaultDescription
modules.assets.assetBatchLimitnumber1Assets processed per batch
modules.assets.uploadAssetsConcurrencynumber2Assets uploaded in parallel
modules.assets.importFoldersConcurrencynumber1Folders processed in parallel
modules.assets.importSameStructurebooleantrueMaintain folder structure
modules.assets.includeVersionedAssetsbooleanfalseInclude versioned assets
modules.assets.displayExecutionTimebooleanfalseDisplay execution time
modules.assets.hoststring"https://api.contentstack.io"API host for asset operations
modules.assets.validKeysstring[]See defaultValid keys to import for assets
modules.assets.folderValidKeysstring[]See defaultValid keys to import for folders

Default validKeys: ["title", "parent_uid", "description", "tags"]

Default folderValidKeys: ["name", "parent_uid"]

Note Folder hierarchy during import follows folders.json, not modules.assets.importSameStructure. The importSameStructure setting (default: true) only controls asset replace or skip behavior.

Entries Module

OptionTypeDefaultDescription
modules.entries.importConcurrencynumber5Parallel entry import operations (overrides root importConcurrency if set)
modules.entries.chunkFileSizenumber10Size in MB for chunking large entry mapper JSON files (defaults to FsUtility default of 10 if not specified)
modules.entries.invalidKeysstring[]See defaultKeys to exclude from entry mapper files

Default invalidKeys: ['created_at', 'updated_at', 'created_by', 'updated_by', '_metadata', 'published']

Note limit and assetBatchLimit are defined in config but not actively used in the entries import code.

Precedence: modules.entries.importConcurrency takes precedence over root-level importConcurrency. If not set, falls back to root importConcurrency (default: 5).

Content Types Module

OptionTypeDefaultDescription
modules.content-types.limitnumber100Content types processed per batch
modules.content-types.validKeysstring[]See defaultValid keys to import
modules.content-types.writeConcurrencynumber5Parallel content type operations (overrides root writeConcurrency if set)

Default validKeys: ["title", "uid", "schema", "options", "singleton", "description"]

Precedence: modules.content-types.writeConcurrency takes precedence over root-level writeConcurrency. If not set, falls back to root writeConcurrency (default: 5).

Global Fields Module

OptionTypeDefaultDescription
modules.global-fields.limitnumber100Global fields processed per batch
modules.global-fields.validKeysstring[]See defaultValid keys to import
modules.global-fields.writeConcurrencynumber5Parallel global field operations (overrides root writeConcurrency if set)

Default validKeys: ["title", "uid", "schema", "options", "singleton", "description"]

Precedence: modules.global-fields.writeConcurrency takes precedence over root-level writeConcurrency. If not set, falls back to root writeConcurrency (default: 5).

Locales Module

OptionTypeDefaultDescription
modules.locales.writeConcurrencynumber5Parallel locale operations (overrides root writeConcurrency if set)
modules.locales.requiredKeysstring[]See defaultRequired keys to import for locales

Default requiredKeys: ['code', 'uid', 'name', 'fallback_locale']

Precedence: modules.locales.writeConcurrency takes precedence over root-level writeConcurrency. If not set, falls back to root writeConcurrency (default: 5).

Environments Module

OptionTypeDefaultDescription
modules.environments.fetchConcurrencynumber2Parallel environment operations (overrides root fetchConcurrency if set)

Precedence: modules.environments.fetchConcurrency takes precedence over root-level fetchConcurrency. If not set, falls back to root fetchConcurrency (default: 5), but the module default is 2.

Extensions Module

OptionTypeDefaultDescription
modules.extensions.concurrencynumber1Parallel extension operations (falls back to fetchConcurrency if not set)
modules.extensions.validKeysstring[]See defaultValid keys to import for extensions

Default validKeys: ['data_type', 'srcdoc', 'title', 'type', 'multiple', 'config']

Taxonomies Module

OptionTypeDefaultDescription
modules.taxonomies.dirNamestring"taxonomies"Directory name for taxonomies
modules.taxonomies.fileNamestring"taxonomies.json"File name for taxonomies data

Personalize Module

OptionTypeDefaultDescription
modules.personalize.baseURLobjectRegion-specificBase URLs for Personalize API by region
modules.personalize.importDatabooleantrueEnable/disable Personalize data import
modules.personalize.importOrderstring[]['attributes', 'audiences', 'events', 'experiences']Import order
modules.personalize.project_idstring""Personalize project ID (auto-populated)
modules.personalize.experiences.thresholdTimernumber60000Timer threshold in milliseconds
modules.personalize.experiences.checkIntervalDurationnumber10000Check interval duration in milliseconds

Base URLs: Same as Export configuration (see Export section above).

Variant Entry Module

OptionTypeDefaultDescription
modules.variantEntry.apiConcurrencynumber5Parallel API calls
modules.variantEntry.query.localestring"en-us"Locale for variant entry queries

General Module Settings

OptionTypeDefaultDescription
modules.apiConcurrencynumber5General API concurrency for modules

Complete Import Configuration Example

{
  "versioning": false,
  "host": "https://api.contentstack.io/v3",
  "extensionHost": "https://app.contentstack.com",
  "contentVersion": 2,
  "preserveStackVersion": false,
  "master_locale": {
    "name": "English - United States",
    "code": "en-us"
  },
  "target_stack": "bltXXXXXXXXXX",
  "data": "./import-data",
  "branchName": "main",
  "moduleName": null,
  "contentTypes": [],
  "skipAssetsPublish": false,
  "skipEntriesPublish": false,
  "entriesPublish": true,
  "concurrency": 1,
  "importConcurrency": 5,
  "fetchConcurrency": 5,
  "writeConcurrency": 5,
  "delayMs": 1000,
  "maxContentLength": 100000000,
  "maxBodyLength": 100000000,
  "skipAudit": false,
  "skipExisting": false,
  "replaceExisting": false,
  "importWebhookStatus": "disable",
  "personalizeProjectName": null,
  "exclude-global-modules": false,
  "skipPrivateAppRecreationIfExist": false,
  "backupDir": "./backup",
  "createBackupDir": "./temp",
  "cliLogsPath": "./logs",
  "developerHubBaseUrl": "",
  "marketplaceAppEncryptionKey": "nF2ejRQcTv",
  "getEncryptionKeyMaxRetry": 3,
  "auditConfig": {
    "noLog": false,
    "skipConfirm": true,
    "returnResponse": true,
    "noTerminalOutput": false,
    "config": {
      "basePath": ""
    }
  },
  "modules": {
    "apiConcurrency": 5,
    "assets": {
      "assetBatchLimit": 1,
      "uploadAssetsConcurrency": 2,
      "importFoldersConcurrency": 1,
      "importSameStructure": true,
      "includeVersionedAssets": false,
      "displayExecutionTime": false,
      "host": "https://api.contentstack.io",
      "validKeys": ["title", "parent_uid", "description", "tags"],
      "folderValidKeys": ["name", "parent_uid"]
    },
    "entries": {
      "limit": 50,
      "assetBatchLimit": 5
    },
    "content-types": {
      "limit": 100,
      "validKeys": ["title", "uid", "schema", "options", "singleton", "description"]
    },
    "global-fields": {
      "limit": 100,
      "validKeys": ["title", "uid", "schema", "options", "singleton", "description"]
    },
    "taxonomies": {
      "dirName": "taxonomies",
      "fileName": "taxonomies.json"
    },
    "personalize": {
      "baseURL": {
        "AWS-NA": "https://personalize-api.contentstack.com",
        "AWS-EU": "https://eu-personalize-api.contentstack.com",
        "AWS-AU": "https://au-personalize-api.contentstack.com",
        "AZURE-NA": "https://azure-na-personalize-api.contentstack.com",
        "AZURE-EU": "https://azure-eu-personalize-api.contentstack.com",
        "GCP-NA": "https://gcp-na-personalize-api.contentstack.com",
        "GCP-EU": "https://gcp-eu-personalize-api.contentstack.com"
      },
      "importData": true,
      "importOrder": ["attributes", "audiences", "events", "experiences"],
      "project_id": "",
      "experiences": {
        "thresholdTimer": 60000,
        "checkIntervalDuration": 10000
      }
    },
    "variantEntry": {
      "apiConcurrency": 5,
      "query": {
        "locale": "en-us"
      }
    }
  }
}

Best Practices for CLI Import and Backup

Follow these best practices for Contentstack CLI imports:

  • Set branchName or branchAlias for non-default branch imports. Verify the branch exists (or the alias resolves). The CLI does not create branches, so the import fails if the branch is missing.
  • Backup your export data using one of these methods:
    • Create a new backup: Set createBackupDir to a dedicated path in the config. If that path already exists, the CLI removes it before creating the backup directory and copying your export data.
    • Reuse an existing backup: Pass the --backup-dir flag or set useBackedupDir in the config.

    Note After each run, the CLI logs the actual backupDir used. Setting backupDir in the config alone does not control the backup location. Use createBackupDir or useBackedupDir (or --backup-dir) to define it.

  • Verify content publishing behavior before import using entriesPublish, skipEntriesPublish, and skipAssetsPublish.

Warning skipExisting and replaceExisting are high-impact flags that control whether content is skipped or overwritten.

Audit Configuration

Use the Audit configuration to analyze stack schemas and entries for structural or data-related issues. Audit identifies inconsistencies and provides a summary of potential problems across supported modules.

Workflow

Follow this workflow to ensure a safe and predictable migration:

  • Export: Export stack content with the CLI into the expected folder layout.
  • Audit: Run csdx cm:stacks:audit against that folder (read-only; reports under audit-report).
  • Fix (optional): Run csdx cm:stacks:audit:fix only when you want to modify files; use --copy-dir or --copy-path to keep a safe copy.
  • Import / migrate: Import or migrate using the cleaned export in a separate step.

Note Audit does not export or import data. Always point --data-dir or basePath to the root of your export.

Command: csdx cm:stacks:audit

Default Configuration: Refer to the default audit configuration file in the CLI repository to understand included modules, supported fixes, and reporting behavior.

Basic Settings

OptionTypeDefaultRequiredDescription
showTerminalOutputbooleantrueNoDisplay output on the terminal
skipRefsstring[]['sys_assets']NoSkip specified references during audit
skipFieldTypesstring[]['taxonomy', 'group']NoSkip specified field types during audit
fixSelectFieldbooleanfalseNoFix select field issues

Module Configuration

Limit audit modules to shorten runs on large exports, skip unnecessary areas, or narrow testing. The modules array defines these audit pipelines.

Supported modules:

  • content-types
  • entries
  • assets
OptionTypeDefaultRequiredDescription
modulesstring[]See defaultNoSpecify modules to include in the audit

Default modules: ['content-types', 'global-fields', 'entries', 'extensions', 'workflows', 'custom-roles', 'assets', 'field-rules']

Field Configuration

OptionTypeDefaultRequiredDescription
fix-fieldsstring[]See defaultNoField types that can be fixed
schema-fields-data-typestring[]See defaultNoSchema field data types to check

Default fix-fields: ['reference', 'global_field', 'json:rte', 'json:extension', 'blocks', 'group', 'content_types']

Default schema-fields-data-type: ['blocks', 'group', 'global_field']

Entry System Keys

OptionTypeDefaultRequiredDescription
entries.systemKeysstring[]See defaultNoDefine system keys to include when auditing entries

Default systemKeys: ['uid', 'ACL', 'tags', 'locale', '_version', '_metadata', 'published', 'created_at', 'updated_at', 'created_by', 'updated_by', '_in_progress', '_restore_status', 'publish_details']

External Configuration

When using the --config flag with audit commands, you can pass external configuration options.

OptionTypeDefaultRequiredDescription
noLogbooleanfalseNoSkip printing logs on the terminal
skipConfirmbooleantrueNoSkip confirmation before writing fixes (cm:stacks:audit:fix); when false, user may be prompted unless --yes / copy-dir applies
returnResponsebooleantrueNoReturn the resolved runtime configuration and fix status when using cm:stacks:audit:fix
noTerminalOutputbooleanfalseNoSkip the final audit table output on the terminal
basePathstring""NoDirectory containing export data to audit (overrides default; equivalent to --data-dir for scope)
Note
  • noLog, noTerminalOutput, and returnResponse control logging, terminal UX, and command returns. They do not change the executed audit rules.
  • skipConfirmApplies fixes without interactive confirmation prompts. Use this with the cm:stacks:audit:fix command.

Example external config file:

{
  "noLog": false,
  "skipConfirm": true,
  "returnResponse": true,
  "noTerminalOutput": false,
  "basePath": "./export-data"
}

Best Practices for Audit

Follow these practices when using the Audit plugin:

  • Use CLI export data in the expected layout. Review the default audit configuration for details. Older or non-CLI exports might lack matching module paths and filenames.
  • Set --data-dir or basePath to the root of the exported data. For branch-enabled stacks, point directly to the branch folder inside the export and not to a parent directory.
  • Use --copy-dir with cm:stacks:audit:fix to back up the export before writing fixes. Use --copy-path to specify a custom backup location. Avoid applying fixes directly to your main copy.
  • Split large audits using --modules or the modules config to reduce memory usage and isolate issues. The entries module is typically the most resource-intensive.
  • Increase Node.js memory (for example, NODE_OPTIONS=--max-old-space-size=4096) if audit runs fail on very large datasets.
  • Use --fix-only for targeted fixes instead of applying all supported fix types.
  • Use skipConfirm: true in non-interactive environments to apply fixes without prompts. Always maintain a backup or version-controlled copy before running fixes.

Query-Export Configuration

Use this configuration when you need to export a subset of stack content that matches a specific query, rather than exporting the entire stack. A successful run creates an export directory containing the matched content and a query metadata file describing the export.

A successful query export creates the specified exportDir containing the exported modules and a _query-meta.json file that describes the export.

Command: csdx cm:stacks:export-query

Basic Settings

OptionTypeDefaultRequiredDescription
contentVersionnumber2NoVersion of the export format
hoststring"https://api.contentstack.io/v3"NoBase URL for Content Management API
exportDirstring-YesPath to export directory
stackApiKeystring-YesAPI key of source stack
branchNamestring-NoBranch name to export from
branchAliasstring-NoBranch alias to export from

Note The exportDir and stackApiKey fields are required unless they are provided through CLI flags or a management token alias.

Query Settings

OptionTypeDefaultRequiredDescription
queryobject|string-Yes*Query object or file path for filtering. See Query field format below.
skipReferencesbooleanfalseNoExport only the matched entries or assets, without including the referenced content chain.
skipDependenciesbooleanfalseNoExclude dependent modules such as Apps, Taxonomies, and other related components.
skipStackSettingsbooleanfalseNoExport content only, and omit all stack-level settings.
maxCTReferenceDepthnumber20NoMax depth for content type references

Query field format (object | string)

The query field supports two formats based on where it is defined: CLI input (string) and config file (object).

CLI (--query as a string)

Pass the query as either a file path or inline JSON:

  • If the value contains .json, /, or \, the CLI treats it as a file path and loads the JSON.
  • Otherwise, it parses the value using JSON.parse, so it must be valid JSON.

Config file (as an object)

Define module-specific filters under query.modules.<moduleName>:

  • Do not use a flat query object for filtering.
  • Each module filter is merged into the corresponding module API request.

For entries:

  • The filter is applied inside the nested query object used by the Content Management API.
  • Supports Mongo-style operators such as $regex.

Example:

{
 "query": {
   "modules": {
     "entries": {
       "title": { "$regex": "blog" }
     }
   }
 }
}

Performance Settings

OptionTypeDefaultRequiredDescription
fetchConcurrencynumber5NoNumber of parallel fetch operations
writeConcurrencynumber5NoNumber of parallel write operations
batchSizenumber100NoNumber of items per batch

Feature Flags

OptionTypeDefaultRequiredDescription
securedAssetsbooleanfalseNoExport secured assets
personalizationEnabledbooleanfalseNoEnable personalization features

Query Configuration

OptionTypeDefaultDescription
queryConfig.maxRecursionDepthnumber10Maximum depth for recursive query processing
queryConfig.batchSizenumber100Number of items per batch
queryConfig.metadataFileNamestring"_query-meta.json"Name of the metadata file
queryConfig.validation.maxQueryDepthnumber5Maximum depth of nested queries
queryConfig.validation.maxArraySizenumber1000Maximum size of arrays in queries
queryConfig.validation.allowedDateFormatsstring[]['ISO8601', 'YYYY-MM-DD', 'MM/DD/YYYY']Allowed date formats

Module Configuration

You can set these modules.* keys in any order in your JSON file. The modules.exportOrder key controls the runtime sequence of the export. Keep the default setting unless you understand module dependencies, such as exporting stacks and locales before content types and entries.

Warning Arbitrary reordering can break or omit data.

OptionTypeDefaultDescription
modules.generalstring[]['stack', 'locales', 'environments']Always exported modules
modules.queryablestring[]['content-types']Modules that can be queried
modules.dependentstring[]['global-fields', 'extensions', 'marketplace-apps', 'taxonomies', 'personalize']Dependent modules
modules.contentstring[]['entries', 'assets']Content modules
modules.exportOrderstring[]See defaultExport order based on dependencies

Default exportOrder: ['stack', 'locales', 'environments', 'content-types', 'global-fields', 'extensions', 'taxonomies', 'entries', 'assets']

Note The modules.dependent array includes marketplace-apps and personalize in addition to the listed modules.

Authentication

OptionTypeDefaultRequiredDescription
managementTokenstring-NoManagement token. (Use --alias flag instead)

Complete Query-Export Configuration Example

{
  "contentVersion": 2,
  "host": "https://api.contentstack.io/v3",
  "exportDir": "./query-export-data",
  "stackApiKey": "bltXXXXXXXXXX",
  "branchName": "main",
  "query": {
    "title": {
      "$regex": "blog"
    }
  },
  "skipReferences": false,
  "skipDependencies": false,
  "skipStackSettings": false,
  "securedAssets": false,
  "fetchConcurrency": 5,
  "writeConcurrency": 5,
  "batchSize": 100,
  "personalizationEnabled": false,
  "maxCTReferenceDepth": 20,
  "queryConfig": {
    "maxRecursionDepth": 10,
    "batchSize": 100,
    "metadataFileName": "_query-meta.json",
    "validation": {
      "maxQueryDepth": 5,
      "maxArraySize": 1000,
      "allowedDateFormats": ["ISO8601", "YYYY-MM-DD", "MM/DD/YYYY"]
    }
  },
  "modules": {
    "general": ["stack", "locales", "environments"],
    "queryable": ["content-types"],
    "dependent": ["global-fields", "extensions", "marketplace-apps", "taxonomies", "personalize"],
    "content": ["entries", "assets"],
    "exportOrder": [
      "stack",
      "locales",
      "environments",
      "content-types",
      "global-fields",
      "extensions",
      "taxonomies",
      "entries",
      "assets"
    ]
  }
}

Import-Setup Configuration

Use this configuration to prepare module dependencies and mappings required for a successful import. Import-Setup is typically run before the Import command to ensure dependent modules are created in the correct order.

Command: csdx cm:stacks:import-setup

Basic Settings

OptionTypeDefaultRequiredDescription
hoststring"https://api.contentstack.io/v3"NoSpecify the base URL for Content Management API
developerHubBaseUrlstring""NoSpecify the base URL for the Developer Hub API
fetchConcurrencynumber5NoControl the number of parallel fetch operations

Module Configuration

Each module can specify dependencies that must be imported first.
Dependencies define the order in which modules are imported. The CLI uses them to automatically import required modules first, avoiding reference or schema errors.

ModuleOptionTypeDefaultRequiredDescription
custom-rolesmodules.custom-roles.dependenciesstring[]['environments', 'entries']NoDefine required module dependencies
localesmodules.locales.dependenciesstring[][]NoDefine required module dependencies
environmentsmodules.environments.dependenciesstring[]-NoDefine required module dependencies
extensionsmodules.extensions.dependenciesstring[]-NoDefine required module dependencies
assetsmodules.assets.fetchConcurrencynumber5NoFetch concurrency for assets
content-typesmodules.content-types.dependenciesstring[]['extensions', 'marketplace-apps', 'taxonomies']NoDefine required module dependencies
entriesmodules.entries.dependenciesstring[]['assets', 'extensions', 'marketplace-apps', 'taxonomies']NoDefine required module dependencies
global-fieldsmodules.global-fields.dependenciesstring[]['extensions', 'marketplace-apps']NoDefine required module dependencies
marketplace-appsmodules.marketplace-apps.dependenciesstring[]-NoDefine required module dependencies
taxonomiesmodules.taxonomies.invalidKeysstring[]See defaultNoKeys to exclude during import

Default taxonomies invalidKeys: ['updated_at', 'created_by', 'updated_by', 'stackHeaders', 'urlPath', 'created_at', 'ancestors', 'update', 'delete', 'fetch', 'descendants', 'move', 'search']

Migration Configuration

Use Migration Configuration to run user-defined scripts during CLI execution for advanced schema or content changes beyond export and import.
Running a migration executes the specified script against the target stack.

Key Considerations for Running Migrations

  • Script controls all changes: The script fully determines all content and schema changes. The CLI does not validate, restrict, or preview the resulting operations.
  • Permissions define impact: Migrations run with the configured management token or session, so the scope of changes depends entirely on that credential’s permissions. The CLI does not add restrictions. Use least-privilege tokens to limit risk.
  • No built-in safety checks: The CLI does not prompt before destructive or bulk actions (for example, deleting a content type). Add safeguards in your script, such as prompts, environment checks, or conditional logic.

Note Migration behavior depends on the logic defined in the migration script. Test migrations in non-production environments before applying them to production stacks.

Command: csdx cm:stacks:migration

Configuration Options

Migration uses either an inline configuration or external JSON files.

Inline Configuration

Use the --config flag with key-value pairs:

csdx cm:migration --config <key1:value1> <key2:value2> --file-path <migration/script/file/path>

Replace the placeholders with keys expected by your script.

External Configuration File

Use the --config-file flag with a JSON file:

{
  "apiKey": "your-api-key",
  "managementToken": "your-management-token",
  "branch": "main",
  "customKey": "customValue"
}

Note Migration configuration is script-specific and varies based on your unique migration requirements.

Additional Resources