> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://contentful.com/developers/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://contentful.com/developers/docs/_mcp/server.

# Authentication with the Contentful CLI

> This guide will help you to authenticate with the Contentful CLI | Requirements | Login | Logout and Next steps

For every request, clients [need to provide an API key](/references/content-management-api/overview), which is created per space and used to delimit applications and content classes. This helps you authenticate with the `contentful-cli`.

## Requirements

* A (free) [Contentful account](https://www.contentful.com/sign-up/)
* Locally [installed](/tutorials/cli/installation) `contentful-cli`

## Login

```bash
contentful login
```

![Contentful-login gif](/developers/docs/_fern-files/contentful.docs.buildwithfern.com/67e52735dd130f3381805aaa404604ca41ef5f5c24070e7b25d395d8c26285cc/docs/assets/images/contentful-login.gif)

If you have no browser available on your machine you can generate the management token manually and pass it directly to the login command.
[Login](https://be.contentful.com/login) and create a management token at `Settings > API keys > Content management tokens > Generate personal token`.

```bash
contentful login --management-token <management-token>
```

*The output should look similar to this:*

```bash
Great! Your CMA token is now stored on your system. (Located at ~/.contentfulrc.json)
You can always run contentful logout to remove it.
```

## Logout

To log out and remove your current management token from `.contentfulrc.json`

```bash
contentful logout
```

*The output should look similar to this:*

```bash
Successfully logged you out.
```

## Next steps

* [Configure the Contentful CLI](/tutorials/cli/config-management)
* [Manage spaces with the Contentful CLI](/tutorials/cli/space-management)
* [Manage environments with the Contentful CLI](/tutorials/cli/environment-management/)
* [Manage extensions with the Contentful CLI](/tutorials/cli/extension-management)
* [Check out the documentation in the GitHub repository](https://github.com/contentful/contentful-cli/blob/master/docs/)