The Contentful CLI (Command Line Interface) tool allows developers to interact with Contentful features directly from their terminal. It supports managing spaces (listing, creating, deleting), exporting and importing content, executing and generating migration scripts using the Contentful Migration DSL, seeding spaces with example data, and managing extensions. The current stable version is `4.0.0`. The project maintains an active release cadence, with minor and patch versions frequently released, often monthly or bi-monthly, addressing bugs and adding new features like organization security checks. Its key differentiators include deep integration with Contentful's content management and delivery APIs, robust migration capabilities, and recently, features for assessing organization security posture. It is a critical tool for automating content workflows and managing Contentful projects programmatically.
npm install contentful-cliVerified import paths — ran on the pinned version, not inferred.
Demonstrates global installation, logging into Contentful via OAuth, listing spaces, exporting a space, and accessing command-specific help.
Upgrade your Node.js runtime to version 22 or newer (e.g., using nvm: `nvm install 22 && nvm use 22`). If you rely on internal API details of Contentful libraries, review their changelogs for breaking changes in v12, v11, and v8 respectively.
Ensure your proxy settings are correctly ordered. For environment variables, set `https_proxy` if applicable. For `.contentfulrc.json`, use `contentful config add --proxy user:auth@host:port`. If encountering connection problems with a proxy, try `contentful config add --raw-proxy`.
Configure the CLI for EU usage by running `contentful config add --host api.eu.contentful.com --host-delivery cdn.eu.contentful.com`. This will persist the EU host configuration for all subsequent commands.
After installation, try opening a new terminal window or tab. If the issue persists, verify your npm/yarn global installation directory is included in your system's PATH environment variable. You can often find the global installation path with `npm root -g`.
Upgrade your Node.js installation to version 22 or newer. Use a tool like `nvm` (Node Version Manager) for easy switching: `nvm install 22 && nvm use 22`.
Ensure you have installed the CLI globally (`npm install -g contentful-cli` or `yarn global add contentful-cli`). Restart your terminal or shell. Check if your global npm packages directory is in your system's PATH.
Try setting `rawProxy: true` in your `.contentfulrc.json` file via the command: `contentful config add --raw-proxy`. This might help with certain proxy configurations.
Verify the provided Space ID is correct. Re-authenticate using `contentful login`. If using a management token, ensure it is still valid and has the necessary CMA permissions (e.g., `space.manage`). If it's an API key, ensure it's a Management API key, not a Delivery API key.