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

# Update an AI suggestion

> Update an AI suggestion — Replaces the text of a draft reply the AI wrote for your team in assist mode. Nothing is sent to the contact.

Replaces the text of an [AI suggestion](https://docs.open.cx/inbox/ai-writing-tools.md#review-ai-suggestions-in-assist-mode): the draft reply the AI writes in assist mode for a teammate to review. Nothing is sent to the contact. The teammate still reviews the draft and sends it.

Find the suggestion with [List chat session history](https://docs.open.cx/api-reference/chat-sessions/list_history.md): it is an event of type `ai_suggestion`, and its `id` is the `suggestion_id` here. Write `text` in the language the reply should reach the contact in.

```json theme={"dark"}
{
  "text": "Your refund was issued on the 14th and should reach your card within 5 business days."
}
```

The response is the updated `ai_suggestion` event, in the same shape the history returns.

* **Translated sessions:** the translated copy your team reads is rebuilt from the new text. A teammate who still has the earlier version in the composer sends their reply as written; the contact never gets new text or images that teammate hasn't seen.
* **Activity log:** every edit is recorded with the API key, Companion user or mini-app that made it.
* **Connected helpdesks:** a copy of the draft that was already posted to your helpdesk (for example as an internal note) keeps its original text.
* **Not found (`404`):** the id is not a live AI suggestion of the session in the path, or the draft or session was redacted. Replies already sent to the contact, internal notes and other events can't be edited here.


## OpenAPI

````yaml patch /chat/sessions/{session_id}/ai-suggestions/{suggestion_id}
openapi: 3.1.0
info:
  title: OpenCX API
  description: >

    OpenCX is an AI-powered, all-in-one platform for customer support and
    outbound communications.


    Use this API to manage your OpenCX organization's AI agents, actions,
    conversations, contacts, and more.


    To get started, generate a new API key from the dashboard.


    ## Authentication

    All API endpoints require authentication using a Bearer token. You can
    generate an API key from your OpenCX dashboard.


    ## Rate Limiting

    API requests are rate limited to ensure fair usage. The current limits are:

    - 100 requests per minute for standard endpoints

    - 1000 requests per minute for streaming endpoints


    ## Error Handling

    The API uses standard HTTP status codes and returns detailed error messages
    in the response body.
  version: 1.0-beta
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: http://localhost:8080
    description: Development
  - url: https://api.open.cx
    description: Production
security:
  - bearerAuth: []
paths:
  /chat/sessions/{session_id}/ai-suggestions/{suggestion_id}:
    patch:
      summary: Update an AI suggestion
      description: >-
        Replaces the text of an AI suggestion: the draft reply the AI wrote for
        a human agent in assist mode. Nothing is sent to the contact; the agent
        still reviews and sends it. The translated copy agents read is rebuilt
        from the new text. A copy of the draft already shown in a connected
        helpdesk is not changed.
      operationId: updateChatSessionAiSuggestion
      parameters:
        - schema:
            type: string
            format: uuid
            pattern: >-
              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
          in: path
          name: session_id
          required: true
          description: The unique identifier of the chat session
        - schema:
            type: string
            format: uuid
            pattern: >-
              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
          in: path
          name: suggestion_id
          required: true
          description: The `id` of the `ai_suggestion` event in the session history
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAiSuggestionInput'
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatHistoryOutput'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
components:
  schemas:
    UpdateAiSuggestionInput:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/UpdateAiSuggestionInputInput'
      type: object
      properties:
        text:
          type: string
          minLength: 1
          description: >-
            Replacement draft text, in the language the reply should reach the
            contact in
      required:
        - text
    ChatHistoryOutput:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/ChatHistoryOutput'
      type: object
      properties:
        id:
          type: string
          format: uuid
          pattern: >-
            ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
        created_at:
          anyOf:
            - type: string
              format: date-time
              pattern: >-
                ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$
        event:
          anyOf:
            - type: object
              properties:
                type:
                  type: string
                  const: message
                sender:
                  $ref: '#/components/schemas/ChatMessageSender'
                email:
                  description: >-
                    Per-message email headers. Omitted when no email metadata is
                    stored. Does not include BCC recipients.
                  type: object
                  properties:
                    from:
                      description: >-
                        Original sender address, when stored; may differ from
                        the session contact when Reply-To is used.
                      type: string
                    to:
                      type: array
                      items:
                        type: string
                      description: Visible To recipients recorded for this message.
                    cc:
                      type: array
                      items:
                        type: string
                      description: Visible CC recipients recorded for this message.
                  required:
                    - to
                    - cc
                  additionalProperties: false
                content:
                  type: object
                  properties:
                    type:
                      type: string
                      const: text
                    text:
                      type: string
                  required:
                    - type
                    - text
                  additionalProperties: false
                context:
                  type: object
                  propertyNames:
                    type: string
                  additionalProperties: {}
                custom_data:
                  description: >-
                    Custom data attached to this message by the sender (e.g. via
                    the widget SDK)
                  type: object
                  propertyNames:
                    type: string
                  additionalProperties: {}
                attachments:
                  type: array
                  items:
                    $ref: '#/components/schemas/PublicChatAttachment'
                options:
                  description: >-
                    Agent messages sent from a macro with options: the options
                    the contact can tap. Report a tap with
                    `message.option_reply` on Send a message.
                  type: array
                  items:
                    $ref: '#/components/schemas/MessageOptionDto'
              required:
                - type
                - sender
                - content
                - attachments
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: session_merged
                internal:
                  type: boolean
                  const: true
                merge:
                  type: object
                  properties:
                    merge_id:
                      type: string
                      format: uuid
                      pattern: >-
                        ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                    source_session_id:
                      type: string
                      format: uuid
                      pattern: >-
                        ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                    source_ticket_number:
                      type: number
                    primary_session_id:
                      type: string
                      format: uuid
                      pattern: >-
                        ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                    primary_ticket_number:
                      type: number
                    actor:
                      oneOf:
                        - type: object
                          properties:
                            type:
                              type: string
                              const: agent
                            agentId:
                              type: number
                          required:
                            - type
                            - agentId
                          additionalProperties: false
                        - type: object
                          properties:
                            type:
                              type: string
                              const: api
                          required:
                            - type
                          additionalProperties: false
                        - type: object
                          properties:
                            type:
                              type: string
                              const: workflow
                            id:
                              type: string
                              description: The workflow that performed the merge.
                            workflow_run_id:
                              type: string
                              description: The workflow run that performed the merge.
                          required:
                            - type
                            - id
                            - workflow_run_id
                          additionalProperties: false
                    redacted:
                      type: boolean
                  required:
                    - merge_id
                    - source_session_id
                    - source_ticket_number
                    - primary_session_id
                    - primary_ticket_number
                    - actor
                  additionalProperties: false
              required:
                - type
                - internal
                - merge
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: merged_session_message
                internal:
                  type: boolean
                  const: true
                source:
                  type: object
                  properties:
                    merge_id:
                      type: string
                      format: uuid
                      pattern: >-
                        ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                    source_session_id:
                      type: string
                      format: uuid
                      pattern: >-
                        ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                    source_ticket_number:
                      type: number
                    source_message_uuid:
                      type: string
                      format: uuid
                      pattern: >-
                        ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                    redacted:
                      type: boolean
                  required:
                    - merge_id
                    - source_session_id
                    - source_ticket_number
                    - source_message_uuid
                  additionalProperties: false
              required:
                - type
                - internal
                - source
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: unmapped_event
                  description: >-
                    A recorded event without a typed history mapping. Included
                    in organization exports so no history rows are lost.
                message_type:
                  type: string
                  enum:
                    - agent_assigned_by_integration
                    - agent_assigned_by_system
                    - agent_assigned_by_user
                    - agent_changed
                    - agent_comment
                    - agent_initiated_session
                    - agent_joined
                    - agent_message
                    - agent_message_deleted_by_agent
                    - agent_reopened_session
                    - agent_took_session_from_ai
                    - agent_unassigned_by_integration
                    - agent_unassigned_by_system
                    - agent_unassigned_by_user
                    - ai_assumed_the_session_resolved
                    - ai_decided_to_not_reply
                    - ai_decided_to_resolve_the_issue
                    - ai_follow_up_cancelled
                    - ai_follow_up_fired
                    - ai_follow_up_scheduled
                    - ai_reopened_session
                    - ai_response_cancelled
                    - ai_resumed_by_system
                    - ai_services_paused_handoff
                    - ai_suggestion
                    - call_history
                    - call_transferred
                    - ces_request_cancelled
                    - ces_requested
                    - ces_submitted
                    - closed_resolved_by_agent
                    - closed_resolved_by_api
                    - closed_resolved_by_contact
                    - closed_resolved_by_integration
                    - closed_resolved_by_system
                    - closed_unresolved_by_agent
                    - closed_unresolved_by_api
                    - closed_unresolved_by_system
                    - contact_data_updated
                    - csat_request_cancelled
                    - csat_requested
                    - csat_submitted
                    - email_draft_message
                    - handoff
                    - handoff_to_salesforce_miaw
                    - handoff_to_third_party_failed
                    - handoff_to_zendesk
                    - integration_reopened_session
                    - ivr_selection
                    - journey_step_by_integration
                    - merged_session_message
                    - message
                    - nps_request_cancelled
                    - nps_requested
                    - nps_submitted
                    - pii_attachment_removed
                    - primary_contact_changed
                    - prohibited_topic_detected
                    - quoted_content_modified
                    - salesforce_fields_updated
                    - sequence_message
                    - session_erased_by_system_due_to_retention_threshold
                    - session_forwarded
                    - session_language_changed_by_agent
                    - session_language_changed_by_api
                    - session_language_changed_by_integration
                    - session_language_changed_by_system
                    - session_merged
                    - session_priority_changed_by_agent
                    - session_priority_changed_by_system
                    - session_snoozed
                    - session_subject_changed_by_agent
                    - session_subject_changed_by_system
                    - session_unsnoozed
                    - skills_added_by_system
                    - sla_applied_by_agent
                    - sla_applied_by_system
                    - sla_first_reply_breached
                    - sla_first_reply_completed_after_breach
                    - sla_first_reply_fulfilled
                    - sla_first_reply_metric_started
                    - sla_freezed_office_hours_ended
                    - sla_freezed_snoozed
                    - sla_next_reply_breached
                    - sla_next_reply_completed_after_breach
                    - sla_next_reply_fulfilled
                    - sla_next_reply_metric_started
                    - sla_removed_by_agent
                    - sla_removed_by_system
                    - sla_resolution_breached
                    - sla_resolution_completed_after_breach
                    - sla_resolution_fulfilled
                    - sla_resolution_metric_started
                    - sla_resolution_paused_resolved
                    - sla_resolution_paused_waiting_on_customer
                    - sla_resolution_resumed_customer_replied
                    - sla_resolution_resumed_reopened
                    - sla_resumed_office_hours_started
                    - sla_resumed_snooze_cancelled
                    - sla_resumed_snooze_expired
                    - state_checkpoint
                    - sub_session_created
                    - sub_session_linked_by_agent
                    - sub_session_linked_by_api
                    - sub_session_linked_by_integration
                    - sub_session_linked_by_system
                    - sub_session_unlinked_by_agent
                    - sub_session_unlinked_by_api
                    - sub_session_unlinked_by_integration
                    - sub_session_unlinked_by_system
                    - sub_status_removed_by_agent
                    - sub_status_removed_by_api
                    - sub_status_removed_by_integration
                    - sub_status_removed_by_system
                    - sub_status_set_by_agent
                    - sub_status_set_by_api
                    - sub_status_set_by_integration
                    - sub_status_set_by_system
                    - system_reopened_session
                    - tag_added_by_agent
                    - tag_added_by_api
                    - tag_added_by_integration
                    - tag_added_by_system
                    - tag_removed_by_agent
                    - tag_removed_by_api
                    - tag_removed_by_integration
                    - tag_removed_by_system
                    - team_assigned_by_integration
                    - team_assigned_by_system
                    - team_assigned_by_user
                    - team_unassigned_by_integration
                    - team_unassigned_by_system
                    - team_unassigned_by_user
                    - user_confirmed_the_session_resolved
                    - voice_call_ai_joined
                    - voice_call_ai_left
                    - voice_call_contact_answered
                    - voice_call_contact_joined
                    - voice_call_contact_left
                    - voice_call_ended
                    - voice_call_failed_to_start
                    - voice_call_human_answered
                    - voice_call_human_joined
                    - voice_call_human_left
                    - voice_call_started
                    - workflow_message
                    - workflow_note
                    - workflow_triggered
                content:
                  anyOf:
                    - type: object
                      properties:
                        type:
                          type: string
                          const: text
                        text:
                          type: string
                      required:
                        - type
                        - text
                      additionalProperties: false
                    - type: 'null'
              required:
                - type
                - message_type
                - content
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: ai_comment
                  description: An internal note authored by AI.
                content:
                  type: object
                  properties:
                    type:
                      type: string
                      const: text
                    text:
                      type: string
                  required:
                    - type
                    - text
                  additionalProperties: false
                comment_thread_id:
                  anyOf:
                    - type: string
                      format: uuid
                      pattern: >-
                        ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                    - type: 'null'
              required:
                - type
                - content
                - comment_thread_id
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: ai_suggestion
                  description: >-
                    An AI draft reply produced in assist mode — suggested to the
                    human support team, never delivered to the contact.
                content:
                  type: object
                  properties:
                    type:
                      type: string
                      const: text
                    text:
                      type: string
                  required:
                    - type
                    - text
                  additionalProperties: false
                attachments:
                  type: array
                  items:
                    $ref: '#/components/schemas/PublicChatAttachment'
              required:
                - type
                - content
                - attachments
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: workflow_message
                workflow_id:
                  type:
                    - string
                    - 'null'
                workflow_run_id:
                  type:
                    - string
                    - 'null'
                content:
                  type: object
                  properties:
                    type:
                      type: string
                      const: text
                    text:
                      type: string
                  required:
                    - type
                    - text
                  additionalProperties: false
              required:
                - type
                - workflow_id
                - workflow_run_id
                - content
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: sequence_message
                sequence_id:
                  type:
                    - string
                    - 'null'
                content:
                  type: object
                  properties:
                    type:
                      type: string
                      const: text
                    text:
                      type: string
                  required:
                    - type
                    - text
                  additionalProperties: false
              required:
                - type
                - sequence_id
                - content
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: handoff
                integration:
                  type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - zendesk
                        - salesforce-miaw
                  required:
                    - type
                  additionalProperties: false
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: closed_resolved_by_agent
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: closed_resolved_by_system
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: closed_resolved_by_api
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: closed_unresolved_by_agent
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: closed_unresolved_by_system
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: closed_unresolved_by_api
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: closed_resolved_by_contact
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: closed_resolved_by_integration
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: sub_status_set_by_agent
                sub_status_id:
                  type:
                    - string
                    - 'null'
              required:
                - type
                - sub_status_id
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: sub_status_set_by_system
                sub_status_id:
                  type:
                    - string
                    - 'null'
              required:
                - type
                - sub_status_id
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: sub_status_set_by_api
                sub_status_id:
                  type:
                    - string
                    - 'null'
              required:
                - type
                - sub_status_id
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: sub_status_removed_by_agent
                sub_status_id:
                  type:
                    - string
                    - 'null'
              required:
                - type
                - sub_status_id
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: sub_status_removed_by_system
                sub_status_id:
                  type:
                    - string
                    - 'null'
              required:
                - type
                - sub_status_id
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: sub_status_removed_by_api
                sub_status_id:
                  type:
                    - string
                    - 'null'
              required:
                - type
                - sub_status_id
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: sub_status_set_by_integration
                sub_status_id:
                  type:
                    - string
                    - 'null'
              required:
                - type
                - sub_status_id
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: sub_status_removed_by_integration
                sub_status_id:
                  type:
                    - string
                    - 'null'
              required:
                - type
                - sub_status_id
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - tag_added_by_system
                    - tag_added_by_agent
                    - tag_added_by_api
                    - tag_added_by_integration
                    - tag_removed_by_system
                    - tag_removed_by_agent
                    - tag_removed_by_api
                    - tag_removed_by_integration
                tags:
                  type: array
                  items:
                    type: object
                    properties:
                      name:
                        type: string
                    required:
                      - name
                    additionalProperties: false
              required:
                - type
                - tags
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: ai_resolved_issue
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: ai_assumed_issue_resolved
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: user_confirmed_issue_resolved
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: human_agent_comment
                human_agent_id:
                  type: number
                content:
                  type: object
                  properties:
                    type:
                      type: string
                      const: text
                    text:
                      type: string
                  required:
                    - type
                    - text
                  additionalProperties: false
                comment_thread_id:
                  anyOf:
                    - type: string
                      format: uuid
                      pattern: >-
                        ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                    - type: 'null'
              required:
                - type
                - human_agent_id
                - content
                - comment_thread_id
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: workflow_note
                workflow_id:
                  type:
                    - string
                    - 'null'
                workflow_run_id:
                  type:
                    - string
                    - 'null'
                content:
                  type: object
                  properties:
                    type:
                      type: string
                      const: text
                    text:
                      type: string
                  required:
                    - type
                    - text
                  additionalProperties: false
              required:
                - type
                - workflow_id
                - workflow_run_id
                - content
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: human_agent_joined
                human_agent_id:
                  type: number
              required:
                - type
                - human_agent_id
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: human_agent_takeover
                human_agent_id:
                  type: number
              required:
                - type
                - human_agent_id
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: human_agent_reopened_session
                human_agent_id:
                  type: number
              required:
                - type
                - human_agent_id
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: system_reopened_session
                workflow_id:
                  type:
                    - string
                    - 'null'
                workflow_run_id:
                  type:
                    - string
                    - 'null'
              required:
                - type
                - workflow_id
                - workflow_run_id
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: integration_reopened_session
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: ai_reopened_session
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: session_erased_by_system_due_to_retention_threshold
                  description: >-
                    The session's content was erased because it passed the
                    organization's retention threshold.
                reason:
                  description: >-
                    Which retention rule erased the session, as a sentence such
                    as "Closed for 30 days" or "No activity for 90 days".
                  type: string
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: state_checkpoint
                payload: {}
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: csat_requested
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: csat_submitted
                payload:
                  type: object
                  properties:
                    score:
                      type: number
                    feedback:
                      type:
                        - string
                        - 'null'
                  required:
                    - score
                    - feedback
                  additionalProperties: false
              required:
                - type
                - payload
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: nps_requested
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: nps_submitted
                payload:
                  type: object
                  properties:
                    score:
                      type: number
                    feedback:
                      type:
                        - string
                        - 'null'
                  required:
                    - score
                    - feedback
                  additionalProperties: false
              required:
                - type
                - payload
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: ces_requested
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: ces_submitted
                payload:
                  type: object
                  properties:
                    score:
                      type: number
                    feedback:
                      type:
                        - string
                        - 'null'
                  required:
                    - score
                    - feedback
                  additionalProperties: false
              required:
                - type
                - payload
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: agent_changed
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: prohibited_topic_detected
                topic:
                  type:
                    - string
                    - 'null'
              required:
                - type
                - topic
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: ai_services_paused
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: agent_assigned_by_system
                assigned_agent_id:
                  type: number
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: agent_assigned_by_integration
                assigned_agent_id:
                  type: number
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: agent_assigned_by_user
                assigned_agent_id:
                  type: number
                actor_id:
                  type: number
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: agent_unassigned_by_system
                unassigned_agent_id:
                  type: number
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: agent_unassigned_by_integration
                unassigned_agent_id:
                  type: number
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: agent_unassigned_by_user
                unassigned_agent_id:
                  type: number
                actor_id:
                  type: number
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: team_assigned_by_system
                assigned_team_id:
                  type: string
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: team_assigned_by_integration
                assigned_team_id:
                  type: string
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: team_assigned_by_user
                assigned_team_id:
                  type: string
                actor_id:
                  type: number
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: team_unassigned_by_system
                unassigned_team_id:
                  type: string
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: team_unassigned_by_integration
                unassigned_team_id:
                  type: string
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: team_unassigned_by_user
                unassigned_team_id:
                  type: string
                actor_id:
                  type: number
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - sla_applied_by_system
                    - sla_applied_by_agent
                    - sla_removed_by_agent
                    - sla_removed_by_system
                    - sla_first_reply_metric_started
                    - sla_first_reply_fulfilled
                    - sla_first_reply_breached
                    - sla_first_reply_completed_after_breach
                    - sla_next_reply_metric_started
                    - sla_next_reply_fulfilled
                    - sla_next_reply_breached
                    - sla_next_reply_completed_after_breach
                    - sla_resolution_metric_started
                    - sla_resolution_paused_waiting_on_customer
                    - sla_resolution_paused_resolved
                    - sla_resolution_resumed_customer_replied
                    - sla_resolution_resumed_reopened
                    - sla_resolution_fulfilled
                    - sla_resolution_breached
                    - sla_resolution_completed_after_breach
                    - sla_freezed_office_hours_ended
                    - sla_resumed_office_hours_started
                    - sla_freezed_snoozed
                    - sla_resumed_snooze_expired
                    - sla_resumed_snooze_cancelled
                elapsed_ms:
                  type:
                    - number
                    - 'null'
              required:
                - type
                - elapsed_ms
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: workflow_triggered
                workflow_id:
                  type:
                    - string
                    - 'null'
                workflow_run_id:
                  type:
                    - string
                    - 'null'
              required:
                - type
                - workflow_id
                - workflow_run_id
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: contact_data_updated
                fields:
                  type: object
                  propertyNames:
                    type: string
                  additionalProperties:
                    type: string
              required:
                - type
                - fields
              additionalProperties: false
      required:
        - id
        - created_at
        - event
      additionalProperties: false
    ErrorDto:
      type: object
      properties:
        statusCode:
          type: integer
        message:
          type: string
        error:
          type: string
    ChatMessageSender:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/ChatMessageSender'
      anyOf:
        - type: object
          properties:
            type:
              type: string
              const: contact
            name:
              type: string
          required:
            - type
          additionalProperties: false
        - type: object
          properties:
            type:
              type: string
              const: ai
            name:
              type: string
          required:
            - type
          additionalProperties: false
        - type: object
          properties:
            type:
              type: string
              const: human_agent
            name:
              type: string
          required:
            - type
          additionalProperties: false
    PublicChatAttachment:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/PublicChatAttachment'
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        size:
          type: number
        type:
          type: string
        url:
          type: string
      required:
        - id
        - name
        - size
        - type
        - url
      additionalProperties: false
    MessageOptionDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/MessageOptionDto'
      type: object
      properties:
        id:
          type: string
        label:
          type: string
        type:
          $ref: '#/components/schemas/MessageOptionType'
      required:
        - id
        - label
        - type
      additionalProperties: false
    MessageOptionType:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/MessageOptionType'
      type: string
      enum:
        - text
        - workflow
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

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