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

# upload a new agent session

`POST /api/agent_sessions`

This endpoint allows the client to create a new agent session.

Sessions are created from pre-parsed and curated data (`curated_data` JSON) and
optionally linked to an S3-stored raw file via `s3_key`. Use the presign endpoint
to get an upload URL for the raw file first.

Use the [Forem CLI plugin](https://github.com/forem/forem-cli-plugin) to upload
sessions directly from the command line.

## 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

- **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
- **2026-03-03** (v1) `c9e7662755c2` — 1 info
  - endpoint added

[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/7db6ba099285/schema)
