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

> ## Agent Instructions
> Start with /introduction/getting-started. Use the Inference API's Direct Query endpoint (POST /api/inference/query) with the newton-c-2.6 or newton-fusion-1.0 model (text, image, and video reasoning) or the omega-embedding encoder (time-series embeddings). ATAI_API_ENDPOINT is the base URL https://platform.u1.archetypeai.app with no version path; every endpoint path begins with /api. Pages whose descriptions are marked (Archived) document the legacy Lens runtime — do not use them for new projects.

# Delete Session

> Delete a session that has ended, with its event log

Requires [version 2.0.1](https://docs.archetypeai.app/release-notes/2.0.x.md#v2-0-1) or later of the Archetype platform.

## Overview

This endpoint deletes a session that has ended (`completed`, `failed`, or `cancelled`),
with its event log.

A session that is still `pending` or `running` returns `409`. [Cancel
it](https://docs.archetypeai.app/api-reference/agents/sessions/cancel-session.md) first.

## Request

**session\_id** `string` *required*

Session `ses_` id.

## Response

Returns `204 No Content` with an empty body on success.

```bash cURL theme={"system"}
curl -X DELETE "$ATAI_API_ENDPOINT/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b" \
  -H "Authorization: Bearer $ATAI_API_KEY"
```

```python Python theme={"system"}
import os
import requests

base_url = os.environ["ATAI_API_ENDPOINT"]
api_key = os.environ["ATAI_API_KEY"]

response = requests.delete(
    f"{base_url}/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b",
    headers={"Authorization": f"Bearer {api_key}"},
)

if response.status_code == 204:
    print("Session deleted")
else:
    print(f"Error: {response.json()['errors']}")
```

```javascript JavaScript theme={"system"}
const response = await fetch(
  `${process.env.ATAI_API_ENDPOINT}/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b`,
  {
    method: 'DELETE',
    headers: {
      'Authorization': `Bearer ${process.env.ATAI_API_KEY}`
    }
  }
);

if (response.status === 204) {
  console.log('Session deleted');
} else {
  const body = await response.json();
  console.error('Error:', body.errors);
}
```

```json 204 - Session deleted theme={"system"}
```

## Important Notes

> [!NOTE]
>
> * A `409` means the session has not ended. Cancel it first.
> * A `403` means you can see the session's project but cannot modify it.
> * A `404` means the session does not exist, belongs to another organization, or is in a project you cannot see.
> * A deployment can be deleted only once it has no sessions left. See [Delete Deployment](https://docs.archetypeai.app/api-reference/agents/deployments/delete-deployment.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.