---
title: "Compact an array of messages into a single summary"
method: POST
path: "/conversation/compact"
tags: ["Conversation"]
---

# Compact an array of messages into a single summary

`POST /conversation/compact`

## Request

- Base URL: `https://api.chatbotkit.com/api/v1`
- URL: `https://api.chatbotkit.com/api/v1/conversation/compact`
- Auth: HTTP bearer

## Headers

- `X-Timezone` string

## Request body

- union
  - object: A bot configuration that can be applied without a dedicated bot instance.
    - `botId` string, nullable: The ID of the bot this configuration is using
    - `messages` Message[], required: An array of messages to be compacted
      - `type` 'user' | 'bot' | 'reasoning' | 'context' | 'instruction' | 'backstory' | 'activity' | 'checkpoint', required: The type of the message
      - `text` string, required: The text of the message
      - `meta` Meta: Meta data information
    - `extensions` ExtensionsDefinition: Extensions to enhance the bot's capabilities
      - `backstory` string: Additional backstory for the bot
      - `datasets` object[]: Inline datasets to provide additional context
        - `name` string, nullable: The name of the dataset
        - `description` string, nullable: The description of the dataset
        - `records` object[], required: The records in the dataset
          - `text` string, required: The text content of the record
          - `meta` object: Additional metadata for the record
      - `skillsets` object[]: Inline skillsets to provide additional abilities
        - `name` string, nullable: The name of the skillset
        - `description` string, nullable: The description of the skillset
        - `abilities` object[], required: The abilities in the skillset
          - `name` string, required: The name of the ability
          - `description` string, required: The description of the ability
          - `instruction` string, required: The instruction for the ability
          - `linkedSecretId` string: Optional secret ID for the ability
          - `linkedSpaceId` string: Optional space ID for the ability
          - `meta` object: Additional metadata for the ability
      - `features` object[]: Feature flags to enable specific bot capabilities
        - `name` string, required: The name of the feature to enable
        - `options` object: Optional configuration options for the feature
  - object: A bot configuration that can be applied without a dedicated bot instance.
    - `model` string: A model definition
    - `backstory` string, nullable: The backstory this configuration is using
    - `datasetId` string, nullable: The id of the dataset this configuration is using
    - `skillsetId` string, nullable: The id of the skillset this configuration is using
    - `privacy` boolean: The privacy flag for this configuration
    - `moderation` boolean: The moderation flag for this configuration
    - `messages` Message[], required: An array of messages to be compacted
      - `type` 'user' | 'bot' | 'reasoning' | 'context' | 'instruction' | 'backstory' | 'activity' | 'checkpoint', required: The type of the message
      - `text` string, required: The text of the message
      - `meta` Meta: Meta data information
    - `extensions` ExtensionsDefinition: Extensions to enhance the bot's capabilities
      - `backstory` string: Additional backstory for the bot
      - `datasets` object[]: Inline datasets to provide additional context
        - `name` string, nullable: The name of the dataset
        - `description` string, nullable: The description of the dataset
        - `records` object[], required: The records in the dataset
          - `text` string, required: The text content of the record
          - `meta` object: Additional metadata for the record
      - `skillsets` object[]: Inline skillsets to provide additional abilities
        - `name` string, nullable: The name of the skillset
        - `description` string, nullable: The description of the skillset
        - `abilities` object[], required: The abilities in the skillset
          - `name` string, required: The name of the ability
          - `description` string, required: The description of the ability
          - `instruction` string, required: The instruction for the ability
          - `linkedSecretId` string: Optional secret ID for the ability
          - `linkedSpaceId` string: Optional space ID for the ability
          - `meta` object: Additional metadata for the ability
      - `features` object[]: Feature flags to enable specific bot capabilities
        - `name` string, required: The name of the feature to enable
        - `options` object: Optional configuration options for the feature

## Response `200`

The messages were compacted successfully

- object
  - `text` string, required: The compacted text of the messages, or an empty string if there was nothing to compact
  - `usage` Usage, required: Usage information
    - `token` number, required: The tokens used in this exchange

## Other responses

- `default`: An error response

---

[API](https://skmtc.dev/chatbotkit/apis/cbk-api.md) · [All operations](https://skmtc.dev/chatbotkit/apis/cbk-api/llms.txt) · [OpenAPI document](https://skmtc.dev/chatbotkit/apis/cbk-api/revisions/13d250576136?raw)
