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

# Delete a session and its events

> DELETE /api/managed-agents/session — permanently removes a session and all its associated events.

Deleting a session removes the session record and all associated events from Knoq. If a background workflow is actively processing a turn when you issue this request, Knoq marks the session as cancelled first so the workflow exits cleanly before the data is removed. Deletion is permanent and cannot be undone.

<Note>
  Deleting a session in Knoq removes only the locally persisted data — conversation history stored on Knoq's side. This action does not affect any data held by external AI providers.
</Note>

```
DELETE /api/managed-agents/session?sessionId=<id>
```

## Request

<ParamField query="sessionId" type="string" required>
  The ID of the session to delete. You can obtain this from the [Create Session](/api-reference/sessions/create) response or the [List Sessions](/api-reference/sessions/list) endpoint.
</ParamField>

## Response

<ResponseField name="ok" type="boolean">
  Always `true` when the deletion succeeds.
</ResponseField>

## Example

<CodeGroup>
  ```bash curl theme={null}
  curl -X DELETE \
    "https://knoq.one/api/managed-agents/session?sessionId=a3f2c1d4-e5b6-7890-abcd-ef1234567890" \
    -H "Origin: https://knoq.one" \
    -H "Cookie: <your-session-cookie>"
  ```

  ```json Response theme={null}
  {
    "ok": true
  }
  ```
</CodeGroup>

## Errors

| Status | Meaning                                                                                                           |
| ------ | ----------------------------------------------------------------------------------------------------------------- |
| `400`  | The `sessionId` query parameter is missing or empty.                                                              |
| `401`  | The request is not authenticated. Ensure your session cookie is valid and has not expired.                        |
| `404`  | No session with the given ID was found for your user and organisation. The session may have already been deleted. |
