Was this page helpful?

Space management with the Contentful CLI

These commands will help you manage spaces in Contentful.

Requirements

List available commands and their description

contentful space --help

Create a space

To create a new space, supply the name. The --organization option is available for power users.

contentful space create --name cli-test
# confirm space creation and select the organization you want to create the space for.

The output should look similar to this:

Successfully created space cli-test (<space-id>)

Get a list of all available spaces

You can list all of the spaces you have access to. The current active space selected via the contentful space use command is highlighted.

contentful space list

The output should look similar to this:

┌────────────────────────────────┬────────────┐
│ Space name                     │ Space id   │
├────────────────────────────────┼────────────┤
│ cli-test [active]              │ <space-id> │
└────────────────────────────────┴────────────┘

Set a space-id to use it in all subsequent commands

Many commands have a --space-id option since they manipulate something related to a space. Since it is unintuitive to pass the space ID every time, you can use the space use command to lock your CLI to a specific Space. Until you use another space or pass a different --space-id to a subsequent command, this space will be your default.

contentful space use --space-id <spaceId>

The output should look similar to this:

Now using the 'master' Environment of Space cli-test (<space-id>) when the `--environment-id` option is missing.

Delete a space in your current account

Delete a space.

contentful space delete --space-id <space-id>
# Confirm the space deletion

The output should look similar to this:

Your cli-test (<space-id>) space was successfully deleted.

Next steps

Not what you’re looking for? Try our FAQ.