> ## 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 a session comment — Replaces the content of an internal note and stamps it as edited. Only the agent who authored the note may edit it.

# Update a session comment

Replaces the content of an existing internal note and stamps it as edited.

Only the note's **author** may edit it: `agent_id` must match the agent the note is attributed to, otherwise the request is rejected with a `403`. A note that has been deleted can no longer be edited.

<Note>
  `agent_id` identifies who the edit is attributed to — it is not a credential. An API key is scoped to the organization, not to one agent, so treat this rule as a safeguard against editing the wrong agent's note rather than as a permission boundary between your own agents.
</Note>

```json theme={"dark"}
{
  "content": "Correction: the refund was issued on the 14th, not the 12th.",
  "agent_id": 42
}
```

The note is resolved against the session in the path, so a `comment_uuid` belonging to a different session returns a `404` rather than editing the wrong conversation.

## Attachments

`attachments` is a full replacement of the note's file list, not a patch:

| You send               | Result                                        |
| ---------------------- | --------------------------------------------- |
| No `attachments` field | Existing files are kept as they are           |
| `"attachments": []`    | All files are removed from the note           |
| `"attachments": [...]` | The list you send replaces the existing files |

So editing only the wording is safe — omit the field and the files stay put. To drop a single file, send the list of the ones you want to keep.


## OpenAPI

````yaml patch /chat/sessions/{session_id}/comments/{comment_uuid}
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}/comments/{comment_uuid}:
    patch:
      summary: Update a session comment
      description: >-
        Replaces the content of an internal comment. Only the comment's author
        may edit it, and a deleted comment can no longer be edited.
      operationId: updateChatSessionComment
      parameters:
        - schema:
            type: string
          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: comment_uuid
          required: true
          description: The unique identifier of the comment
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateSessionCommentInput'
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatHistoryDto'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
components:
  schemas:
    UpdateSessionCommentInput:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/UpdateSessionCommentInputInput'
      type: object
      properties:
        content:
          type: string
          minLength: 1
          description: Replacement comment text content
        agent_id:
          type: integer
          exclusiveMinimum: 0
          maximum: 9007199254740991
          description: >-
            Agent user ID performing the edit. Only the note's author may edit
            it.
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/ChatAttachmentInput'
      required:
        - content
        - agent_id
    ChatHistoryDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/ChatHistoryDto'
      type: object
      properties:
        id:
          type: number
        uuid:
          type: string
        chatbot_id:
          anyOf:
            - type: string
            - type: 'null'
        session_id:
          type: string
        from_user:
          anyOf:
            - type: boolean
            - type: 'null'
        message:
          anyOf:
            - type: string
            - type: 'null'
        original_message:
          anyOf:
            - type: string
            - type: 'null'
        original_language:
          anyOf:
            - type: string
            - type: 'null'
        translated_message:
          anyOf:
            - type: string
            - type: 'null'
        translated_language:
          anyOf:
            - type: string
            - type: 'null'
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        updated_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        debug_json:
          anyOf:
            - anyOf:
                - type: object
                  properties:
                    v2:
                      type: object
                      properties:
                        response:
                          allOf:
                            - oneOf:
                                - type: object
                                  properties:
                                    type:
                                      type: string
                                      const: prohibited_topic
                                    topic:
                                      type: string
                                  required:
                                    - type
                                    - topic
                                  additionalProperties: false
                                - type: object
                                  properties:
                                    type:
                                      type: string
                                      const: response_skipped
                                    reason:
                                      type: string
                                      enum:
                                        - empty_response
                                        - potential_answers_dead_end
                                        - silent_handoff
                                        - assist_human_handling_recommended
                                        - superseded_by_newer_run
                                        - flagged_as_spam
                                    reasoning:
                                      type: array
                                      items:
                                        oneOf:
                                          - type: object
                                            properties:
                                              type:
                                                type: string
                                                const: reasoning
                                              content:
                                                type: string
                                            required:
                                              - type
                                              - content
                                            additionalProperties: false
                                          - type: object
                                            properties:
                                              type:
                                                type: string
                                                const: tool_call
                                              call_id:
                                                type: string
                                              tool_name:
                                                type: string
                                              action:
                                                type: object
                                                properties:
                                                  name:
                                                    type: string
                                                  id:
                                                    type: string
                                                  openapi:
                                                    type: object
                                                    properties:
                                                      openapi_spec_id:
                                                        type: string
                                                      operation_spec: {}
                                                      operation_id:
                                                        type: string
                                                      operation_method:
                                                        type: string
                                                    required:
                                                      - operation_spec
                                                    additionalProperties: false
                                                  metadata: {}
                                                  required_form_submission:
                                                    type: boolean
                                                  is_handoff_like:
                                                    type: boolean
                                                required:
                                                  - name
                                                  - id
                                                  - metadata
                                                additionalProperties: false
                                              call_arguments:
                                                type: string
                                              call_result:
                                                type: string
                                            required:
                                              - type
                                              - call_id
                                              - tool_name
                                              - call_arguments
                                              - call_result
                                            additionalProperties: false
                                    context:
                                      type: object
                                      properties:
                                        knowledgeBaseItems:
                                          type: array
                                          items:
                                            type: object
                                            properties:
                                              itemId:
                                                type: string
                                              chunkIndex:
                                                type: number
                                              title:
                                                type: string
                                              url:
                                                type: string
                                            required:
                                              - itemId
                                              - chunkIndex
                                              - title
                                            additionalProperties: false
                                        instructions:
                                          type: array
                                          items:
                                            type: object
                                            properties:
                                              id:
                                                type: string
                                              title:
                                                type: string
                                              source:
                                                type: string
                                                const: sequence_campaign
                                            required:
                                              - id
                                              - title
                                            additionalProperties: false
                                        tools:
                                          type: array
                                          items:
                                            type: object
                                            properties:
                                              name:
                                                type: string
                                            required:
                                              - name
                                            additionalProperties: false
                                      required:
                                        - knowledgeBaseItems
                                        - instructions
                                        - tools
                                      additionalProperties: false
                                    suppressedResponseText:
                                      type: string
                                    reasoningSummary:
                                      type: string
                                  required:
                                    - type
                                  additionalProperties: false
                                - type: object
                                  properties:
                                    type:
                                      type: string
                                      const: response
                                    responseText:
                                      type: string
                                    responseTextWithReferences:
                                      type: string
                                    context:
                                      type: object
                                      properties:
                                        knowledgeBaseItems:
                                          type: array
                                          items:
                                            type: object
                                            properties:
                                              itemId:
                                                type: string
                                              chunkIndex:
                                                type: number
                                              title:
                                                type: string
                                              url:
                                                type: string
                                            required:
                                              - itemId
                                              - chunkIndex
                                              - title
                                            additionalProperties: false
                                        instructions:
                                          type: array
                                          items:
                                            type: object
                                            properties:
                                              id:
                                                type: string
                                              title:
                                                type: string
                                              source:
                                                type: string
                                                const: sequence_campaign
                                            required:
                                              - id
                                              - title
                                            additionalProperties: false
                                        tools:
                                          type: array
                                          items:
                                            type: object
                                            properties:
                                              name:
                                                type: string
                                            required:
                                              - name
                                            additionalProperties: false
                                      required:
                                        - knowledgeBaseItems
                                        - instructions
                                        - tools
                                      additionalProperties: false
                                    reasoning:
                                      type: array
                                      items:
                                        oneOf:
                                          - type: object
                                            properties:
                                              type:
                                                type: string
                                                const: reasoning
                                              content:
                                                type: string
                                            required:
                                              - type
                                              - content
                                            additionalProperties: false
                                          - type: object
                                            properties:
                                              type:
                                                type: string
                                                const: tool_call
                                              call_id:
                                                type: string
                                              tool_name:
                                                type: string
                                              action:
                                                type: object
                                                properties:
                                                  name:
                                                    type: string
                                                  id:
                                                    type: string
                                                  openapi:
                                                    type: object
                                                    properties:
                                                      openapi_spec_id:
                                                        type: string
                                                      operation_spec: {}
                                                      operation_id:
                                                        type: string
                                                      operation_method:
                                                        type: string
                                                    required:
                                                      - operation_spec
                                                    additionalProperties: false
                                                  metadata: {}
                                                  required_form_submission:
                                                    type: boolean
                                                  is_handoff_like:
                                                    type: boolean
                                                required:
                                                  - name
                                                  - id
                                                  - metadata
                                                additionalProperties: false
                                              call_arguments:
                                                type: string
                                              call_result:
                                                type: string
                                            required:
                                              - type
                                              - call_id
                                              - tool_name
                                              - call_arguments
                                              - call_result
                                            additionalProperties: false
                                    reasoningSummary:
                                      type: string
                                    quickReplySuggestions:
                                      type: array
                                      items:
                                        type: object
                                        properties:
                                          toolName:
                                            anyOf:
                                              - type: string
                                              - type: 'null'
                                          suggestions:
                                            type: array
                                            items:
                                              type: string
                                        required:
                                          - suggestions
                                        additionalProperties: false
                                      description: Quick reply suggestions for the user
                                    mightSolveUserIssue:
                                      type: boolean
                                      description: >-
                                        If your answer might solve the user's
                                        issue, return true, otherwise false.
                                        Note: once the user confirms it is
                                        solved, stop returning true
                                    completelyAndFullyCoveredUserIssue:
                                      description: >-
                                        True if your answer to the user
                                        completely covers the issue from
                                        knowledge and tools, and no further user
                                        input is needed. False if your answer is
                                        generic or is not specific to the issue.
                                      type: boolean
                                  required:
                                    - type
                                    - responseText
                                    - responseTextWithReferences
                                    - context
                                    - reasoning
                                    - quickReplySuggestions
                                    - mightSolveUserIssue
                                  additionalProperties: false
                            - type: object
                              properties:
                                language:
                                  type: string
                                  enum:
                                    - en
                                    - fr
                                    - de
                                    - nl
                                    - pl
                                    - pt
                                    - es
                                    - it
                                    - ru
                                    - ja
                                    - ko
                                    - zh
                                    - ar
                                    - tr
                                    - sv
                                    - da
                                    - 'no'
                                    - fi
                                    - el
                                    - cs
                                    - hu
                                    - th
                                    - vi
                                    - id
                                    - he
                                    - hi
                                    - uk
                                    - ro
                                    - bg
                                    - hr
                                    - sk
                                    - sl
                                    - sr
                                    - et
                                    - lv
                                    - lt
                                    - is
                                    - ga
                                    - ms
                                    - tl
                                    - fa
                                    - bn
                                    - ta
                                    - te
                                    - ur
                                    - sw
                                    - zu
                                    - af
                                    - sq
                                    - hy
                                    - az
                                    - eu
                                    - be
                                    - bs
                                    - ca
                                    - cy
                                    - ku
                                    - ckb
                                    - kmr
                              required:
                                - language
                              additionalProperties: false
                      required:
                        - response
                      additionalProperties: false
                    actionCalls:
                      type: array
                      items:
                        type: object
                        properties:
                          action:
                            type: object
                            properties:
                              name:
                                type: string
                              id:
                                type: string
                              openapi:
                                type: object
                                properties:
                                  openapi_spec_id:
                                    type: string
                                  operation_spec: {}
                                  operation_id:
                                    type: string
                                  operation_method:
                                    type: string
                                required:
                                  - operation_spec
                                additionalProperties: false
                              metadata: {}
                              required_form_submission:
                                type: boolean
                              is_handoff_like:
                                type: boolean
                            required:
                              - name
                              - id
                              - metadata
                            additionalProperties: false
                          arguments: {}
                          result: {}
                        required:
                          - action
                          - arguments
                          - result
                        additionalProperties: false
                    assignment_choice_summary:
                      default: null
                      anyOf:
                        - type: object
                          properties:
                            strategy:
                              type: string
                              const: least-busy
                            selected:
                              anyOf:
                                - type: object
                                  properties:
                                    agent_id:
                                      type: number
                                    agent_name:
                                      type: string
                                    active_sessions:
                                      type: number
                                    active_sessions_in_group:
                                      type: number
                                    pending_sessions:
                                      type: number
                                    remaining_capacity:
                                      type: number
                                    max_capacity:
                                      type: number
                                    max_capacity_in_group:
                                      anyOf:
                                        - type: number
                                        - type: 'null'
                                    is_available_globally:
                                      type: boolean
                                    is_available_in_group:
                                      type: boolean
                                    missing_required_skills:
                                      default: []
                                      type: array
                                      items:
                                        type: object
                                        properties:
                                          id:
                                            type: string
                                          name:
                                            type: string
                                        required:
                                          - id
                                          - name
                                        additionalProperties: false
                                  required:
                                    - agent_id
                                    - agent_name
                                    - active_sessions
                                    - active_sessions_in_group
                                    - pending_sessions
                                    - remaining_capacity
                                    - max_capacity
                                    - max_capacity_in_group
                                    - is_available_globally
                                    - is_available_in_group
                                    - missing_required_skills
                                  additionalProperties: false
                                - type: 'null'
                            peers:
                              type: array
                              items:
                                type: object
                                properties:
                                  agent_id:
                                    type: number
                                  agent_name:
                                    type: string
                                  active_sessions:
                                    type: number
                                  active_sessions_in_group:
                                    type: number
                                  pending_sessions:
                                    type: number
                                  remaining_capacity:
                                    type: number
                                  max_capacity:
                                    type: number
                                  max_capacity_in_group:
                                    anyOf:
                                      - type: number
                                      - type: 'null'
                                  is_available_globally:
                                    type: boolean
                                  is_available_in_group:
                                    type: boolean
                                  missing_required_skills:
                                    default: []
                                    type: array
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: string
                                        name:
                                          type: string
                                      required:
                                        - id
                                        - name
                                      additionalProperties: false
                                required:
                                  - agent_id
                                  - agent_name
                                  - active_sessions
                                  - active_sessions_in_group
                                  - pending_sessions
                                  - remaining_capacity
                                  - max_capacity
                                  - max_capacity_in_group
                                  - is_available_globally
                                  - is_available_in_group
                                  - missing_required_skills
                                additionalProperties: false
                            required_skills:
                              default: []
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: string
                                  name:
                                    type: string
                                required:
                                  - id
                                  - name
                                additionalProperties: false
                          required:
                            - strategy
                            - selected
                            - peers
                            - required_skills
                          additionalProperties: false
                        - type: 'null'
                    custom_data:
                      anyOf:
                        - type: object
                          propertyNames:
                            type: string
                          additionalProperties: {}
                        - type: 'null'
                    assist_mode:
                      type: boolean
                  required:
                    - v2
                  additionalProperties: false
                - type: object
                  properties:
                    actionCalls:
                      type: array
                      items:
                        type: object
                        properties:
                          action:
                            type: object
                            properties:
                              name:
                                type: string
                              id:
                                type: string
                              openapi:
                                type: object
                                properties:
                                  openapi_spec_id:
                                    type: string
                                  operation_spec: {}
                                  operation_id:
                                    type: string
                                  operation_method:
                                    type: string
                                required:
                                  - operation_spec
                                additionalProperties: false
                              metadata: {}
                              required_form_submission:
                                type: boolean
                              is_handoff_like:
                                type: boolean
                            required:
                              - name
                              - id
                              - metadata
                            additionalProperties: false
                          arguments: {}
                          result: {}
                        required:
                          - action
                          - arguments
                          - result
                        additionalProperties: false
                    actionSearchQuery:
                      type: string
                    knowledge:
                      type: array
                      items:
                        type: object
                        properties:
                          source:
                            type: string
                          source_type:
                            type: string
                          url:
                            type: string
                        required:
                          - source
                          - source_type
                          - url
                        additionalProperties: false
                    knowledge_used:
                      type: array
                      items:
                        type: object
                        properties:
                          content:
                            type: string
                          source:
                            type: string
                        required:
                          - content
                          - source
                        additionalProperties: false
                    work_instructions_scanned:
                      type: array
                      items:
                        type: object
                        properties:
                          content:
                            type: string
                        required:
                          - content
                        additionalProperties: false
                    client_context:
                      anyOf:
                        - type: object
                          propertyNames:
                            type: string
                          additionalProperties: {}
                        - type: 'null'
                      description: >-
                        Context provided from the client. For example, dynamic
                        metadata sent from the widget such as: the current
                        product name on the page, the current Shopify shop
                        domain, etc etc.
                    additional_debug_data:
                      anyOf:
                        - type: object
                          propertyNames:
                            type: string
                          additionalProperties: {}
                        - type: 'null'
                      description: Org-specific or message-type-specific debug data.
                    custom_data:
                      anyOf:
                        - type: object
                          propertyNames:
                            type: string
                          additionalProperties: {}
                        - type: 'null'
                    whatsapp_template_request:
                      anyOf:
                        - {}
                        - type: 'null'
                    assist_mode:
                      type: boolean
                    whatsapp_template_snapshot:
                      anyOf:
                        - {}
                        - type: 'null'
                    rule_violation_reflections:
                      type: array
                      items:
                        type: object
                        properties:
                          rule_name:
                            type: string
                          violation_description:
                            type: string
                            description: How the rule was violated
                        required:
                          - rule_name
                          - violation_description
                        additionalProperties: false
                    tool_call_results_quick_reply_suggestions:
                      type: array
                      items:
                        type: object
                        properties:
                          tool_name:
                            type: string
                          suggestions:
                            type: array
                            items:
                              type: string
                        required:
                          - tool_name
                          - suggestions
                        additionalProperties: false
                    assignment_choice_summary:
                      default: null
                      anyOf:
                        - type: object
                          properties:
                            strategy:
                              type: string
                              const: least-busy
                            selected:
                              anyOf:
                                - type: object
                                  properties:
                                    agent_id:
                                      type: number
                                    agent_name:
                                      type: string
                                    active_sessions:
                                      type: number
                                    active_sessions_in_group:
                                      type: number
                                    pending_sessions:
                                      type: number
                                    remaining_capacity:
                                      type: number
                                    max_capacity:
                                      type: number
                                    max_capacity_in_group:
                                      anyOf:
                                        - type: number
                                        - type: 'null'
                                    is_available_globally:
                                      type: boolean
                                    is_available_in_group:
                                      type: boolean
                                    missing_required_skills:
                                      default: []
                                      type: array
                                      items:
                                        type: object
                                        properties:
                                          id:
                                            type: string
                                          name:
                                            type: string
                                        required:
                                          - id
                                          - name
                                        additionalProperties: false
                                  required:
                                    - agent_id
                                    - agent_name
                                    - active_sessions
                                    - active_sessions_in_group
                                    - pending_sessions
                                    - remaining_capacity
                                    - max_capacity
                                    - max_capacity_in_group
                                    - is_available_globally
                                    - is_available_in_group
                                    - missing_required_skills
                                  additionalProperties: false
                                - type: 'null'
                            peers:
                              type: array
                              items:
                                type: object
                                properties:
                                  agent_id:
                                    type: number
                                  agent_name:
                                    type: string
                                  active_sessions:
                                    type: number
                                  active_sessions_in_group:
                                    type: number
                                  pending_sessions:
                                    type: number
                                  remaining_capacity:
                                    type: number
                                  max_capacity:
                                    type: number
                                  max_capacity_in_group:
                                    anyOf:
                                      - type: number
                                      - type: 'null'
                                  is_available_globally:
                                    type: boolean
                                  is_available_in_group:
                                    type: boolean
                                  missing_required_skills:
                                    default: []
                                    type: array
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: string
                                        name:
                                          type: string
                                      required:
                                        - id
                                        - name
                                      additionalProperties: false
                                required:
                                  - agent_id
                                  - agent_name
                                  - active_sessions
                                  - active_sessions_in_group
                                  - pending_sessions
                                  - remaining_capacity
                                  - max_capacity
                                  - max_capacity_in_group
                                  - is_available_globally
                                  - is_available_in_group
                                  - missing_required_skills
                                additionalProperties: false
                            required_skills:
                              default: []
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: string
                                  name:
                                    type: string
                                required:
                                  - id
                                  - name
                                additionalProperties: false
                          required:
                            - strategy
                            - selected
                            - peers
                            - required_skills
                          additionalProperties: false
                        - type: 'null'
                    destination_id:
                      type: string
                    destination_name:
                      type: string
                    destination_type:
                      type: string
                      enum:
                        - phone
                        - sip
                        - hangup
                    transfer_reason:
                      anyOf:
                        - type: string
                        - type: 'null'
                    is_failover:
                      type: boolean
                    failover_source:
                      type: string
                      enum:
                        - stt
                        - llm
                        - tts
                    hangup_initiator:
                      type: string
                      enum:
                        - user
                        - agent
                        - system
                    hangup_reason:
                      type: string
                    duration_seconds:
                      type: number
                    call_direction:
                      type: string
                      enum:
                        - inbound
                        - outbound
                  additionalProperties: false
            - type: 'null'
        knowledgebase_called:
          anyOf:
            - type: boolean
            - type: 'null'
        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_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_reopened_session
            - ai_response_cancelled
            - ai_resumed_by_system
            - ai_suggestion
            - call_history
            - call_transferred
            - 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_requested
            - csat_submitted
            - email_draft_message
            - handoff
            - handoff_to_salesforce_miaw
            - handoff_to_zendesk
            - integration_reopened_session
            - message
            - pii_attachment_removed
            - prohibited_topic_detected
            - quoted_content_modified
            - salesforce_fields_updated
            - sequence_message
            - session_forwarded
            - session_language_changed_by_agent
            - session_language_changed_by_api
            - session_language_changed_by_integration
            - session_language_changed_by_system
            - 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
            - workflow_message
            - workflow_note
            - workflow_triggered
        extra_params:
          anyOf:
            - type: object
              propertyNames:
                type: string
              additionalProperties: {}
            - type: 'null'
        agent_id:
          anyOf:
            - type: number
            - type: 'null'
        agent_name:
          anyOf:
            - type: string
            - type: 'null'
        agent_avatar:
          anyOf:
            - type: string
            - type: 'null'
        handoff_happened_during_office_hours:
          anyOf:
            - type: boolean
            - type: 'null'
        sender_display_name:
          anyOf:
            - type: string
            - type: 'null'
        plan_executed:
          anyOf:
            - type: boolean
            - type: 'null'
        contact_id:
          anyOf:
            - type: string
            - type: 'null'
        contact_name:
          anyOf:
            - type: string
            - type: 'null'
        contact_avatar_url:
          anyOf:
            - type: string
            - type: 'null'
        contact_source:
          anyOf:
            - type: string
              enum:
                - csv
                - form
                - freshchat
                - hubspot
                - intercom
                - pipedream
                - salesforce
                - slack
            - type: 'null'
        contact_slack_data:
          anyOf:
            - type: string
            - type: 'null'
        attachments:
          anyOf:
            - type: array
              items:
                $ref: '#/components/schemas/ChatAttachmentDto'
            - type: 'null'
        email_rfc_message_id:
          anyOf:
            - type: string
            - type: 'null'
        email_to:
          anyOf:
            - type: array
              items:
                type: string
            - type: 'null'
        email_cc:
          anyOf:
            - type: array
              items:
                type: string
            - type: 'null'
        external_message_id:
          anyOf:
            - type: string
            - type: 'null'
        csat_score:
          anyOf:
            - type: number
            - type: 'null'
        csat_feedback:
          anyOf:
            - type: string
            - type: 'null'
        state_checkpoint_payload:
          anyOf:
            - {}
            - type: 'null'
        client_context:
          anyOf:
            - type: object
              propertyNames:
                type: string
              additionalProperties: {}
            - type: 'null'
        workflow_id:
          anyOf:
            - type: string
            - type: 'null'
        workflow_run_id:
          anyOf:
            - type: string
            - type: 'null'
        sequence_id:
          anyOf:
            - type: string
            - type: 'null'
        whatsapp_template_name:
          anyOf:
            - type: string
            - type: 'null'
        whatsapp_template_snapshot:
          anyOf:
            - $ref: '#/components/schemas/WhatsAppTemplateDto'
            - type: 'null'
        from_opencx_public_api:
          anyOf:
            - type: boolean
            - type: 'null'
        sub_status_id:
          anyOf:
            - type: string
            - type: 'null'
        whatsapp_sent_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        whatsapp_delivered_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        whatsapp_read_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        whatsapp_failed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        whatsapp_error_title:
          anyOf:
            - type: string
            - type: 'null'
        whatsapp_error_details:
          anyOf:
            - type: string
            - type: 'null'
        twitter_sent_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        twitter_read_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        twitter_failed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        twitter_error_title:
          anyOf:
            - type: string
            - type: 'null'
        twitter_error_details:
          anyOf:
            - type: string
            - type: 'null'
        session_closed_payload: {}
        agent_changed_payload:
          anyOf:
            - $ref: '#/components/schemas/AgentChangedPayload'
            - type: 'null'
        comment_thread_id:
          anyOf:
            - type: string
            - type: 'null'
        edited_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        deleted_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        phone_call_id:
          anyOf:
            - type: string
            - type: 'null'
        phone_call:
          anyOf:
            - $ref: '#/components/schemas/PhoneCallDto'
            - type: 'null'
      required:
        - id
        - uuid
        - session_id
        - type
        - session_closed_payload
      additionalProperties: false
    ErrorDto:
      type: object
      properties:
        statusCode:
          type: integer
        message:
          type: string
        error:
          type: string
    ChatAttachmentInput:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/ChatAttachmentInputInput'
      type: object
      properties:
        name:
          type: string
          description: The name of the file
        url:
          description: The URL of the file (mutually exclusive with base64)
          type: string
        base64:
          description: >-
            Base64-encoded file content (mutually exclusive with url). Can be a
            data URL (data:mimetype;base64,...) or raw base64 string.
          type: string
        mime_type:
          description: >-
            MIME type of the file (e.g., "image/png", "application/pdf").
            Optional if using data URL format or if type can be detected from
            file content.
          type: string
      required:
        - name
    ChatAttachmentDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/ChatAttachmentDto'
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        size:
          type: number
        type:
          type: string
        url:
          type: string
        openai_file_id:
          type: string
      required:
        - id
        - name
        - size
        - type
        - url
      additionalProperties: false
    WhatsAppTemplateDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/WhatsAppTemplateDto'
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        status:
          type: string
          enum:
            - APPROVED
            - REJECTED
            - PENDING
            - PAUSED
            - DISABLED
            - IN_APPEAL
            - PENDING_DELETION
            - DELETED
            - LIMIT_EXCEEDED
            - ARCHIVED
        category:
          type: string
          enum:
            - UTILITY
            - MARKETING
            - AUTHENTICATION
        parameter_format:
          type: string
          enum:
            - NAMED
            - POSITIONAL
        language:
          type: string
        components:
          anyOf:
            - type: array
              items:
                anyOf:
                  - type: object
                    properties:
                      type:
                        type: string
                        const: HEADER
                      format:
                        type: string
                        const: TEXT
                      text:
                        type: string
                        description: 60 chars max
                      example:
                        anyOf:
                          - type: object
                            properties:
                              header_text:
                                type: array
                                items:
                                  type: string
                            required:
                              - header_text
                            additionalProperties: false
                          - type: object
                            properties:
                              header_text_named_params:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    param_name:
                                      type: string
                                    example:
                                      type: string
                                  required:
                                    - param_name
                                    - example
                                  additionalProperties: false
                            required:
                              - header_text_named_params
                            additionalProperties: false
                    required:
                      - type
                      - format
                      - text
                    additionalProperties: false
                  - type: object
                    properties:
                      type:
                        type: string
                        const: HEADER
                      format:
                        type: string
                        enum:
                          - IMAGE
                          - DOCUMENT
                          - VIDEO
                        description: |2-

                            /**
                             * IMAGE: JPG | PNG
                             * DOCUMENT: PDF
                             * VIDEO: MP4
                             */
                              
                      example:
                        type: object
                        properties:
                          header_handle:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: string
                            description: |2-

                                  /**
                                   * A handle for the media uploaded through the Resumable Upload API
                                   * https://developers.facebook.com/docs/graph-api/guides/upload
                                   */
                                  
                        required:
                          - header_handle
                        additionalProperties: false
                    required:
                      - type
                      - format
                    additionalProperties: false
                  - type: object
                    properties:
                      type:
                        type: string
                        const: HEADER
                      format:
                        type: string
                        const: LOCATION
                    required:
                      - type
                      - format
                    additionalProperties: false
                  - type: object
                    properties:
                      type:
                        type: string
                        const: BODY
                      text:
                        type: string
                        description: >-
                          1024 chars max, or 32768 if `body` is the only
                          component in the template
                      example:
                        anyOf:
                          - type: object
                            properties:
                              body_text:
                                type: array
                                items:
                                  type: array
                                  items:
                                    type: string
                                description: >-
                                  Yes, this is an array of arrays, but only the
                                  first array is used, just like `header_text`
                            required:
                              - body_text
                            additionalProperties: false
                          - type: object
                            properties:
                              body_text_named_params:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    param_name:
                                      type: string
                                    example:
                                      type: string
                                  required:
                                    - param_name
                                    - example
                                  additionalProperties: false
                            required:
                              - body_text_named_params
                            additionalProperties: false
                    required:
                      - type
                      - text
                    additionalProperties: false
                  - type: object
                    properties:
                      type:
                        type: string
                        const: FOOTER
                      text:
                        type: string
                        description: 60 chars max
                    required:
                      - type
                      - text
                    additionalProperties: false
                  - type: object
                    properties:
                      type:
                        type: string
                        const: BUTTONS
                        description: |2-

                            /**
                             * Templates are limited to 10 quick reply buttons. If using quick reply buttons with other buttons,
                             * buttons must be organized into two groups: quick reply buttons and non-quick reply buttons.
                             * If grouped incorrectly, the API will return an error indicating an invalid combination.
                             *
                             * Examples of valid groupings:
                             * - Quick Reply, Quick Reply
                             * - Quick Reply, Quick Reply, URL, Phone
                             * - URL, Phone, Quick Reply, Quick Reply
                             *
                             * Examples of invalid groupings:
                             * - Quick Reply, URL, Quick Reply
                             * - URL, Quick Reply, URL
                             */
                            
                      buttons:
                        type: array
                        items:
                          oneOf:
                            - type: object
                              properties:
                                type:
                                  type: string
                                  const: QUICK_REPLY
                                text:
                                  type: string
                                  description: 25 chars max
                              required:
                                - type
                                - text
                              additionalProperties: false
                            - type: object
                              properties:
                                type:
                                  type: string
                                  const: URL
                                text:
                                  type: string
                                url:
                                  type: string
                                  description: 2000 chars max
                                example:
                                  type: array
                                  prefixItems:
                                    - type: string
                                      description: 2000 chars max
                              required:
                                - type
                                - text
                                - url
                              additionalProperties: false
                            - type: object
                              properties:
                                type:
                                  type: string
                                  const: PHONE_NUMBER
                                text:
                                  type: string
                                  description: 25 chars max
                                phone_number:
                                  type: string
                                  description: 20 chars max
                              required:
                                - type
                                - text
                                - phone_number
                              additionalProperties: false
                            - type: object
                              properties:
                                type:
                                  type: string
                                  const: COPY_CODE
                                example:
                                  anyOf:
                                    - type: string
                                    - type: array
                                      items:
                                        type: string
                                  description: 15 chars max
                              required:
                                - type
                                - example
                              additionalProperties: false
                            - type: object
                              properties:
                                type:
                                  type: string
                                  const: FLOW
                                text:
                                  type: string
                                  description: 25 chars max
                                icon:
                                  type: string
                                  enum:
                                    - DOCUMENT
                                    - PROMOTION
                                    - REVIEW
                                flow_id:
                                  type: string
                                flow_name:
                                  type: string
                                flow_json:
                                  type: object
                                  propertyNames:
                                    type: string
                                  additionalProperties: {}
                                flow_action:
                                  type: string
                                  enum:
                                    - data_exchange
                                    - navigate
                                navigate_screen:
                                  type: string
                              required:
                                - type
                                - text
                                - icon
                                - flow_action
                              additionalProperties: false
                            - type: object
                              properties:
                                type:
                                  type: string
                                  const: MPM
                                example:
                                  type: string
                              required:
                                - type
                                - example
                              additionalProperties: false
                    required:
                      - type
                      - buttons
                    additionalProperties: false
            - type: 'null'
        rejected_reason:
          anyOf:
            - type: string
            - type: 'null'
        message_send_ttl_seconds:
          anyOf:
            - type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            - type: 'null'
      required:
        - id
        - name
        - status
        - category
        - parameter_format
        - language
      additionalProperties: false
    AgentChangedPayload:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/AgentChangedPayload'
      anyOf:
        - type: object
          properties:
            from:
              type: string
              const: ai
            to:
              type: string
              const: human_agent
            agent_id:
              anyOf:
                - type: number
                - type: 'null'
          required:
            - from
            - to
            - agent_id
          additionalProperties: false
        - type: object
          properties:
            from:
              type: string
              const: human_agent
            to:
              type: string
              const: ai
            agent_id:
              type: number
          required:
            - from
            - to
            - agent_id
          additionalProperties: false
        - type: object
          properties:
            from:
              type: string
              const: human_agent
            to:
              type: string
              const: human_agent
            agent_id:
              type: number
            old_agent_id:
              type: number
          required:
            - from
            - to
            - agent_id
            - old_agent_id
          additionalProperties: false
        - type: object
          properties:
            from:
              type: string
              const: human_agent
            to:
              type: string
              const: unassigned
          required:
            - from
            - to
          additionalProperties: false
        - type: object
          properties:
            from:
              type: string
              const: ai
            to:
              type: string
              const: unassigned
          required:
            - from
            - to
          additionalProperties: false
        - type: object
          properties:
            from:
              type: string
              const: unassigned
            to:
              type: string
              const: human_agent
            agent_id:
              type: number
          required:
            - from
            - to
            - agent_id
          additionalProperties: false
        - type: object
          properties:
            from:
              type: string
              const: unassigned
            to:
              type: string
              const: ai
          required:
            - from
            - to
          additionalProperties: false
    PhoneCallDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/PhoneCallDto'
      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)$
        session_id:
          type: string
        direction:
          type: string
          enum:
            - inbound
            - outbound
        status:
          type: string
          enum:
            - initiating
            - ringing
            - in_progress
            - completed
            - no_answer
            - busy
            - rejected
            - failed
            - missed
            - canceled
        initiated_by_user_id:
          anyOf:
            - type: number
            - type: 'null'
        phone_agent_id:
          anyOf:
            - type: string
            - type: 'null'
        from_number:
          anyOf:
            - type: string
            - type: 'null'
        to_number:
          anyOf:
            - type: string
            - type: 'null'
        failure_reason:
          anyOf:
            - type: string
            - type: 'null'
        livekit_disconnect_reason:
          anyOf:
            - type: string
            - type: 'null'
        ring_started_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        ring_expires_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        accepted_by_user_id:
          anyOf:
            - type: number
            - type: 'null'
        answered_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        ended_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        ended_by_user_id:
          anyOf:
            - type: number
            - type: 'null'
        duration_seconds:
          anyOf:
            - type: number
            - type: 'null'
        ring_duration_seconds:
          anyOf:
            - type: number
            - type: 'null'
        recording_status:
          anyOf:
            - type: string
              enum:
                - pending
                - completed
                - failed
            - type: 'null'
        has_recording:
          type: boolean
        is_session_latest_call:
          type: boolean
        created_at:
          type: string
          format: date-time
        events:
          type: array
          items:
            $ref: '#/components/schemas/PhoneCallEventDto'
      required:
        - id
        - session_id
        - direction
        - status
        - initiated_by_user_id
        - phone_agent_id
        - from_number
        - to_number
        - failure_reason
        - livekit_disconnect_reason
        - ring_started_at
        - ring_expires_at
        - accepted_by_user_id
        - answered_at
        - ended_at
        - ended_by_user_id
        - duration_seconds
        - ring_duration_seconds
        - recording_status
        - has_recording
        - is_session_latest_call
        - created_at
        - events
      additionalProperties: false
    PhoneCallEventDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/PhoneCallEventDto'
      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)$
        phone_call_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)$
        event_type:
          type: string
          enum:
            - ring_started
            - ring_accepted
            - ring_declined
            - ring_missed
            - dial_started
            - customer_answered
            - human_joined
            - transfer_initiated
            - transfer_accepted
            - transfer_completed
            - transfer_cancelled
            - transfer_declined
            - call_ended
            - call_failed
        actor_user_id:
          anyOf:
            - type: number
            - type: 'null'
        actor_name:
          anyOf:
            - type: string
            - type: 'null'
        detail:
          anyOf:
            - type: string
            - type: 'null'
        created_at:
          type: string
          format: date-time
      required:
        - id
        - phone_call_id
        - event_type
        - actor_user_id
        - actor_name
        - detail
        - created_at
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````