---
title: "Upload Session"
method: PUT
path: "/api/v1/agent-traces/sessions/{session_id}"
tags: ["agent_traces"]
---

# Upload Session

`PUT /api/v1/agent-traces/sessions/{session_id}`

Overwrite the stored JSONL for this session.

Body is raw NDJSON; the CLI sends the entire local session file each call.
Content-Length is checked before the body is read so oversized requests
are rejected without buffering bytes.

## Path parameters

- `session_id` string, required

## Headers

- `x-trace-id` string — Root session id in the recursion tree.
- `x-parent-session` string, nullable — Parent session id if this is a sub-agent session.
- `x-cwd` string, nullable — Working directory the agent was launched from.
- `x-agent-version` string, nullable — prime-agent version string.

## Response `200`

Successful Response

- UploadSessionResponse
  - `session_id` string, required
  - `trace_id` string, required
  - `bytes_stored` integer, required
  - `key` string, required — R2 object key the session was written to

## Other responses

- `401` — Authorization failed
- `422` — Invalid request data

---

[API](https://skmtc.net/primeintellect/apis/pi-api.md) · [All operations](https://skmtc.net/primeintellect/apis/pi-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/primeintellect/pi-api/versions/60efc9b3ff2a/schema)
