At Contentstack, we are always looking for ways to make it simpler for developers to use our APIs. With that in mind, we recently introduced Contentstack command-line interface (CLI) Beta, a simple, seamless way to interact with Contentstack using the command line. With this release, developers can now perform common tasks and bulk actions with just a few keystrokes, without having to code.
Contentstack CLI - Supported Actions
In this Beta release, you can use the Contentstack CLI to perform the following operations, as long as you have the proper permissions:
- Bulk publish and unpublish operations
- Content migration operations
Bulk Publish and Unpublish Operations
Using the Contentstack CLI, you can perform bulk operations on entries and assets. By running a series of commands in the CLI, you can perform the following tasks:
- Publish all entities and assets in bulk
- Publish all draft entries in bulk
- Publish entries and assets from one environment to another in bulk
- Publish all entries of a content type in bulk after adding a new field
- Publish entries in bulk after a non-localized field is updated
- Restore or unpublish entries in bulk
- Unpublish all published entries of a content type in bulk
It’s possible to achieve all of the above actions using our Bulk Publish utility. However, using the Contentstack CLI makes managing content changes and publishing in bulk easier and quicker.
Content Migration Operations
Along with bulk operations, the Contentstack CLI allows you to perform content migration operations from the console. By using specific commands, you can perform the following content migrations operations:
- Export content: If you want to migrate content from one stack to another, you need to first export the content from the source stack. You can perform export operations using management and auth tokens.
- Import content: After you export content from one stack, you can import the content into another. Again, you use management and auth tokens to perform these operations.
Setting Up the Contentstack CLI
Getting started with Contentstack CLI is easy. You need to first install the required npm module and run csdx help to get all commands. For installation information, read the CLI documentation.
Next, create a stack in your Contentstack account, or ask the admin to create one for you. Make sure you have either the Developer or Admin rights to the stack. You can use the stack’s management token or your auth token to authenticate.
Using the Contentstack CLI
Once authenticated, you can configure the CLI as per your requirements and start using the commands. Read the detailed instructions on using our CLI commands in our documentation.