---
title: "upload a new agent session"
method: POST
path: "/api/agent_sessions"
tags: ["agent_sessions"]
---

# upload a new agent session

`POST /api/agent_sessions`

Upload a new agent session.

### S3 Upload Workflow:
1. Call the S3 presign endpoint to obtain a direct upload URL for the raw session transcript file.
2. Upload the raw transcript to S3.
3. Send a POST request to this endpoint with the S3 key (`s3_key`) and the pre-parsed, curated JSON payload (`curated_data`).

## Request body

- object
  - `title` string — Title for the session (auto-generated if omitted)
  - `curated_data` string, required — JSON string of curated session data with messages array and metadata.
  - `s3_key` string — S3 object key from presign endpoint (optional).
  - `tool_name` 'claude_code' | 'codex' | 'gemini_cli' | 'github_copilot' | 'opencode' | 'pi' — Tool that produced the session (e.g. claude_code, codex).

## Response `201`

created

- AgentSessionIndex — Representation of an agent session returned in a list or after creation
  - `id` integer, required
  - `slug` string, required
  - `title` string, required
  - `tool_name` string, required — Tool that produced the session (e.g. claude_code, codex)
  - `total_messages` integer, required
  - `published` boolean, required
  - `created_at` string, date-time, required
  - `updated_at` string, date-time
  - `url` string, url, required

## Other responses

- `401` — unauthorized
- `422` — unprocessable

## Changes

> 59 revisions in range; 8 could not be searched.

- **2026-07-13** (v1) `189b62b952ea` — 2 breaking
  - removed the media type `application/json` for the response with the status `401`
  - removed the media type `application/json` for the response with the status `422`
- **2026-07-13** (v1) `7db6ba099285` — 2 breaking
  - removed the media type `application/json` for the response with the status `401`
  - removed the media type `application/json` for the response with the status `422`
- **2026-05-28** (v1) `6550ad7be94f` — 2 info
  - added the media type `application/json` for the response with the status `401`
  - added the media type `application/json` for the response with the status `422`
- **2026-05-07** (v1) `5407fa6a8633` — 1 info
  - added the new `opencode` enum value to the request property `tool_name`
- **2026-03-19** (v1) `8dae809f0fde` — 4 breaking, 1 warning, 3 info
  - added the new required request property `curated_data`
  - removed the enum value `aider` of the request property `tool_name`
  - removed the enum value `auto` of the request property `tool_name`
  - removed the enum value `copilot_chat` of the request property `tool_name`
  - …4 more

[Full history](https://skmtc.dev/forem/apis/forem-api-v1/changes/api/agent_sessions/post.md)

---

[API](https://skmtc.dev/forem/apis/forem-api-v1.md) · [All operations](https://skmtc.dev/forem/apis/forem-api-v1/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/forem/forem-api-v1/revisions/1f64f71fc2a7/schema)
