# Manage sessions

Source: https://agenta.ai/docs/reference/agents/manage-sessions

Session management endpoints use the authenticated project from the request context.

| Operation                     | Endpoint                                                             |
| ----------------------------- | -------------------------------------------------------------------- |
| Query sessions                | `POST /api/sessions/query`                                           |
| Inspect a session             | `GET /api/sessions/{session_id}`                                     |
| Rename                        | `POST /api/sessions/streams/header?session_id={session_id}`          |
| Archive or unarchive          | `POST /api/sessions/archive?session_id={session_id}` or `/unarchive` |
| Cancel active work            | `POST /api/sessions/{session_id}/cancel`                             |
| Delete                        | `DELETE /api/sessions/?session_id={session_id}`                      |
| Query interactions            | `POST /api/sessions/interactions/query`                              |
| Edit or remove a queued input | `PATCH` or `DELETE /api/sessions/{session_id}/inputs/{input_id}`     |

The session snapshot from `GET /api/sessions/{session_id}` includes the inputs queued for that session.

## Query

```json
{
  "session": {
    "search": "support",
    "origins": ["manual"]
  },
  "include_ended": true,
  "include_archived": false,
  "include_total": true,
  "expand": ["last_message", "trigger"],
  "windowing": { "limit": 50, "order": "descending" }
}
```

Use `include_ended` to include inactive sessions and `archived_only` to restrict results to archived sessions. Cursor fields in `windowing` paginate without relying on mutable offsets.

## Archive versus delete

Archiving hides a session from ordinary queries but preserves its records. Unarchiving restores it. Deletion is destructive and should only follow explicit user intent.

Stopping and archiving are independent: stop active execution before destructive cleanup when necessary.

## Interactions

Interactions have kinds `user_approval`, `user_input`, or `client_tool`, and statuses `pending`, `responded`, `resolved`, or `cancelled`. Fetch the pending interaction before responding so the client can validate its current status and payload.
