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

# Get a chat session by ticket number

> Retrieves a specific chat session by exact ticket number. Use when orchestrating sessions from code.



## OpenAPI

````yaml get /chat/sessions/ticket/{ticket_number}
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/ticket/{ticket_number}:
    get:
      summary: Get a chat session by ticket number
      description: Retrieves a specific chat session by exact ticket number.
      operationId: getChatSessionByTicketNumber
      parameters:
        - schema:
            type: string
          in: path
          name: ticket_number
          required: true
          description: 'The exact ticket number, e.g. 4521 or #4521'
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetChatSessionOutput'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
components:
  schemas:
    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:
                - 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.
      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
      additionalProperties: false
    ErrorDto:
      type: object
      properties:
        statusCode:
          type: integer
        message:
          type: string
        error:
          type: string
    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
        - 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.