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

# Decide Action Approval as a contact on a channel

> Decide on a pending action approval, recorded as the contact (not as the admin / API key). Only custom channels are supported. Use this from custom integrations so the decision is attributed to the right chat member.



## OpenAPI

````yaml https://api.useinvent.com/openapi.json post /orgs/{org_id}/contacts/{contact_id}/channels/{channel_id}/chats/{chat_id}/messages/{message_id}/approvals/{tool_call_id}
openapi: 3.1.0
info:
  version: 1.0.0
  title: Invent API
servers:
  - url: https://api.useinvent.com
security:
  - bearerAuth: []
paths:
  /orgs/{org_id}/contacts/{contact_id}/channels/{channel_id}/chats/{chat_id}/messages/{message_id}/approvals/{tool_call_id}:
    post:
      tags:
        - Orgs Contacts
      summary: Decide Action Approval as a contact on a channel
      description: >-
        Decide on a pending action approval, recorded as the contact (not as the
        admin / API key). Only custom channels are supported. Use this from
        custom integrations so the decision is attributed to the right chat
        member.
      parameters:
        - schema:
            type: string
          required: true
          description: Org ID
          name: org_id
          in: path
        - schema:
            type: string
          required: true
          description: Contact ID
          name: contact_id
          in: path
        - schema:
            type: string
          required: true
          description: Channel ID
          name: channel_id
          in: path
        - schema:
            type: string
          required: true
          description: Chat ID
          name: chat_id
          in: path
        - schema:
            type: string
          required: true
          description: The ID of the message with the pending approval.
          name: message_id
          in: path
        - schema:
            type: string
          required: true
          description: The ID of the tool call to decide on.
          name: tool_call_id
          in: path
      requestBody:
        description: ''
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MessageDecideApprovalSchema'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/MessageDecideApprovalSchema'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatMessageSchema'
components:
  schemas:
    MessageDecideApprovalSchema:
      type: object
      properties:
        decision:
          $ref: '#/components/schemas/ConnectionActionApprovalDecisionSchema'
        reason:
          type: string
          maxLength: 512
          description: >-
            Optional explanation for the decision. When rejecting, this is
            surfaced back to the assistant.
        background:
          type: boolean
          description: >-
            When true, the decision is recorded immediately and the approved
            tool runs in the background — the response returns the "running"
            state. Defaults to false, which blocks until the tool finishes
            executing and returns the final message.
      required:
        - decision
      description: Accept or reject a pending approval on an assistant action
    ChatMessageSchema:
      type: object
      properties:
        id:
          type: string
        role:
          $ref: '#/components/schemas/ModelMessageRoleSchema'
        model:
          type: string
          description: The model used for the message
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ModelMessageSchema'
          description: The message content
        member:
          $ref: '#/components/schemas/ChatMemberSchema'
        status:
          $ref: '#/components/schemas/ChatStatusSchema'
        error:
          type: string
          description: Error message if the message failed
        broadcast_id:
          type: string
          description: ID of the broadcast this message originates from
        is_broadcast_message:
          type: boolean
          description: Whether this message was sent via a broadcast template
        usage:
          $ref: '#/components/schemas/ModelUsageSchema'
        delivered_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When the message was delivered to the recipient
        seen_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When the recipient saw the message
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - role
        - model
        - status
        - created_at
        - updated_at
      description: The chat message schema
    ConnectionActionApprovalDecisionSchema:
      type: string
      enum:
        - accepted
        - rejected
      description: How a pending approval was resolved
    ModelMessageRoleSchema:
      type: string
      enum:
        - user
        - assistant
        - system
        - tool
        - event
        - note
      description: The role of the message
    ModelMessageSchema:
      oneOf:
        - $ref: '#/components/schemas/ModelSystemMessageSchema'
        - $ref: '#/components/schemas/ModelAssistantMessageSchema'
        - $ref: '#/components/schemas/ModelUserMessageSchema'
        - $ref: '#/components/schemas/ModelToolMessageSchema'
        - $ref: '#/components/schemas/ModelEventMessageSchema'
        - $ref: '#/components/schemas/ModelNoteMessageSchema'
      discriminator:
        propertyName: role
        mapping:
          system:
            $ref: '#/components/schemas/ModelSystemMessageSchema'
          assistant:
            $ref: '#/components/schemas/ModelAssistantMessageSchema'
          user:
            $ref: '#/components/schemas/ModelUserMessageSchema'
          tool:
            $ref: '#/components/schemas/ModelToolMessageSchema'
          event:
            $ref: '#/components/schemas/ModelEventMessageSchema'
          note:
            $ref: '#/components/schemas/ModelNoteMessageSchema'
    ChatMemberSchema:
      type: object
      properties:
        id:
          type: string
        role:
          $ref: '#/components/schemas/ChatMemberRoleSchema'
        user:
          $ref: '#/components/schemas/UserPublicSchema'
        session:
          $ref: '#/components/schemas/PublicSessionSchema'
        contact_channel:
          $ref: '#/components/schemas/PublicContactChannelSchema'
      required:
        - id
        - role
      description: The member of the chat
    ChatStatusSchema:
      type: string
      enum:
        - RUNNING
        - COMPLETED
        - FAILED
        - CANCELED
      description: The chat status
    ModelUsageSchema:
      type: object
      properties:
        input_tokens:
          type: number
          description: Number of input tokens used by the model
        output_tokens:
          type: number
          description: Number of output tokens generated by the model
        total_tokens:
          type: number
          description: Total number of tokens used by the model
        reasoning_tokens:
          type: number
          description: Number of reasoning tokens used by the model
        input_tokens_cache_read:
          type: number
          description: Number of input tokens cached read by the model
        input_tokens_cache_write:
          type: number
          description: Number of input tokens cached written by the model
        turns:
          type: array
          items:
            $ref: '#/components/schemas/ModelUsageTurnSchema'
      description: The usage information for the message
    ModelSystemMessageSchema:
      type: object
      properties:
        role:
          type: string
          enum:
            - system
        parts:
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/ModelTextPartSchema'
            discriminator:
              propertyName: type
              mapping:
                text:
                  $ref: '#/components/schemas/ModelTextPartSchema'
      required:
        - role
        - parts
      description: System message
    ModelAssistantMessageSchema:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the assistant message
        role:
          type: string
          enum:
            - assistant
        parts:
          type: array
          items:
            $ref: '#/components/schemas/ModelAssistantMessagePartsSchema'
      required:
        - role
        - parts
      description: Assistant message
    ModelUserMessageSchema:
      type: object
      properties:
        role:
          type: string
          enum:
            - user
        parts:
          type: array
          items:
            $ref: '#/components/schemas/ModelUserPartsSchema'
        name:
          type: string
          maxLength: 512
          description: Name of the user, used to give context on multiplayer chats
        member_role:
          $ref: '#/components/schemas/ModelUserMessageMemberRoleSchema'
        timestamp:
          type: string
          maxLength: 64
          description: >-
            Formatted timestamp for the message, used for time-awareness in
            conversations
      required:
        - role
        - parts
      description: User message
    ModelToolMessageSchema:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the assistant message
        role:
          type: string
          enum:
            - tool
        parts:
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/ModelToolResultPartSchema'
            discriminator:
              propertyName: type
              mapping:
                tool_result:
                  $ref: '#/components/schemas/ModelToolResultPartSchema'
      required:
        - role
        - parts
      description: Tool message
    ModelEventMessageSchema:
      type: object
      properties:
        role:
          type: string
          enum:
            - event
        parts:
          type: array
          items:
            $ref: '#/components/schemas/ModelEventMessagePartsSchema'
        name:
          type: string
        member_role:
          $ref: '#/components/schemas/ModelUserMessageMemberRoleSchema'
        timestamp:
          type: string
          maxLength: 64
      required:
        - role
        - parts
    ModelNoteMessageSchema:
      type: object
      properties:
        role:
          type: string
          enum:
            - note
        parts:
          type: array
          items:
            $ref: '#/components/schemas/ModelUserPartsSchema'
        name:
          type: string
          maxLength: 512
          description: Name of the staff member who wrote the note
        member_role:
          $ref: '#/components/schemas/ModelUserMessageMemberRoleSchema'
        timestamp:
          type: string
          maxLength: 64
          description: >-
            Formatted timestamp for the note, used for time-awareness in
            conversations
      required:
        - role
        - parts
    ChatMemberRoleSchema:
      type: string
      enum:
        - ADMIN
        - MEMBER
      description: The role of the member in the chat
    UserPublicSchema:
      type: object
      properties:
        id:
          type: string
        name:
          type:
            - string
            - 'null'
        avatar:
          type:
            - string
            - 'null'
      required:
        - id
        - name
        - avatar
      description: User who deployed the version
    PublicSessionSchema:
      type: object
      properties:
        id:
          type: string
      required:
        - id
      description: Data that is publicly accessible for a session
    PublicContactChannelSchema:
      type: object
      properties:
        id:
          type: string
        type:
          $ref: '#/components/schemas/ConnectionIntegrationIdSchema'
        user_id:
          type: string
          description: >-
            The unique identifier for the contact channel, e.g Phone Number or
            User ID
        avatar:
          type:
            - string
            - 'null'
          description: The avatar for the contact channel, e.g X Avatar URL
        name:
          type:
            - string
            - 'null'
          description: The name for the contact channel, e.g Full Name
        username:
          type:
            - string
            - 'null'
          description: The username for the contact channel, e.g Username
        email:
          type:
            - string
            - 'null'
          format: email
          description: The email for the contact channel, e.g Email
        phone:
          type:
            - string
            - 'null'
          description: The phone number for the contact channel, e.g Phone Number
        country:
          type:
            - string
            - 'null'
          description: >-
            The country code associated with the contact channel, e.g US for
            United States
        agent:
          type:
            - string
            - 'null'
          description: The user agent associated with the contact channel
        ip:
          type:
            - string
            - 'null'
          description: The IP address associated with the contact channel
        language:
          type:
            - string
            - 'null'
          description: >-
            The language code associated with the contact channel, e.g en for
            English
        link:
          type: string
          description: >-
            A link to the contact channel, e.g a link to the social media
            profile
        contact:
          $ref: '#/components/schemas/PublicContactSchema'
      required:
        - id
        - type
        - user_id
        - avatar
        - name
        - username
        - email
        - phone
        - country
        - agent
        - ip
        - language
        - contact
      description: Schema for the public contact channel
    ModelUsageTurnSchema:
      type: object
      properties:
        input_tokens:
          type: number
          description: Number of input tokens used by the model
        output_tokens:
          type: number
          description: Number of output tokens generated by the model
        total_tokens:
          type: number
          description: Total number of tokens used by the model
        reasoning_tokens:
          type: number
          description: Number of reasoning tokens used by the model
        input_tokens_cache_read:
          type: number
          description: Number of input tokens cached read by the model
        input_tokens_cache_write:
          type: number
          description: Number of input tokens cached written by the model
      description: The usage of a turn
    ModelTextPartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - text
        text:
          type: string
        audio:
          $ref: '#/components/schemas/FileSchema'
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
        - text
    ModelAssistantMessagePartsSchema:
      oneOf:
        - $ref: '#/components/schemas/ModelTextPartSchema'
        - $ref: '#/components/schemas/ModelFilePartSchema'
        - $ref: '#/components/schemas/ModelToolCallPartSchema'
        - $ref: '#/components/schemas/ModelMessageReasoningSchema'
        - $ref: '#/components/schemas/ModelSourcePartSchema'
      discriminator:
        propertyName: type
        mapping:
          text:
            $ref: '#/components/schemas/ModelTextPartSchema'
          file:
            $ref: '#/components/schemas/ModelFilePartSchema'
          tool_call:
            $ref: '#/components/schemas/ModelToolCallPartSchema'
          reasoning:
            $ref: '#/components/schemas/ModelMessageReasoningSchema'
          source:
            $ref: '#/components/schemas/ModelSourcePartSchema'
      description: Parts of the assistant message
    ModelUserPartsSchema:
      oneOf:
        - $ref: '#/components/schemas/ModelTextPartSchema'
        - $ref: '#/components/schemas/ModelFilePartSchema'
        - $ref: '#/components/schemas/ModelImagePartSchema'
        - $ref: '#/components/schemas/ModelOptionSelectedPartSchema'
        - $ref: '#/components/schemas/ModelContactPartSchema'
        - $ref: '#/components/schemas/ModelLocationPartSchema'
      discriminator:
        propertyName: type
        mapping:
          text:
            $ref: '#/components/schemas/ModelTextPartSchema'
          file:
            $ref: '#/components/schemas/ModelFilePartSchema'
          image:
            $ref: '#/components/schemas/ModelImagePartSchema'
          option_selected:
            $ref: '#/components/schemas/ModelOptionSelectedPartSchema'
          contact:
            $ref: '#/components/schemas/ModelContactPartSchema'
          location:
            $ref: '#/components/schemas/ModelLocationPartSchema'
      description: User message parts
    ModelUserMessageMemberRoleSchema:
      type: string
      enum:
        - customer
        - staff
        - user
      description: >-
        Role of the message sender: customer/staff for assistant chats, user for
        regular chats
    ModelToolResultPartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - tool_result
        id:
          type: string
          description: Unique identifier for the tool call
        name:
          type: string
          description: The name of the tool called
        parts:
          type: array
          items:
            $ref: '#/components/schemas/ModelResultPartResultPartsSchema'
          description: Parts of the tool call result
        result:
          description: >-
            The result of the tool call, can be any type based on the tool
            schema
        refresh_tools:
          type: boolean
          description: >-
            Runtime-only signal: when true, the agent loop rebuilds its tool set
            before the next step (e.g. after enable_tools / disable_tools).
            Stripped before the result is persisted.
        is_error:
          type: boolean
          description: Indicates if the tool call resulted in an error
        timestamp:
          type: number
          description: Timestamp of the tool call in milliseconds
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
        - id
        - name
    ModelEventMessagePartsSchema:
      oneOf:
        - $ref: '#/components/schemas/ModelEventAssignmentPartSchema'
        - $ref: '#/components/schemas/ModelEventStatusChangePartSchema'
        - $ref: '#/components/schemas/ModelEventAiStatusPartSchema'
        - $ref: '#/components/schemas/ModelEventMuteChangePartSchema'
        - $ref: '#/components/schemas/ModelEventFollowUpPartSchema'
        - $ref: '#/components/schemas/ModelEventAnalysisPartSchema'
        - $ref: '#/components/schemas/ModelEventReferralPartSchema'
        - $ref: '#/components/schemas/ModelEventApprovalDecisionPartSchema'
        - $ref: '#/components/schemas/ModelEventContactUpdatePartSchema'
        - $ref: '#/components/schemas/ModelEventConnectionConnectedPartSchema'
      discriminator:
        propertyName: type
        mapping:
          event_assignment:
            $ref: '#/components/schemas/ModelEventAssignmentPartSchema'
          event_status_change:
            $ref: '#/components/schemas/ModelEventStatusChangePartSchema'
          event_ai_status:
            $ref: '#/components/schemas/ModelEventAiStatusPartSchema'
          event_mute_change:
            $ref: '#/components/schemas/ModelEventMuteChangePartSchema'
          event_follow_up:
            $ref: '#/components/schemas/ModelEventFollowUpPartSchema'
          event_analysis:
            $ref: '#/components/schemas/ModelEventAnalysisPartSchema'
          event_referral:
            $ref: '#/components/schemas/ModelEventReferralPartSchema'
          event_approval_decision:
            $ref: '#/components/schemas/ModelEventApprovalDecisionPartSchema'
          event_contact_update:
            $ref: '#/components/schemas/ModelEventContactUpdatePartSchema'
          event_connection_connected:
            $ref: '#/components/schemas/ModelEventConnectionConnectedPartSchema'
      description: Parts of the event message
    ConnectionIntegrationIdSchema:
      type: string
      enum:
        - internal
        - org
        - custom
        - whatsapp_bot
        - messenger_bot
        - instagram_dm
        - tiktok_dm
        - telegram_bot
        - gmail
        - slack_bot
        - twilio
        - telnyx
        - email
      description: ID of the connection integration
    PublicContactSchema:
      type: object
      properties:
        id:
          type: string
        name:
          type:
            - string
            - 'null'
        blocked:
          type: boolean
        unsubscribed:
          type: boolean
        ai_replies:
          type: boolean
        is_admin:
          type: boolean
      required:
        - id
        - name
        - blocked
        - unsubscribed
        - ai_replies
        - is_admin
      description: Schema for the contact
    FileSchema:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the file
        file_path:
          type: string
          maxLength: 2048
          description: Path to the file in the storage system
        file_filename:
          type: string
          maxLength: 255
          description: Name of the file
          example: document.pdf
        file_size:
          type: number
          description: Size of the file in bytes
          example: 1024
        file_mimetype:
          type: string
          maxLength: 255
          description: MIME type of the file
          example: application/pdf
        file_url:
          type: string
          maxLength: 2048
          description: URL to access the file
        created_at:
          type:
            - string
            - 'null'
          format: date-time
          description: Timestamp when the file was created
      required:
        - id
        - file_path
        - file_filename
        - file_size
        - file_mimetype
        - file_url
        - created_at
      description: Detailed information about a file
    ModelFilePartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - file
        url:
          type: string
        kind:
          $ref: '#/components/schemas/ModelFileKindSchema'
        file:
          $ref: '#/components/schemas/FileSchema'
        auto_consume:
          type: boolean
          description: >-
            Whether this file should be automatically consumed and processed by
            the model
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
        - url
    ModelToolCallPartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - tool_call
        id:
          type: string
          description: Unique identifier for the tool call
        name:
          type: string
          description: The name of the tool to call
        display_name:
          type: string
        action_name:
          type: string
        description:
          type: string
          description: >-
            Model-authored, present-tense summary of what this call is doing
            (lifted from the injected _description param when the tool sets
            describe). Shown as the action title in the UI.
        args:
          $ref: '#/components/schemas/ModelToolCallArgumentsSchema'
        metadata:
          type: object
          properties: {}
          additionalProperties: {}
          description: >-
            Metadata associated with the tool call, can include signature
            information
        approval:
          $ref: '#/components/schemas/ConnectionActionApprovalSchema'
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
        - id
        - name
    ModelMessageReasoningSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - reasoning
        id:
          type: string
          description: Unique identifier for the message part
        text:
          type: string
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
        - id
        - text
    ModelSourcePartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - source
        id:
          type: string
          description: Unique identifier for the source, typically a link identifier
        url:
          type: string
        title:
          type: string
          description: Title of the source, typically a document or webpage title
        description:
          type: string
          description: >-
            Description of the source, can be a summary or excerpt from the
            content
        favicon:
          type: string
          description: Favicon URL for the source, can be used in UI
        metadata:
          type: object
          properties: {}
          additionalProperties: {}
          description: >-
            Metadata associated with the source, can include additional
            information like author, date, etc.
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
        - id
        - url
      description: Source URL for the message, typically used for annotations
    ModelImagePartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - image
        url:
          type: string
        kind:
          $ref: '#/components/schemas/ModelFileKindSchema'
        file:
          $ref: '#/components/schemas/FileSchema'
        auto_consume:
          type: boolean
          description: >-
            Whether this file should be automatically consumed and processed by
            the model
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
        - url
    ModelOptionSelectedPartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - option_selected
        call_id:
          type: string
          description: The ID of the tool call that generated the options
        label:
          type: string
          description: Label for the option selected
        value:
          type: string
          description: Value for the option selected
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
        - label
        - value
      description: Option selected by the user, typically used in multiple choice scenarios
    ModelContactPartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - contact
        name:
          type: string
        email:
          type: string
        phone:
          type: string
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
    ModelLocationPartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - location
        latitude:
          type: number
        longitude:
          type: number
        name:
          type: string
        address:
          type: string
        url:
          type: string
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
    ModelResultPartResultPartsSchema:
      oneOf:
        - $ref: '#/components/schemas/ModelTextPartSchema'
        - $ref: '#/components/schemas/ModelImagePartSchema'
        - $ref: '#/components/schemas/ModelFilePartSchema'
        - $ref: '#/components/schemas/ModelLocationPartSchema'
        - $ref: '#/components/schemas/ModelSourcePartSchema'
      discriminator:
        propertyName: type
        mapping:
          text:
            $ref: '#/components/schemas/ModelTextPartSchema'
          image:
            $ref: '#/components/schemas/ModelImagePartSchema'
          file:
            $ref: '#/components/schemas/ModelFilePartSchema'
          location:
            $ref: '#/components/schemas/ModelLocationPartSchema'
          source:
            $ref: '#/components/schemas/ModelSourcePartSchema'
      description: Parts of the tool call result
    ModelEventAssignmentPartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - event_assignment
        assigned_user_id:
          type:
            - string
            - 'null'
        source:
          $ref: '#/components/schemas/ModelEventSourceSchema'
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
        - assigned_user_id
        - source
      description: Assignment event part - text generated from locales
    ModelEventStatusChangePartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - event_status_change
        old_status:
          type: string
          enum:
            - OPEN
            - SNOOZED
            - CLOSED
        new_status:
          type: string
          enum:
            - OPEN
            - SNOOZED
            - CLOSED
        source:
          $ref: '#/components/schemas/ModelEventSourceSchema'
        follow_up_at:
          type: string
          format: date-time
          description: Scheduled follow-up date (ISO 8601)
        reason:
          type: string
          maxLength: 512
          description: AI analysis reason for the decision
        csat_score:
          type: integer
          minimum: 1
          maximum: 5
          description: AI-assigned customer satisfaction score (1-5)
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
        - old_status
        - new_status
        - source
      description: Status change event part (user-visible) - text generated from locales
    ModelEventAiStatusPartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - event_ai_status
        status:
          type: boolean
        source:
          $ref: '#/components/schemas/ModelEventSourceSchema'
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
        - status
        - source
      description: AI toggle event part - text generated from locales
    ModelEventMuteChangePartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - event_mute_change
        muted_until:
          type:
            - string
            - 'null'
          format: date-time
          description: New mute expiry datetime (null = un-muted)
        source:
          $ref: '#/components/schemas/ModelEventMuteSourceSchema'
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
        - muted_until
        - source
      description: Mute change event part
    ModelEventFollowUpPartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - event_follow_up
        old_status:
          type: string
          enum:
            - OPEN
            - SNOOZED
            - CLOSED
        new_status:
          type: string
          enum:
            - OPEN
            - SNOOZED
            - CLOSED
        reason:
          type: string
          maxLength: 512
          description: AI analysis reason for the follow-up
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
      description: Follow-up event — AI re-engaging an inactive conversation
    ModelEventAnalysisPartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - event_analysis
        csat_score:
          type: integer
          minimum: 1
          maximum: 5
          description: AI-assigned customer satisfaction score (1-5)
        reason:
          type: string
          maxLength: 512
          description: Brief reason for the analysis result
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
      description: Analysis event — AI post-conversation analysis (CSAT, etc.)
    ModelEventReferralPartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - event_referral
        referral:
          $ref: '#/components/schemas/ChatReferralSchema'
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
        - referral
      description: >-
        Referral event — conversation initiated or resumed from an ad, post, or
        story
    ModelEventApprovalDecisionPartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - event_approval_decision
        tool_call_id:
          type: string
          description: Tool call id the decision was made on
        action_id:
          type: string
          description: >-
            Canonical id of the gated action (the tool name, e.g.
            TOOLS:HTTP_REQUEST)
        action_name:
          type: string
          description: >-
            User-facing display name of the action at decision time, when
            available
        decision:
          type: string
          enum:
            - accepted
            - rejected
        reason:
          type: string
          maxLength: 512
          description: Optional reason supplied with the decision
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
        - tool_call_id
        - action_id
        - decision
      description: >-
        Approval decision event — a pending action was accepted or rejected by a
        chat member. The decider is the owner of the parent ChatMessage.
    ModelEventContactUpdatePartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - event_contact_update
        changes:
          type: array
          items:
            $ref: '#/components/schemas/ModelContactFieldChangeSchema'
          minItems: 1
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
        - changes
      description: >-
        AI updated one or more contact properties. Emitted from the
        update_contact tool callback or the post-conversation analysis pass.
    ModelEventConnectionConnectedPartSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - event_connection_connected
        tool_call_id:
          type: string
          description: Tool call id this connection answers (the request_connection call)
        connection_id:
          type: string
          description: The connected connection id (con_...)
        connection_type:
          type: string
          description: Connection app type, e.g. GOOGLE_SHEETS
        connection_name:
          type: string
          description: The name of the connection, e.g. "Google Sheets"
        start_timestamp:
          type: number
          description: Timestamp when the message part started processing, in milliseconds
        end_timestamp:
          type: number
          description: Timestamp when the message part finished processing, in milliseconds
      required:
        - type
        - tool_call_id
        - connection_id
      description: >-
        Connection-connected event: the user connected an app in response to
        request_connection.
    ModelFileKindSchema:
      type: string
      enum:
        - voice
        - sticker
      description: >-
        Marks communication-only files (voice notes, stickers) from integrations
        so they can be excluded from the contact files tab.
    ModelToolCallArgumentsSchema:
      description: Arguments for the tool call
    ConnectionActionApprovalSchema:
      type: object
      properties:
        title:
          type: string
          maxLength: 140
          description: >-
            Short heading shown on the approval card, in the conversation
            language
        accept_button:
          type: string
          maxLength: 32
          description: Label for the accept button, in the conversation language
        reject_button:
          type: string
          maxLength: 32
          description: Label for the reject button, in the conversation language
        decision:
          $ref: '#/components/schemas/ConnectionActionApprovalDecisionSchema'
        decided_at:
          type: number
          description: Decision timestamp in milliseconds since epoch
        decided_by_member_id:
          type: string
          description: Encoded chat member id of the decider
        reason:
          type: string
          maxLength: 512
          description: Optional reason supplied with the decision
      required:
        - title
        - accept_button
        - reject_button
      description: >-
        Approval prompt and decision state when the action requires confirmation
        before running
    ModelEventSourceSchema:
      type: string
      enum:
        - user
        - agent
        - ai
      description: Source of the event
    ModelEventMuteSourceSchema:
      type: string
      enum:
        - agent
        - system
      description: Source of the mute event (only humans or system)
    ChatReferralSchema:
      oneOf:
        - $ref: '#/components/schemas/ChatMessengerAdSchema'
        - $ref: '#/components/schemas/ChatMessengerProductSchema'
        - $ref: '#/components/schemas/ChatMessengerProductTemplateSchema'
        - $ref: '#/components/schemas/ChatWhatsAppAdSchema'
        - $ref: '#/components/schemas/ChatWhatsAppProductSchema'
        - $ref: '#/components/schemas/ChatWhatsAppOrderSchema'
        - $ref: '#/components/schemas/ChatInstagramAdSchema'
        - $ref: '#/components/schemas/ChatInstagramProductSchema'
        - $ref: '#/components/schemas/ChatInstagramProductTemplateSchema'
        - $ref: '#/components/schemas/ChatInstagramPostSchema'
        - $ref: '#/components/schemas/ChatInstagramReelSchema'
        - $ref: '#/components/schemas/ChatInstagramStorySchema'
        - $ref: '#/components/schemas/ChatInstagramStoryMentionSchema'
        - $ref: '#/components/schemas/ChatMessengerPostSchema'
        - $ref: '#/components/schemas/ChatMessengerReelSchema'
        - $ref: '#/components/schemas/ChatTikTokAdSchema'
        - $ref: '#/components/schemas/ChatTikTokPostShareSchema'
        - $ref: '#/components/schemas/ChatTikTokShortLinkSchema'
        - $ref: '#/components/schemas/ChatWebWidgetReferralSchema'
      discriminator:
        propertyName: type
        mapping:
          messenger_ad:
            $ref: '#/components/schemas/ChatMessengerAdSchema'
          messenger_product:
            $ref: '#/components/schemas/ChatMessengerProductSchema'
          messenger_product_template:
            $ref: '#/components/schemas/ChatMessengerProductTemplateSchema'
          whatsapp_ad:
            $ref: '#/components/schemas/ChatWhatsAppAdSchema'
          whatsapp_product:
            $ref: '#/components/schemas/ChatWhatsAppProductSchema'
          whatsapp_order:
            $ref: '#/components/schemas/ChatWhatsAppOrderSchema'
          instagram_ad:
            $ref: '#/components/schemas/ChatInstagramAdSchema'
          instagram_product:
            $ref: '#/components/schemas/ChatInstagramProductSchema'
          instagram_product_template:
            $ref: '#/components/schemas/ChatInstagramProductTemplateSchema'
          instagram_post:
            $ref: '#/components/schemas/ChatInstagramPostSchema'
          instagram_reel:
            $ref: '#/components/schemas/ChatInstagramReelSchema'
          instagram_story:
            $ref: '#/components/schemas/ChatInstagramStorySchema'
          instagram_story_mention:
            $ref: '#/components/schemas/ChatInstagramStoryMentionSchema'
          messenger_post:
            $ref: '#/components/schemas/ChatMessengerPostSchema'
          messenger_reel:
            $ref: '#/components/schemas/ChatMessengerReelSchema'
          tiktok_ad:
            $ref: '#/components/schemas/ChatTikTokAdSchema'
          tiktok_post_share:
            $ref: '#/components/schemas/ChatTikTokPostShareSchema'
          tiktok_short_link:
            $ref: '#/components/schemas/ChatTikTokShortLinkSchema'
          web_widget:
            $ref: '#/components/schemas/ChatWebWidgetReferralSchema'
      description: >-
        Referral/commerce event data from Meta platforms — ads, products,
        orders.
    ModelContactFieldChangeSchema:
      type: object
      properties:
        field:
          type: string
          description: Contact field key.
        before: {}
        after: {}
      required:
        - field
      description: >-
        A single contact-property change. FE looks up the rest (id, name, type)
        by key against the assistant's contact-field whitelist.
    ChatMessengerAdSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - messenger_ad
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        ref:
          type: string
        ad_id:
          type: string
        source:
          type: string
        referer_uri:
          type: string
        ads_context_data:
          type: object
          properties:
            ad_title:
              type: string
            photo_url:
              type: string
            video_url:
              type: string
            post_id:
              type: string
            product_id:
              type: string
      required:
        - type
    ChatMessengerProductSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - messenger_product
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        product:
          type: object
          properties:
            id:
              type: string
            name:
              type: string
            image_url:
              type: string
            price:
              type: string
            description:
              type: string
            url:
              type: string
          required:
            - id
      required:
        - type
        - product
    ChatMessengerProductTemplateSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - messenger_product_template
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        products:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              retailer_id:
                type: string
              image_url:
                type: string
              title:
                type: string
              subtitle:
                type: string
            required:
              - id
      required:
        - type
        - products
    ChatWhatsAppAdSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - whatsapp_ad
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        source_url:
          type: string
        source_id:
          type: string
        source_type:
          type: string
        headline:
          type: string
        body:
          type: string
        media_type:
          type: string
        image_url:
          type: string
        video_url:
          type: string
        thumbnail_url:
          type: string
        ctwa_clid:
          type: string
      required:
        - type
    ChatWhatsAppProductSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - whatsapp_product
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        catalog_id:
          type: string
        product_retailer_id:
          type: string
        name:
          type: string
        image_url:
          type: string
        price:
          type: string
        description:
          type: string
        url:
          type: string
        retailer_id:
          type: string
      required:
        - type
        - catalog_id
        - product_retailer_id
    ChatWhatsAppOrderSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - whatsapp_order
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        catalog_id:
          type: string
        product_items:
          type: array
          items:
            type: object
            properties:
              product_retailer_id:
                type: string
              quantity:
                type: number
              item_price:
                type: number
              currency:
                type: string
              name:
                type: string
              image_url:
                type: string
              price:
                type: string
              description:
                type: string
              url:
                type: string
              retailer_id:
                type: string
            required:
              - product_retailer_id
              - quantity
              - item_price
              - currency
        text:
          type: string
      required:
        - type
        - catalog_id
        - product_items
    ChatInstagramAdSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - instagram_ad
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        ref:
          type: string
        ad_id:
          type: string
        source:
          type: string
        ads_context_data:
          type: object
          properties:
            ad_title:
              type: string
            photo_url:
              type: string
            video_url:
              type: string
      required:
        - type
    ChatInstagramProductSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - instagram_product
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        product:
          type: object
          properties:
            id:
              type: string
            name:
              type: string
            image_url:
              type: string
            price:
              type: string
            description:
              type: string
            url:
              type: string
          required:
            - id
      required:
        - type
        - product
    ChatInstagramProductTemplateSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - instagram_product_template
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        products:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              retailer_id:
                type: string
              image_url:
                type: string
              title:
                type: string
              subtitle:
                type: string
            required:
              - id
      required:
        - type
        - products
    ChatInstagramPostSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - instagram_post
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        post_id:
          type: string
        post_media_id:
          type: string
        title:
          type: string
        media_url:
          type: string
        username:
          type: string
        permalink:
          type: string
      required:
        - type
    ChatInstagramReelSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - instagram_reel
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        reel_video_id:
          type: string
        title:
          type: string
        media_url:
          type: string
        username:
          type: string
        permalink:
          type: string
      required:
        - type
    ChatInstagramStorySchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - instagram_story
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        story_media_id:
          type: string
        media_url:
          type: string
        username:
          type: string
        permalink:
          type: string
      required:
        - type
    ChatInstagramStoryMentionSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - instagram_story_mention
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        media_url:
          type: string
        username:
          type: string
        permalink:
          type: string
      required:
        - type
    ChatMessengerPostSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - messenger_post
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        post_id:
          type: string
        title:
          type: string
        permalink:
          type: string
        media_url:
          type: string
      required:
        - type
    ChatMessengerReelSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - messenger_reel
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        reel_video_id:
          type: string
        title:
          type: string
        permalink:
          type: string
        media_url:
          type: string
      required:
        - type
    ChatTikTokAdSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - tiktok_ad
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        advertiser_id:
          type: string
        ad_id:
          type: string
        ad_name:
          type: string
        embed_url:
          type: string
        message_material_id:
          type: string
        timestamp:
          type: number
      required:
        - type
    ChatTikTokPostShareSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - tiktok_post_share
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        video_id:
          type: string
        embed_url:
          type: string
      required:
        - type
    ChatTikTokShortLinkSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - tiktok_short_link
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        ref:
          type: string
        prefilled_message:
          type: string
        prefilled_message_audit_status:
          type: string
          enum:
            - PASS
            - REJECT
      required:
        - type
    ChatWebWidgetReferralSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - web_widget
        parts:
          $ref: '#/components/schemas/ChatMessageReferralPartsSchema'
        utm_source:
          type: string
        utm_medium:
          type: string
        utm_campaign:
          type: string
        utm_term:
          type: string
        utm_content:
          type: string
        utm_ad:
          type: string
        utm_match:
          type: string
        utm_referrer:
          type: string
        gclid:
          type: string
        fbclid:
          type: string
        msclkid:
          type: string
        ttclid:
          type: string
        li_fat_id:
          type: string
        rdt_cid:
          type: string
        referrer:
          type: string
        page_url:
          type: string
      required:
        - type
    ChatMessageReferralPartsSchema:
      type: array
      items:
        oneOf:
          - $ref: '#/components/schemas/ModelFilePartSchema'
          - $ref: '#/components/schemas/ModelImagePartSchema'
        discriminator:
          propertyName: type
          mapping:
            file:
              $ref: '#/components/schemas/ModelFilePartSchema'
            image:
              $ref: '#/components/schemas/ModelImagePartSchema'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: Bearer token authentication using your API key

````