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

# Archive a Session thread

> Archive a child thread in a managed-agent Session.

`POST /api/v1/cloud/sessions/{session_id}/threads/{thread_id}/archive`

Archives a child thread. Current CAS returns `409` when asked to archive the coordinator/main thread.

## Path parameters

| Parameter    | Type   | Description                        |
| ------------ | ------ | ---------------------------------- |
| `session_id` | string | Session ID with the `sess_` prefix |
| `thread_id`  | string | Thread ID with the `sthr_` prefix  |

## Headers

| Header          | Required | Description         |
| --------------- | -------- | ------------------- |
| `Authorization` | Yes      | `Bearer $QODER_PAT` |

## Example request

```bash theme={null}
curl -X POST "https://api.qoder.com/api/v1/cloud/sessions/sess_019f00000000000000000000000000aa/threads/sthr_019f00000000000000000000000002bb/archive" \
  -H "Authorization: Bearer $QODER_PAT"
```

## Example response

**HTTP 200 OK**

Returns the [Session Thread object](/cloud-agents/api/sessions/schemas#session-thread-object).

```json theme={null}
{
  "id": "sthr_019ef2a07a06704fb899908c29eed779",
  "type": "session_thread",
  "session_id": "sess_019ef2a07a0670b3b68a84f0f3c5c98e",
  "parent_thread_id": "sthr_019ef2a07a06704fb899908c29eed778",
  "agent": {
    "id": "agent_019e390add9f7bac9b6cc806db46fcbd",
    "type": "agent",
    "version": 2,
    "name": "doc-test-agent",
    "description": "",
    "model": {"id": "ultimate", "effective_context_window": 200000},
    "system": "You are an expert software engineer.",
    "tools": [{"enabled_tools": ["Bash", "Read", "Write", "Edit", "Glob", "Grep"], "type": "agent_toolset_20260401"}],
    "skills": [],
    "mcp_servers": []
  },
  "status": "terminated",
  "stats": null,
  "archived_at": "2026-06-23T06:00:00.000Z",
  "created_at": "2026-06-23T05:53:19.774840Z",
  "updated_at": "2026-06-23T06:00:00.000Z"
}
```

## Errors

| HTTP | Type                    | Trigger                                                                                                           |
| ---- | ----------------------- | ----------------------------------------------------------------------------------------------------------------- |
| 401  | `authentication_error`  | PAT invalid or expired                                                                                            |
| 404  | `not_found_error`       | Session or thread does not exist                                                                                  |
| 409  | `invalid_request_error` | Coordinator/main thread cannot be archived, the thread is not in `idle` status, or another version/state conflict |

**HTTP 404 Not Found**

```json theme={null}
{
  "type": "error",
  "request_id": "cb80235f-76a2-4ff3-9e28-5aa2da12dc14",
  "error": {
    "type": "not_found_error",
    "message": "Session thread 'sthr_fakefakefake_xxxxxxxxxxxxxxxx' was not found."
  },
  "request_id": "b5822072-f264-48da-9d61-6d48ffb07551"
}
```

**HTTP 409 Conflict**

```json theme={null}
{
  "type": "error",
  "request_id": "cb80235f-76a2-4ff3-9e28-5aa2da12dc14",
  "error": {
    "type": "invalid_request_error",
    "message": "Version or state conflict."
  }
}
```

The 409 response uses a single generic `"Version or state conflict."` message regardless of whether the conflict is caused by the coordinator role, a non-idle thread status, or another concurrency conflict. Disambiguate by inspecting the thread state via `GET /api/v1/cloud/sessions/{session_id}/threads/{thread_id}`.

See [Errors](/cloud-agents/api/conventions/errors) for the full error envelope.

## Related

<CardGroup cols={2}>
  <Card title="Managed Agents" icon="user-gear" href="/cloud-agents/managed-agents">
    Learn the coordinator and child thread collaboration model.
  </Card>

  <Card title="List Session Threads" icon="list" href="/cloud-agents/api/sessions/list-threads">
    Inspect all threads in a session and their statuses.
  </Card>

  <Card title="Session Thread object" icon="layer-group" href="/cloud-agents/api/sessions/schemas#session-thread-object">
    Full field reference for the Session Thread object.
  </Card>
</CardGroup>
