Query-based Export

View as Markdown
Last updated August 13, 2026

The Contentstack CLI Query Export Plugin gives you complete control over exporting specific content types and their dependencies using queries.

The Query-based Export plugin lets you perform the following operations in Contentstack CLI:

  • Migrating specific content types.
  • Backing up filtered content.
  • Managing environments efficiently.

Key Features

Prerequisites

Installation

Run the following command to install the plugin:

csdx plugins:install @contentstack/cli-cm-export-query

To verify the installation, run:

csdx plugins

Usage

csdx cm:stacks:export-query [OPTIONS]

Options

  • -k, --stack-api-key=stack-api-key: API key of the source stack.
  • --query=query: Query string or file path. Refer to the Query Format section.
  • -d, --data-dir=data-dir: Absolute path to the folder to store the exported content.
  • -a, --alias=alias: Management token alias of the source stack.
  • --branch=branch: [default: main] Name of the branch where you want to export content.
  • --branch-alias=branch-alias: Alias of the branch to export from. (Version: 1.0.0-beta.4 or above)

    Note If no branch or branch alias is provided, and the stack is branch-enabled, the default main branch will be exported.

  • -c, --config=config: Path to the configuration JSON file containing all options for a single run.
  • --skip-references: Skip referenced content types.
  • --skip-dependencies: Skip global fields, extensions, and taxonomies.
  • --secured-assets=secured-assets: [optional] Use this flag to export your content if the secured assets feature is enabled.
  • --yes, -y: [optional] Skip confirmation prompts.
  • --config, -c: [optional] Path to the configuration file.

Query Format

Use the following query structure to filter content types. Replace placeholders with appropriate field names and values.

{
  "modules": {
    "content-types": {
      "

Example Operators: $in, $regex, $gte

Additional Resource Refer to the Content Delivery API Queries for the full list of operators.

Examples

  • To export content types by title:
    csdx cm:stacks:export-query -a prod-alias --query '{"modules":{"content-types":{"title":{"$in":["Blog","Author"]}}}}'
  • To export using a query from a file:
    csdx cm:stacks:export-query -a prod-alias --query ./my-query.json
    
    my-query.json:
    {
      "modules": {
        "content-types": {
          "$and": [
            { "uid": { "$in": ["author","blog_post"] }}
          ]
        }
      }
    }

Supported Modules

  • Query-supported Module:
    • content-types: Schema and configuration of content types.
  • Automatically Exported Dependencies:
    • global-fields: Linked global fields
    • extensions: Standard and marketplace custom field extensions
    • marketplace-apps: Marketplace integrations
    • taxonomies: Referenced taxonomy definitions
  • Always Exported Modules:
    • stack: Stack metadata
    • locales: Language settings
    • environments: Deployment environments
    • personalize: Personalize the project
  • Content Data Modules:
    • entries: Entries of all exported content types
    • assets: All assets linked in exported entries

Limitations

  • Only content type queries are supported.
  • All asset folders are exported. Folder-level filtering is not supported.