SPB Git

Repository Public

messages.md 11.9 KB 439 lines markdown

1---2title: Messages3url: https://platform.claude.com/docs/en/api/compliance/apps/sessions/remote/messages4---56# Messages78## Retrieve remote session messages910**GET** `/v1/compliance/apps/sessions/remote/{claude_remote_session_id}/messages`1112Retrieve one remote session's transcript: user prompts, assistant13responses, and tool calls and results. Thinking blocks and images are14not included.1516Messages are returned oldest first by default; pass `order=desc` to17reverse. Pagination uses the same `page`/`next_page` scheme as the18list endpoint, with at most `limit` messages per page (default 100,19maximum 1000); keep paginating until `next_page` is null.20`tool_use_input_max_bytes` and `tool_result_max_bytes` cap how many21bytes of each tool-use input and each tool-result text item are22returned; a block shortened by either cap carries `truncated: true`.2324The response embeds the session's metadata under `session` alongside25the paginated `data` array. On this endpoint `session.user.email_address`26and `session.started_by_user` are always null; read them from the list27endpoint instead.2829Returns 404 while the session is still `pending`, for deleted sessions,30and for sessions outside the organizations the key may read. A31malformed session identifier returns 400.3233### Path parameters3435- `claude_remote_session_id: string`3637  The remote session identifier (`cse_...`) to retrieve3839### Query parameters4041- `limit: optional number`4243  Maximum results (default: 100, max: 1000)4445  default: 100, maximum: 1000, minimum: 14647- `order: optional "asc" or "desc"`4849  Sort direction. `asc` (oldest-first) or `desc`.5051  default: asc5253  - `"asc"`5455  - `"desc"`5657- `page: optional string`5859  Opaque pagination token from a previous response's `next_page` field. Pass this to retrieve the next page of results. Clients should treat this value as an opaque string and not attempt to parse or interpret its contents, as the format may change without notice.6061- `tool_result_max_bytes: optional number`6263  Truncate each text item inside a tool result to at most this many bytes (cut on a code-point boundary). Pass `-1` to request the server maximum. `0` is not a valid value.6465  default: 10000, maximum: 2147483647, minimum: -16667- `tool_use_input_max_bytes: optional number`6869  Truncate each tool-use input to at most this many bytes (cut on a code-point boundary so the result is valid UTF-8). Pass `-1` to request the server maximum. `0` is not a valid value.7071  default: 10000, maximum: 2147483647, minimum: -17273### Headers7475- `"x-api-key": optional string`7677### Returns7879- `data: array of object`8081  Transcript turns for this page, ordered by transcript position. `created_at` is a commit timestamp and may tie or invert under concurrent writes; do not re-sort by it.8283  - `id: string`8485    Unique identifier for the message, e.g. `csev_abc123`8687  - `content: array of Text or ToolUse or ToolResult`8889    Content blocks within the message9091    - `Text object`9293      Text content block.9495      - `type: "text"`9697        default: text9899      - `text: string`100101        Text content from the user or the assistant102103      - `truncated: boolean`104105        True when `text` exceeded the server-defined maximum (approximately 1 MiB) and was shortened.106107        default: false108109    - `ToolUse object`110111      Tool invocation requested by the assistant.112113      - `type: "tool_use"`114115        default: tool_use116117      - `id: string or null`118119        Tool-use ID, e.g. 'toolu_01AbC...'120121      - `input: string`122123        Arguments passed to the tool, as a JSON-encoded string. May be shortened — see the `truncated` field124125      - `name: string`126127        Name of the tool invoked128129      - `truncated: boolean`130131        True when `input` was shortened. Pass `tool_use_input_max_bytes=-1` to request full content, subject to the server-side maximum.132133        default: false134135    - `ToolResult object`136137      Result returned by a tool invocation.138139      - `type: "tool_result"`140141        default: tool_result142143      - `content: array of object`144145        Text content returned by the tool. Non-text item types are omitted.146147        - `type: "text"`148149          default: text150151        - `text: string`152153          Text returned by the tool154155      - `is_error: boolean`156157        True when the tool reported an error158159      - `name: string`160161        Name of the tool that produced this result162163      - `tool_use_id: string or null`164165        ID of the tool_use block this result responds to166167      - `truncated: boolean`168169        True when one or more text items in `content` were shortened. Pass `tool_result_max_bytes=-1` to request full content, subject to the server-side maximum.170171        default: false172173  - `content_unavailable: boolean`174175    True when the stored content could not be returned — it could not be decrypted, or it exceeded the server's per-event size bound. `content` is empty in that case; this distinguishes 'no content' from 'content withheld'.176177    default: false178179  - `created_at: string`180181    When the message was recorded (RFC 3339, UTC)182183    format: date-time184185  - `role: "assistant" or "user"`186187    Message sender (`user` or `assistant`)188189    - `"assistant"`190191    - `"user"`192193  - `sent_by_user_id: string or null`194195    Identifier of the human account that sent this turn on an agent-owned session. Null on user-owned sessions, where every user-role turn was sent by the session's `user`.196197- `next_page: string or null`198199  Opaque page token; pass as `page` to retrieve the next page. Null when no rows exist after this page. Treat this value as opaque; do not parse or store it long-term, as the format may change without notice.200201- `session: object`202203  Session metadata. `started_by_user`, `user.email_address`, and `claude_project_id` are always null on this endpoint; the messages endpoint resolves neither email addresses nor project bindings.204205  - `id: string`206207    Remote session identifier208209  - `agent_id: string or null`210211    Identifier of the automated agent that owns the session. Null for user-owned sessions. At most one of `user` and `agent_id` is set.212213  - `claude_project_id: string or null`214215    ID of the project the session is bound to. Null when the session has no project binding.216217  - `created_at: string`218219    When the session was created (RFC 3339, UTC)220221    format: date-time222223  - `organization_uuid: string`224225    UUID of the organization the session belongs to226227  - `product_surface: string or null`228229    The Claude product the session was created from. Currently `cowork_remote`, for Cowork sessions started on claude.ai web or mobile. More values will appear as other surfaces launch, so treat any unrecognized value as an unclassified surface rather than an error. Null for sessions created before this field was recorded, for surfaces that do not stamp it, and for unrecognized tag values.230231  - `started_by_user: object or null`232233    A user associated with a remote session.234235    - `id: string`236237      User identifier238239    - `email_address: string or null`240241      User's email address. Null when the user is no longer a member of an organization the key may read — `id` remains set so attribution is preserved. The messages endpoint does not resolve email addresses; this field is always null there.242243  - `status: string`244245    Session lifecycle state. One of `active`, `paused`, `archived`, or `failed` — the lifecycle states the owning product surface exposes — plus `pending`, a brief transient state that resolves before any transcript content exists. The list endpoint includes `pending`; the messages endpoint returns 404 for it. Deleted sessions are not returned on either endpoint. Treat unrecognized values as an unknown state rather than an error.246247  - `updated_at: string`248249    When the session was last modified (RFC 3339, UTC)250251    format: date-time252253  - `user: object or null`254255    A user associated with a remote session.256257    - `id: string`258259      User identifier260261    - `email_address: string or null`262263      User's email address. Null when the user is no longer a member of an organization the key may read — `id` remains set so attribution is preserved. The messages endpoint does not resolve email addresses; this field is always null there.264265### Example266267```bash268curl https://api.anthropic.com/v1/compliance/apps/sessions/remote/$CLAUDE_REMOTE_SESSION_ID/messages \269    -H 'anthropic-version: 2023-06-01' \270    -H "Authorization: Bearer $ANTHROPIC_COMPLIANCE_API_KEY"271```272273#### Response (200)274275```json276{277  "data": [278    {279      "id": "id",280      "content": [281        {282          "text": "text",283          "truncated": true,284          "type": "text"285        }286      ],287      "content_unavailable": true,288      "created_at": "2019-12-27T18:11:19.117Z",289      "role": "assistant",290      "sent_by_user_id": "sent_by_user_id"291    }292  ],293  "next_page": "next_page",294  "session": {295    "id": "id",296    "agent_id": "agent_id",297    "claude_project_id": "claude_project_id",298    "created_at": "2019-12-27T18:11:19.117Z",299    "organization_uuid": "organization_uuid",300    "product_surface": "product_surface",301    "started_by_user": {302      "id": "id",303      "email_address": "email_address"304    },305    "status": "status",306    "updated_at": "2019-12-27T18:11:19.117Z",307    "user": {308      "id": "id",309      "email_address": "email_address"310    }311  }312}313```314315## Domain types316317### Message List Response318319- `MessageListResponse object`320321  A single user or assistant turn in a remote session transcript.322323  `content` is a discriminated union of `text`, `tool_use`, and324  `tool_result` blocks.325326  - `id: string`327328    Unique identifier for the message, e.g. `csev_abc123`329330  - `content: array of Text or ToolUse or ToolResult`331332    Content blocks within the message333334    - `Text object`335336      Text content block.337338      - `type: "text"`339340        default: text341342      - `text: string`343344        Text content from the user or the assistant345346      - `truncated: boolean`347348        True when `text` exceeded the server-defined maximum (approximately 1 MiB) and was shortened.349350        default: false351352    - `ToolUse object`353354      Tool invocation requested by the assistant.355356      - `type: "tool_use"`357358        default: tool_use359360      - `id: string or null`361362        Tool-use ID, e.g. 'toolu_01AbC...'363364      - `input: string`365366        Arguments passed to the tool, as a JSON-encoded string. May be shortened — see the `truncated` field367368      - `name: string`369370        Name of the tool invoked371372      - `truncated: boolean`373374        True when `input` was shortened. Pass `tool_use_input_max_bytes=-1` to request full content, subject to the server-side maximum.375376        default: false377378    - `ToolResult object`379380      Result returned by a tool invocation.381382      - `type: "tool_result"`383384        default: tool_result385386      - `content: array of object`387388        Text content returned by the tool. Non-text item types are omitted.389390        - `type: "text"`391392          default: text393394        - `text: string`395396          Text returned by the tool397398      - `is_error: boolean`399400        True when the tool reported an error401402      - `name: string`403404        Name of the tool that produced this result405406      - `tool_use_id: string or null`407408        ID of the tool_use block this result responds to409410      - `truncated: boolean`411412        True when one or more text items in `content` were shortened. Pass `tool_result_max_bytes=-1` to request full content, subject to the server-side maximum.413414        default: false415416  - `content_unavailable: boolean`417418    True when the stored content could not be returned — it could not be decrypted, or it exceeded the server's per-event size bound. `content` is empty in that case; this distinguishes 'no content' from 'content withheld'.419420    default: false421422  - `created_at: string`423424    When the message was recorded (RFC 3339, UTC)425426    format: date-time427428  - `role: "assistant" or "user"`429430    Message sender (`user` or `assistant`)431432    - `"assistant"`433434    - `"user"`435436  - `sent_by_user_id: string or null`437438    Identifier of the human account that sent this turn on an agent-owned session. Null on user-owned sessions, where every user-role turn was sent by the session's `user`.439
Files main
Menu

Theme