> 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.

# Create an access token

POST https://api.contentful.com/users/me/access_tokens
Content-Type: application/vnd.contentful.management.v1+json

Creates a Personal Access Token with the specified scopes (`content_management_read` or `content_management_manage`). The token value is only returned once — copy and store it securely.

Reference: https://contentful.com/developers/docs/references/content-management-api/access-tokens/create-an-access-token

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/vnd.contentful.management.v1+json)

This endpoint expects a map from string to any.

- `map from string to any`

## Response

### 201

Created - Resource created successfully

- `map from string to any`

## Examples

**Request**

```json
{
  "expiresIn": 0,
  "name": "My Token",
  "scopes": [
    "content_management_manage"
  ]
}
```

**Response**

```json
{
  "name": "My Token",
  "revokedAt": null,
  "scopes": [
    "content_management_manage"
  ],
  "sys": {
    "application": {
      "sys": {
        "id": "<application_id>",
        "linkType": "Application",
        "type": "Link"
      }
    },
    "createdAt": "2026-01-26T13:48:37.000Z",
    "expiresAt": null,
    "id": "exampletokenid",
    "lastUsedAt": null,
    "redactedValue": "TmTU",
    "type": "PersonalAccessToken",
    "updatedAt": "2026-01-26T13:48:37.000Z"
  },
  "token": "46d42a80f96db00393ffa867a753de126e658484dd8a20d209bcb7efcf3761b9"
}
```

**SDK Code**

```android Android
// Create the Contentful client.
final CMAClient client =
    new CMAClient
        .Builder()
        .setAccessToken("<access_token>")
        .setSpaceId("<space_id>")
        .setEnvironmentId("<environment_id>")
        .build();

// Create a new personal access token.
final CMAPersonalAccessToken token = new CMAPersonalAccessToken()
    .setName("NewApiKey")
    .addScope(CMAPersonalAccessToken.Scope.Read);

// Upload it to Contentful.
client
    .personalAccessTokens()
    .async()
    .create(
        token,
        new CMACallback<CMAPersonalAccessToken>() {
          @Override protected void onSuccess(CMAPersonalAccessToken result) {
            new AlertDialog.Builder(context)
                .setTitle("Contentful")
                .setMessage("Successfully create a new access token." +
                    "\n\nResult: " + result)
                .show();
          }

          @Override protected void onFailure(RuntimeException exception) {
            // An error occurred! Inform the user.
            new AlertDialog.Builder(context)
                .setTitle("Contentful Error")
                .setMessage("Could not create a token." +
                    "\n\nReason: " + exception.toString())
                .show();

            super.onFailure(exception);
          }
        }
    );
```

```java Java
// Create the Contentful client.
final CMAClient client =
    new CMAClient
        .Builder()
        .setAccessToken("<access_token>")
        .setSpaceId("<space_id>")
        .setEnvironmentId("<environment_id>")
        .build();

// Create a new access token locally.
final CMAPersonalAccessToken token = new CMAPersonalAccessToken()
    .setName("newApiKey");

// Upload it to Contentful.
final CMAPersonalAccessToken createdToken = client
    .personalAccessTokens()
    .create(token);
```

```kotlin Kotlin
// Create the Contentful client.
val client = CMAClient.Builder()
    .setAccessToken("<access_token>")
    .setSpaceId("<space_id>")
    .setEnvironmentId("<environment_id>")
    .build()

// Create a new access token locally.
val token = CMAPersonalAccessToken()
        .setName("newApiKey")

// Upload it to Contentful.
val createdToken = client
        .personalAccessTokens()
        .create(token)
```

```swift Swift
We currently don't provide a CMA SDK for this platform.
```

```js-legacy JavaScript (legacy)
import { createClient } from 'contentful-management'

const client = createClient({
  accessToken: '<content_management_api_key>'
}, { type: 'legacy' })

client.createPersonalAccessToken(
    {
      name: 'My Token',
      scopes: [
        'content_management_manage'
      ]
    }
  )
 .then((personalAccessToken) => console.log(personalAccessToken.token))
 .catch(console.error)
```

```javascript JavaScript
import { createClient } from 'contentful-management'

// Client init
const client = createClient({
  accessToken: '<content_management_api_key>'
})

await client.accessToken.createPersonalAccessToken({
  name: '<name>',
  scopes: ['<scope>'],
  expiresIn: '<expires_in>'
});
```

```php PHP
$client = new \Contentful\Management\Client('<content_management_api_key>');

$token = new \Contentful\Management\Resource\PersonalAccessToken(
  'Token name',
  true // Set to true for write access, defaults to read-only
);
$client->create($token);
```

```ruby Ruby
require 'contentful/management'

client = Contentful::Management::Client.new('<content_management_api_key>')

personal_access_token = client.personal_access_tokens.create(name: 'Token Name', scopes: ['content_management_manage'])
```

```python Python
from contentful_management import Client

client = Client('<content_management_api_key>')

personal_access_token = client.personal_access_tokens().create({
    'name': 'Token Name',
    'scopes': ['content_management_manage']
})
```

```.net .NET
// This client should only be created once per application.
var httpClient = new HttpClient();

var client = new ContentfulManagementClient(httpClient, "<content_management_api_key>", "<space_id>");

var token = new ManagementToken {
    Name = "Token name",
    Scopes = new List<string> {
        SystemManagementScopes.Manage
    }
}

var createdToken = await client.CreateManagementToken(token);
```