> ## Documentation Index
> Fetch the complete documentation index at: https://docs.staging.questra.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Truncate conversation messages from a checkpoint

> Deletes `before_message_id` and every later message so chat history can be restored to the state before that message (e.g. AI Elements checkpoint restore).



## OpenAPI

````yaml /openapi/program.openapi.json post /surveys/{surveyId}/conversations/{conversationId}/messages/truncate
openapi: 3.1.0
info:
  title: Questra Program API
  version: 0.0.1
  description: >-
    REST API for the Questra Program product. Browser users authenticate through
    Questra Auth SSO; automation uses workspace-scoped API keys (`Authorization:
    Bearer qpk_live_…`). API keys carry scopes enforced before handlers.
    Outbound webhooks follow Standard Webhooks (at-least-once delivery;
    consumers must be idempotent).
servers:
  - url: /v1
    description: Program API base path
security: []
paths:
  /surveys/{surveyId}/conversations/{conversationId}/messages/truncate:
    post:
      tags:
        - Conversations
      summary: Truncate conversation messages from a checkpoint
      description: >-
        Deletes `before_message_id` and every later message so chat history can
        be restored to the state before that message (e.g. AI Elements
        checkpoint restore).
      parameters:
        - schema:
            type: string
            format: uuid
          required: true
          name: surveyId
          in: path
        - schema:
            type: string
            format: uuid
          required: true
          name: conversationId
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TruncateConversationMessagesRequest'
      responses:
        '200':
          description: Truncated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TruncateConversationMessagesResponse'
        '404':
          description: Survey, conversation, or message not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
components:
  schemas:
    TruncateConversationMessagesRequest:
      type: object
      properties:
        before_message_id:
          type: string
          format: uuid
          description: >-
            Delete this message and every later message (chronological order).
            Messages before it are kept.
      required:
        - before_message_id
    TruncateConversationMessagesResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/TruncateConversationMessagesResult'
      required:
        - data
    ErrorBody:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
        resource:
          type: string
        slug:
          type: string
        file_id:
          type: string
        endpoint_id:
          type: string
        event_id:
          type: string
        delivery_id:
          type: string
        api_key_id:
          type: string
        integration_id:
          type: string
        audit_id:
          type: string
        status:
          type: string
        details: {}
        question_ids:
          type: array
          items:
            type: string
        survey_ids:
          type: array
          items:
            type: string
        revisions:
          type: array
          items:
            type: number
      required:
        - error
    TruncateConversationMessagesResult:
      type: object
      properties:
        deleted_ids:
          type: array
          items:
            type: string
            format: uuid
      required:
        - deleted_ids

````