---
title: "createSession"
---

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

# createSession

Path: agenthold API › sessions

`POST /agents/{agentId}/sessions`

URL: `/api/v1/agents/{agentId}/sessions`

## Authentication

Requires one of the following:

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

## Path parameters

- `agentId` (`createSession.path.agentId`; string, required)

## Request body

- `title` (`createSession.title`; string, optional)
  - maxLength: `200`

## Example request

```json
{
  "title": "string"
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url '<base-url>/api/v1/agents/<agentId>/sessions' \
  --header 'Content-Type: application/json' \
  --cookie 'agenthold_session=<agenthold_session>' \
  --data '
{
  "title": "string"
}
'
```

### TypeScript

```typescript
const url = '<base-url>/api/v1/agents/<agentId>/sessions';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    cookie: 'agenthold_session=<agenthold_session>'
  },
  body: JSON.stringify({title: 'string'})
};

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/agents/<agentId>/sessions"

payload = { "title": "string" }
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",
  "agentId": "string",
  "origin": {
    "agentId": "string",
    "agentName": "string",
    "sessionId": "string"
  },
  "title": "string",
  "running": true,
  "createdBy": {
    "id": "string",
    "email": "string",
    "name": "string",
    "avatarUrl": "string"
  },
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z"
}
```

- `id` (`createSession.response.201.id`; string, required)
- `agentId` (`createSession.response.201.agentId`; string, required)
- `title` (`createSession.response.201.title`; string, required)
- `running` (`createSession.response.201.running`; boolean, required)
- `createdBy` (`createSession.response.201.createdBy`; object, required)
  - `id` (`createSession.response.201.createdBy.id`; string, required)
  - `email` (`createSession.response.201.createdBy.email`; string, required)
  - `name` (`createSession.response.201.createdBy.name`; string, required)
  - `avatarUrl` (`createSession.response.201.createdBy.avatarUrl`; string, required)
- `createdAt` (`createSession.response.201.createdAt`; string, required)
  - format: `date-time`
- `updatedAt` (`createSession.response.201.updatedAt`; string, required)
  - format: `date-time`
- `origin` (`createSession.response.201.origin`; object, optional) — Set when another agent started the session (send_message or ask).
  - `agentId` (`createSession.response.201.origin.agentId`; string, required)
  - `agentName` (`createSession.response.201.origin.agentName`; string, required)
  - `sessionId` (`createSession.response.201.origin.sessionId`; string, required) — The other agent's session that sent the messages.

### 403

Error.

#### Example

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

- `error` (`createSession.response.403.error`; string, required)

### 404

Error.

#### Example

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

- `error` (`createSession.response.404.error`; string, required)


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