---
title: "Export agent sessions"
method: POST
path: "/api/v0/agent/sessions/export"
tags: ["Agent"]
---

# Export agent sessions

`POST /api/v0/agent/sessions/export`

## Request

- Base URL: `https://api.outerport.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.outerport.com/api/v0/agent/sessions/export`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/outerport/apis/outerport-api/docs/api/v0/agent/sessions/export/post.ts> (a function with typed inputs; its response is checked against the schema)

Export whole conversations: the sessions named in `session_ids`, or every session of the user that passes the filters, newest activity first. An export of more sessions than `agent_session_export_max_sessions` is refused with 422 and detail `{code: 'too_many_sessions', count, limit}`.

## Request body

- AgentSessionExportRequest: Which sessions to export: the listed ones, or every session that passes the filters.
  - `session_ids` string[], nullable: Export exactly these sessions. Cannot be combined with the filters.
  - `persona_id` string, uuid, nullable: Keep the sessions of this persona.
  - `without_persona` boolean: Keep the sessions on the default persona.
  - `section_id` string, uuid, nullable: Keep the sessions filed under this section.
  - `q` string, nullable: Keep the sessions whose name or message text matches, or with this session ID.

## Response `200`

Successful Response

- AgentSessionExportResponse: Response for exporting agent sessions.
  - `exported_at` string, date-time, required: When the export was made.
  - `sessions` AgentSessionExportSession[], required: The exported sessions, newest activity first.
    - `id` string, uuid, required: The ID of the session.
    - `name` string, nullable: The name of the session.
    - `persona_id` string, uuid, nullable: The session's persona; null for the default persona.
    - `persona_name` string, nullable: The persona's name; null for the default persona.
    - `section_name` string, nullable: The section the session is filed under, if any.
    - `created_at` string, date-time, required: When the session was created.
    - `updated_at` string, date-time, required: When the session was last updated.
    - `messages` AgentSessionExportMessage[], required: The conversation, in order.
      - `role` string, required: 'user', 'assistant' or 'tool'.
      - `content` string, nullable: The message text.
      - `tool_calls` object[], nullable: Tool calls an assistant message made.
      - `tool_call_id` string, nullable: The tool call a tool message answers.
      - `attachment_filenames` string[]: Names of the files attached to the message.
      - `created_at` string, date-time, required: When the message was created.

## Other responses

- `422`: Validation Error

## Changes

- **2026-11-11** `f9dcfeb78d3d`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/outerport/apis/outerport-api/changes/api/v0/agent/sessions/export/post.md)

---

[API](https://skmtc.dev/outerport/apis/outerport-api.md) - [All operations](https://skmtc.dev/outerport/apis/outerport-api/llms.txt) - [OpenAPI document](https://skmtc.dev/outerport/apis/outerport-api/revisions/08b5bf6f7f18?raw)
