> ## Documentation Index
> Fetch the complete documentation index at: https://koreai.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate conversation summary

[Back to the Analytics APIs overview](https://koreai.mintlify.site/agent-platform/api-reference/analytics-overview.md)

Use this endpoint to generate a model-written summary of one conversation. Summarize a saved session with `sessionId`, or send a transcript in `messages`. Send exactly one of the two. The endpoint doesn't store the summary.

For a saved session, set `includeMessages` to `true` to also get the first page of the conversation history. The history has the same format as [List conversation messages](https://koreai.mintlify.site/agent-platform/api-reference/analytics-list-conversation-messages).

## Prerequisites

* A Platform Key bound to the project, sent in the `x-api-key` header, with the `analytics:read` permission.
* A model bound to the `conversation_summary` feature in the project. Without it, the API returns `422 SUMMARY_MODEL_NOT_CONFIGURED`.
* For a saved session, the ID of a session in the project.

## Request

Send a JSON body. Set `Content-Type` to `application/json` or `application/jose+json`. When request encryption is on for the Platform Key, send the body as an encrypted JWE. For details, see [List conversation messages using JWE payload](https://koreai.mintlify.site/agent-platform/api-reference/analytics-list-conversation-messages-with-encrypted-payload).

| Field | Description |
| :- | :- |
| `sessionId` | The ID of a session in the project. Send this or `messages`, not both. |
| `messages` | The transcript to summarize, from 1 to 500 items. Send this or `sessionId`, not both. The content of all items together is limited to 100,000 characters. |
| `messages[].role` | Required. `user` or `assistant`. |
| `messages[].content` | Required. The message text, from 1 to 8,000 characters. |
| `includeMessages` | Session mode only. When `true`, the response also includes the first page of the conversation history. The default is `false`. |

In session mode, the summary covers at most the 2,000 newest user and assistant messages of the session.

### Include conversation history

With `includeMessages`, the response contains `messages`, `hasMore`, and `nextCursor`. They have the same format as the response of [List conversation messages](https://koreai.mintlify.site/agent-platform/api-reference/analytics-list-conversation-messages). The response holds only the first page. To get the rest, call List conversation messages with `sessionIds` set to the session ID and `cursor` set to `nextCursor`.

## Response

| Field | Description |
| :- | :- |
| `success` | Always `true` on a successful response. |
| `summary` | The summary text, after the project's PII read policy. `null` only when `summaryStatus` is `unavailable`. |
| `summaryStatus` | `generated`, or `unavailable`. The status is `unavailable` only when the model failed and `includeMessages` was `true`. The response then still returns the history. |
| `summaryError` | The `code` and `message` of the failure, when the summary is unavailable. |
| `sessionId` | The canonical session ID. `null` in transcript mode. |
| `messageCount` | The number of user and assistant messages available. For a session, this counts at most the 2,000 newest. |
| `summarizedMessageCount` | The number of messages sent to the model. |
| `truncated` | `true` when older messages were left out to fit the input budget. |
| `requestId` | The ID of the request. It matches the LLM call ID and support logs. |
| `messages`, `hasMore`, `nextCursor` | Only with `includeMessages`. The first page of conversation history and the paging values. |

## How the summary is generated

* Only user and assistant messages reach the model.
* The prompt is the project's `llm_prompt.conversation_summary` override, or the platform default when there is no override. A deployed session uses the settings version it ran with.
* The model is the one bound to the project's `conversation_summary` feature.
* In transcript mode, the project's input PII redaction applies to user messages.
* The summary passes through the project's PII read policy, as the content of [List conversation messages](https://koreai.mintlify.site/agent-platform/api-reference/analytics-list-conversation-messages) does.
* The endpoint stores nothing.

## Errors

An error response has `success` set to `false` and an `error` object with a `code` and a `message`.

| Status | Code | Cause |
| :- | :- | :- |
| `400` | `INVALID_REQUEST_BODY`, `INVALID_QUERY_PARAMETER`, `MISSING_REQUIRED_FILTER`, `CONFLICTING_INPUT`, `INVALID_MESSAGE_ROLE`, `TRANSCRIPT_TOO_LARGE` | The request body or query string is invalid. |
| `400` | `ENCRYPTED_PAYLOAD_INVALID` | The JWE body is malformed, or its form doesn't match the key's request encryption setting. |
| `401` | `AUTHENTICATION_REQUIRED` | The `x-api-key` header is missing or invalid. |
| `403` | `FORBIDDEN` | The key lacks `analytics:read` or isn't bound to the project. |
| `404` | `NOT_FOUND`, `SESSION_NOT_FOUND` | The project or the session doesn't exist. |
| `415` | `UNSUPPORTED_MEDIA_TYPE` | The `Content-Type` isn't `application/json` or `application/jose+json`. |
| `422` | `NO_SUMMARIZABLE_MESSAGES` | The conversation has no messages to summarize. |
| `422` | `SUMMARY_MODEL_NOT_CONFIGURED` | The project has no model bound to the `conversation_summary` feature. |
| `429` | `RATE_LIMITED` | The tenant request rate limit is exceeded. |
| `502` | `SUMMARY_MODEL_FAILED` | The model failed. |
| `503` | `SERVICE_UNAVAILABLE`, `ENCRYPTION_CONFIG_UNAVAILABLE` | The service or the key's encryption configuration is unavailable. Retry later. |
| `504` | `SUMMARY_TIMEOUT` | The model didn't respond in time. |


## OpenAPI

````yaml agent-platform/api-specs/analytics-conversation-summary.yaml post /api/public/analytics/projects/{projectId}/conversation-summary
openapi: 3.1.0
info:
  title: Analytics Conversation Summary API
  version: 1.0.0
  summary: Generate a summary of one conversation, optionally with its history.
  description: >
    Returns a model-written summary of a saved session (`sessionId`) or of a

    transcript the caller sends (`messages`). Send exactly one of the two.


    With `sessionId`, set `includeMessages: true` to also receive the first page

    of the session's conversation history. The `messages`, `hasMore` and

    `nextCursor` fields have the same shape as the conversation-history API;
    page

    the rest through `/conversation-history` with `sessionIds` and `cursor`.


    Only user and assistant messages reach the model. The prompt is the
    project's

    `llm_prompt.conversation_summary` override (a deployed session uses its

    settings version), otherwise the platform default, followed by a fixed

    instruction that the transcript is data. The model is the project's

    `conversation_summary` feature binding. A passed transcript gets the
    project's

    input PII redaction on user turns. The summary is rendered through the

    project's PII read policy. Nothing is stored.


    Authenticate with the `x-api-key` header. The key must be bound to the

    project and have `analytics:read`. Request and response encryption follow
    the

    Platform Key settings, as for the conversation-history POST form.
servers:
  - url: https://agents.example.com
security:
  - PlatformKey: []
paths:
  /api/public/analytics/projects/{projectId}/conversation-summary:
    post:
      tags:
        - Conversation Summary
      summary: Generate a conversation summary
      operationId: generatePublicAnalyticsConversationSummary
      parameters:
        - name: projectId
          in: path
          required: true
          schema:
            type: string
            minLength: 1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConversationSummaryRequestBody'
            examples:
              session:
                value:
                  sessionId: c6c7dfd6-3988-468b-89b2-86907d5acbba
                  includeMessages: true
              transcript:
                value:
                  messages:
                    - role: assistant
                      content: Welcome to Venus Bank! May I have your customer ID?
                    - role: user
                      content: cust-001
          application/jose+json:
            schema:
              type: string
              description: Compact JWE request envelope when request encryption is on.
      responses:
        '200':
          description: Summary generated, or history returned with an unavailable summary.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationSummaryResponse'
        '400':
          $ref: '#/components/responses/Error'
        '401':
          $ref: '#/components/responses/Error'
        '403':
          $ref: '#/components/responses/Error'
        '404':
          $ref: '#/components/responses/Error'
        '415':
          $ref: '#/components/responses/Error'
        '422':
          $ref: '#/components/responses/Error'
        '429':
          $ref: '#/components/responses/Error'
        '502':
          $ref: '#/components/responses/Error'
        '503':
          $ref: '#/components/responses/Error'
        '504':
          $ref: '#/components/responses/Error'
components:
  schemas:
    ConversationSummaryRequestBody:
      type: object
      additionalProperties: false
      properties:
        sessionId:
          type: string
          minLength: 1
          description: Session ID in this project. Send this or `messages`, not both.
        messages:
          type: array
          minItems: 1
          maxItems: 500
          description: >
            Transcript to summarize. Send this or `sessionId`, not both. Content
            is

            limited to 100,000 characters in total.
          items:
            type: object
            additionalProperties: false
            required:
              - role
              - content
            properties:
              role:
                type: string
                enum:
                  - user
                  - assistant
              content:
                type: string
                minLength: 1
                maxLength: 8000
        includeMessages:
          type: boolean
          default: false
          description: >-
            Session mode only. Also return the first page of conversation
            history.
    ConversationSummaryResponse:
      type: object
      required:
        - success
        - summary
        - summaryStatus
        - sessionId
        - messageCount
        - summarizedMessageCount
        - truncated
        - requestId
      properties:
        success:
          type: boolean
          const: true
        summary:
          type:
            - string
            - 'null'
          description: >-
            The summary after the PII read policy. Null only when summaryStatus
            is unavailable.
        summaryStatus:
          type: string
          enum:
            - generated
            - unavailable
          description: unavailable only when the model failed and includeMessages was true.
        summaryError:
          $ref: '#/components/schemas/ErrorBody'
        sessionId:
          type:
            - string
            - 'null'
          description: Canonical session ID. Null in transcript mode.
        messageCount:
          type: integer
          description: >-
            User and assistant messages available (at most 2,000 newest for a
            session).
        summarizedMessageCount:
          type: integer
          description: Messages sent to the model.
        truncated:
          type: boolean
          description: True when older messages were left out to fit the input budget.
        requestId:
          type: string
          description: Matches the llm_metrics callId and support logs.
        messages:
          type: array
          description: With includeMessages. Same items as the conversation-history API.
          items:
            type: object
        hasMore:
          type: boolean
          description: With includeMessages. More history exists after this page.
        nextCursor:
          type:
            - string
            - 'null'
          description: With includeMessages. Pass to /conversation-history as cursor.
    ErrorBody:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
        message:
          type: string
    ErrorEnvelope:
      type: object
      required:
        - success
        - error
      properties:
        success:
          type: boolean
          const: false
        error:
          $ref: '#/components/schemas/ErrorBody'
  responses:
    Error:
      description: |
        Error envelope. Codes: INVALID_REQUEST_BODY, INVALID_QUERY_PARAMETER,
        MISSING_REQUIRED_FILTER, CONFLICTING_INPUT, INVALID_MESSAGE_ROLE,
        TRANSCRIPT_TOO_LARGE, ENCRYPTED_PAYLOAD_INVALID (400);
        AUTHENTICATION_REQUIRED (401); FORBIDDEN (403); NOT_FOUND,
        SESSION_NOT_FOUND (404); UNSUPPORTED_MEDIA_TYPE (415);
        NO_SUMMARIZABLE_MESSAGES, SUMMARY_MODEL_NOT_CONFIGURED (422);
        RATE_LIMITED (429); SUMMARY_MODEL_FAILED (502); SERVICE_UNAVAILABLE,
        ENCRYPTION_CONFIG_UNAVAILABLE (503); SUMMARY_TIMEOUT (504).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
  securitySchemes:
    PlatformKey:
      type: apiKey
      in: header
      name: x-api-key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.