> ## 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.

# Change the contact of a chat session

> Move an email session to another contact without sending anything, named either by contact ID or by email. Later replies go to the new contact and the session moves to their history.



## OpenAPI

````yaml post /chat/sessions/{session_id}/contact
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}/contact:
    post:
      summary: Change the contact of a chat session
      description: >-
        Moves an email session to another contact, named either by `contact_id`
        (an existing contact in this organization) or by `email` (an existing
        contact with that address and no external ID is reused, otherwise one is
        created; use `contact_id` for a contact with an external ID) — exactly
        one. Nothing is sent to anyone. Later replies go to the new contact, the
        session moves to their history, and an internal event is added to the
        session timeline. Only native OpenCX email sessions with a connected
        inbox, and Zendesk email sessions with recipient synchronization, are
        supported; other sessions are rejected with 400. A closed Zendesk
        ticket, or one whose recipient edits are paused, is rejected with 409. A
        contact from another organization is rejected with 404.
      operationId: changeChatSessionContact
      parameters:
        - schema:
            type: string
          in: path
          name: session_id
          required: true
          description: The unique identifier of the chat session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChangeSessionContactDto'
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionContactUpdateOutput'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
components:
  schemas:
    ChangeSessionContactDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/ChangeSessionContactDtoInput'
      type: object
      properties:
        contact_id:
          description: ID of an existing contact in this organization
          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)$
        email:
          description: >-
            Email of the new contact; an existing contact with that address and
            no external ID is reused, otherwise one is created. Use contact_id
            for a contact with an external ID
          type: string
          format: email
          pattern: >-
            ^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$
    SessionContactUpdateOutput:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/SessionContactUpdateOutput'
      type: object
      properties:
        no_change:
          type: boolean
        session:
          $ref: '#/components/schemas/GetChatSessionOutput'
      required:
        - no_change
        - session
      additionalProperties: false
    ErrorDto:
      type: object
      properties:
        statusCode:
          type: integer
        message:
          type: string
        error:
          type: string
    GetChatSessionOutput:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/GetChatSessionOutput'
      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)$
        merge:
          anyOf:
            - 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)$
                primary_session_id:
                  anyOf:
                    - type: string
                      format: uuid
                      pattern: >-
                        ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                    - type: 'null'
                merged_at:
                  anyOf:
                    - type: string
                      format: date-time
                    - type: 'null'
              required:
                - id
                - primary_session_id
                - merged_at
              additionalProperties: false
            - type: 'null'
        tags:
          type: array
          items:
            $ref: '#/components/schemas/SessionTagOutput'
          description: >-
            All tags currently assigned to this session, ordered by tag name.
            Empty when no tags are assigned.
        status:
          type: string
          enum:
            - open
            - closed_resolved
            - closed_unresolved
        sub_status_id:
          description: >-
            Id of the custom status refining `status`, or null when only the
            built-in status applies. Resolve it with GET /custom-statuses.
          type:
            - string
            - 'null'
        ai_closure_type:
          anyOf:
            - type: string
              enum:
                - assumed_resolved
                - handed_off
                - resolved
            - type: 'null'
        sentiment:
          anyOf:
            - type: string
              enum:
                - angry
                - happy
                - neutral
            - type: 'null'
        summary:
          description: >-
            AI-generated summary of the conversation. Populated for both
            AI-resolved and handed-off sessions once the session has been
            summarized; null otherwise.
          type:
            - string
            - 'null'
        title:
          description: >-
            Session title: the email subject, a subject set by an agent, or an
            AI-generated title. Null until one is set.
          type:
            - string
            - 'null'
        channel:
          type: object
          properties:
            type:
              $ref: '#/components/schemas/SessionChannel'
          required:
            - type
          additionalProperties: false
        contact:
          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)$
            external_id:
              description: >-
                The contact's ID in your system, unique within your
                organization, or null when the contact was not identified by
                external ID. Set through external-ID widget authentication or
                the contact create/update endpoints.
              type:
                - string
                - 'null'
            primary_external_id:
              description: >-
                The main account's external_id within your organization, or null
                when unlinked. The main contact may not exist yet. Set through
                external-ID widget authentication or the contact create/update
                endpoints.
              type:
                - string
                - 'null'
            email:
              anyOf:
                - type: string
                  format: email
                  pattern: >-
                    ^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$
                - type: 'null'
            phone_number:
              type:
                - string
                - 'null'
            name:
              type:
                - string
                - 'null'
            custom_data:
              anyOf:
                - type: object
                  propertyNames:
                    type: string
                  additionalProperties:
                    type: string
                - type: 'null'
            non_verified_custom_data:
              anyOf:
                - type: object
                  propertyNames:
                    type: string
                  additionalProperties:
                    type:
                      - string
                      - number
                      - boolean
                - type: 'null'
            created_at:
              type: string
              description: ISO 8601 timestamp of when the contact was created
            updated_at:
              type: string
              description: ISO 8601 timestamp of when the contact was last updated
            restricted_channels:
              type: array
              items:
                $ref: '#/components/schemas/RestrictableChannel'
              description: >-
                Channels this contact asked not to be contacted on: any of
                `email`, `sms`, `whatsapp`, `phone_voice`. Nothing your team,
                workflows, sequences or the API start goes out to the contact on
                a listed channel; AI replies to the contact's messages and your
                team's replies in a session on that channel are still delivered.
                Empty when nothing is restricted.
            non_verified_name:
              type:
                - string
                - 'null'
            non_verified_email:
              type:
                - string
                - 'null'
          required:
            - id
            - external_id
            - primary_external_id
            - email
            - phone_number
            - name
            - custom_data
            - non_verified_custom_data
            - created_at
            - updated_at
            - restricted_channels
            - non_verified_name
            - non_verified_email
          additionalProperties: false
        language:
          type: string
        assignee_id:
          description: >-
            Deprecated: use assignee. Contains the recorded human user ID as a
            string, or null for AI and unassigned sessions. Use assignee.type to
            distinguish them. This deprecation applies only to response fields;
            assignment requests still accept assignee_id.
          deprecated: true
          type:
            - string
            - 'null'
        assignee:
          $ref: '#/components/schemas/ChatSessionAssignee'
        custom_data:
          description: Session-level custom data stored on the chat session.
          type: object
          propertyNames:
            type: string
          additionalProperties:
            type:
              - string
              - number
              - boolean
        editable_custom_data:
          description: >-
            Session attributes set in the inbox, including Structured Field
            answers keyed by the field key (for example `slg_attempted`). Kept
            separate from `custom_data`. This field will be deprecated in a
            future release and its keys merged into `custom_data`.
          type: object
          propertyNames:
            type: string
          additionalProperties:
            type: string
        team:
          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)$
            name:
              type: string
            description:
              type: string
          required:
            - id
            - name
          additionalProperties: false
        support_team:
          anyOf:
            - 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)$
                  description: Stable team ID, preserved when the team is renamed.
                name:
                  type: string
              required:
                - id
                - name
              additionalProperties: false
            - type: 'null'
          description: >-
            Support team assigned to this session. Null when no team can be
            resolved within the session organization.
        handoff:
          type: object
          properties:
            sentiment:
              type: string
              enum:
                - angry
                - happy
                - neutral
            summary:
              type: string
          required:
            - summary
          additionalProperties: false
        ticketing_system:
          type: object
          properties:
            name:
              type: string
              enum:
                - crisp
                - dynamics365
                - freshchat
                - freshdesk
                - freshdesk_ticketing
                - front
                - genesys
                - gorgias
                - hubspot
                - infobip
                - intercom
                - jira_service_management
                - open
                - salesforce
                - salesforce_v2
                - twilio_flex
                - zendesk
                - zendesk_v2
            external_id:
              type: string
            id_type:
              type: string
              enum:
                - conversation_id
                - ticket_id
                - case_id
                - conversation_sid
          required:
            - name
            - external_id
            - id_type
          additionalProperties: false
        ticket_number:
          type: number
        assist_mode:
          type: boolean
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        first_human_message_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          description: >-
            Timestamp of the first recorded human reply to this session. Null
            when no human reply has been recorded.
        erased_due_to_retention_threshold_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          description: >-
            When the organization's session retention rules erased this
            session's content. An erased session stays closed for good. Null
            when it has not been erased.
      required:
        - id
        - merge
        - tags
        - status
        - sub_status_id
        - ai_closure_type
        - sentiment
        - summary
        - title
        - channel
        - assignee
        - support_team
        - ticket_number
        - assist_mode
        - created_at
        - updated_at
        - first_human_message_at
        - erased_due_to_retention_threshold_at
      additionalProperties: false
    SessionTagOutput:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/SessionTagOutput'
      type: object
      properties:
        tag_name:
          type: string
        created_at:
          type: string
          format: date-time
      required:
        - tag_name
        - created_at
      additionalProperties: false
    SessionChannel:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/SessionChannel'
      type: string
      enum:
        - web
        - email
        - phone_voice
        - slack
        - sms
        - whatsapp
        - instagram
        - messenger
        - api
        - web_voice
        - twitter
        - twitter_mentions
        - app_review
        - location_review
        - internal
    RestrictableChannel:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/RestrictableChannel'
      type: string
      enum:
        - email
        - sms
        - whatsapp
        - phone_voice
    ChatSessionAssignee:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/ChatSessionAssignee'
      oneOf:
        - type: object
          properties:
            type:
              type: string
              const: human
            id:
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
              description: Human user ID, matching the numeric ID in GET /users.
            name:
              description: >-
                Current organization display name, matching GET /users, or null
                if the user is no longer a member of this organization or cannot
                be found. The recorded human ID is retained.
              type:
                - string
                - 'null'
          required:
            - type
            - id
            - name
          additionalProperties: false
        - type: object
          properties:
            type:
              type: string
              const: ai
          required:
            - type
          additionalProperties: false
        - type: object
          properties:
            type:
              type: string
              const: none
          required:
            - type
          additionalProperties: false
      description: >-
        Current session assignment. AI and unassigned sessions have no assignee
        ID.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

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