Installing the CLI tool
The CLI tool is installed using your favorite package manager:
npm install -g contentful-cli
yarn global add contentful-cli
Run the contentful guide command
If you’re new to Contentful, a good way to get familiar with the CLI tool is to run the
contentful guide command.
contentful guide will walk you through the process of signing up for Contentful, log in to your new account and create a space with some sample content.
contentful guide command will also make use of that sample content to build and boot up a local web app called the Contentful blog in five minutes as shown below:
Use the CLI tool for automation
More experienced Contentful users can use the CLI tool in their automation workflow. To get an idea of what the tool can do for automation, just type in
Working with spaces
So let’s say that we want to automate the creation of new spaces. But before we create any new spaces, we want to list the spaces that already exist:
contentful space list
The output would then be like so:
And if we want to create a new space, we type in:
contentful space create --name 'TheTechblog'.
contentful space list again to verify that the new space was successfully created:
As you can see, the bottom row now contains the entry for the Space
TheTechblog together with its Space id of
Give us your feedback
While we’re excited to introduce you to one of our latest creations, the CLI tool is still in its early stages. This means we’ll be adding lots of features in the near future. Our top priority with this tool is to make your life easier. So to get things just right - we need your feedback.
If you have a feature request, or if you’ve found an intrusive bug, let us know by using the “Talk to us” feature in the WebApp. You can also give us your suggestions via our Slack community channel at contentful.com/slack - or by writing to firstname.lastname@example.org.
Our new CLI tool makes it possible to automate tasks that you previously had to use the WebApp for. Such tasks include managing access tokens as well as listing and creating new spaces. If you’re new to Contentful, you can use the CLI tool’s guide mode to build a sample Contentful-powered app in just a few minutes.