---
title: "createToken"
---

> Documentation Index
> Fetch the complete documentation index at: https://agenthold.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# createToken

Path: agenthold API › tokens

`POST /me/tokens`

URL: `/api/v1/me/tokens`

Create a personal access token. It acts as you, with your permissions.
Send it as `Authorization: Bearer <token>`. The token is shown once.

## Authentication

Requires one of the following:

- `session`, apiKey, in cookie
- `token`, http bearer, header `Authorization`

## Request body

_Required._

- `name` (`createToken.name`; string, required)
  - maxLength: `100` · minLength: `1`
- `expiresInDays` (`createToken.expiresInDays`; integer, optional)
  - maximum: `3650` · minimum: `1`

## Example request

```json
{
  "name": "string",
  "expiresInDays": 1
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url '<base-url>/api/v1/me/tokens' \
  --header 'Content-Type: application/json' \
  --cookie 'agenthold_session=<agenthold_session>' \
  --data '
{
  "name": "string",
  "expiresInDays": 1
}
'
```

### TypeScript

```typescript
const url = '<base-url>/api/v1/me/tokens';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    cookie: 'agenthold_session=<agenthold_session>'
  },
  body: JSON.stringify({name: 'string', expiresInDays: 1})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "<base-url>/api/v1/me/tokens"

payload = {
    "name": "string",
    "expiresInDays": 1
}
headers = {
    "cookie": "agenthold_session=<agenthold_session>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 201

Created.

#### Example

```json
{
  "id": "string",
  "name": "string",
  "prefix": "string",
  "createdAt": "2019-08-24T14:15:22Z",
  "lastUsedAt": "2019-08-24T14:15:22Z",
  "expiresAt": "2019-08-24T14:15:22Z",
  "token": "string"
}
```

- `id` (`createToken.response.201.id`; string, required)
- `name` (`createToken.response.201.name`; string, required)
- `prefix` (`createToken.response.201.prefix`; string, required) — The first characters of the token.
- `createdAt` (`createToken.response.201.createdAt`; string, required)
  - format: `date-time`
- `token` (`createToken.response.201.token`; string, required)
- `lastUsedAt` (`createToken.response.201.lastUsedAt`; string, optional)
  - format: `date-time`
- `expiresAt` (`createToken.response.201.expiresAt`; string, optional)
  - format: `date-time`

### 400

Error.

#### Example

```json
{
  "error": "string"
}
```

- `error` (`createToken.response.400.error`; string, required)


Source: https://agenthold.dev/api/create-token/index.md
