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

# Get ticket history

> Returns ticket metadata and a chunk of ticket messages for the API key company. If the response contains `nextChunkStartMessageId`, pass it as `chunkLastMessageId` to load the next chunk.

Required API key scope: `read`.



## OpenAPI

````yaml /openapi/public-api-v1.json get /v1/tickets/{ticketId}/history
openapi: 3.1.0
info:
  title: YoLead Public API
  version: 1.0.0
  description: >-
    Public REST API for YoLead integrations. Only endpoints mounted under /v1
    are included. Management endpoints used by the YoLead UI, including
    /integrations/*, are intentionally excluded.
servers:
  - url: https://api.yo-lead.com
    description: Production
security:
  - YoLeadPublicKey: []
    YoLeadTimestamp: []
    YoLeadSignature: []
tags:
  - name: Employees
    description: Employee data available to integrations.
  - name: Embed
    description: Iframe session creation for embedding YoLead UI.
  - name: Tickets
    description: Ticket history and status operations.
paths:
  /v1/tickets/{ticketId}/history:
    get:
      tags:
        - Tickets
      summary: Get ticket history
      description: >-
        Returns ticket metadata and a chunk of ticket messages for the API key
        company. If the response contains `nextChunkStartMessageId`, pass it as
        `chunkLastMessageId` to load the next chunk.


        Required API key scope: `read`.
      operationId: getTicketHistory
      parameters:
        - $ref: '#/components/parameters/TicketId'
        - name: chunkLastMessageId
          in: query
          required: false
          description: >-
            Cursor returned as `nextChunkStartMessageId` by the previous history
            response.
          schema:
            type: string
            minLength: 1
          example: wamid.HBg...
      responses:
        '200':
          description: Ticket history.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetTicketHistoryResponse'
              example:
                data:
                  ticket:
                    id: 64f000000000000000000003
                    chatId: 64f000000000000000000002
                    status: active
                    assigneeId: 64f000000000000000000001
                    startedAt: '2026-05-08T11:00:00.000Z'
                  messages:
                    - id: wamid.HBg...
                      sentAt: '2026-05-08T11:01:00.000Z'
                      fromId: '15551234567'
                      direction: incoming
                      text: Hello
                      attachments: []
                  nextChunkStartMessageId: wamid.HBg...
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    TicketId:
      name: ticketId
      in: path
      required: true
      description: Ticket id.
      schema:
        $ref: '#/components/schemas/ObjectId'
      example: 64f000000000000000000003
  schemas:
    GetTicketHistoryResponse:
      type: object
      additionalProperties: false
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/TicketHistory'
    ObjectId:
      type: string
      pattern: ^[0-9a-fA-F]{24}$
      description: MongoDB ObjectId represented as a 24-character hexadecimal string.
      example: 64f000000000000000000001
    TicketHistory:
      type: object
      additionalProperties: false
      required:
        - ticket
        - messages
      properties:
        ticket:
          $ref: '#/components/schemas/TicketHistoryTicket'
        messages:
          type: array
          items:
            $ref: '#/components/schemas/TicketHistoryMessage'
        nextChunkStartMessageId:
          oneOf:
            - type: string
            - type: number
    ErrorResponse:
      type: object
      additionalProperties: false
      required:
        - code
        - message
      properties:
        code:
          type: integer
          example: 40001
        message:
          type: string
          example: Validation error
    TicketHistoryTicket:
      type: object
      additionalProperties: false
      required:
        - id
        - chatId
        - status
        - startedAt
      properties:
        id:
          $ref: '#/components/schemas/ObjectId'
        chatId:
          $ref: '#/components/schemas/ObjectId'
        status:
          $ref: '#/components/schemas/TicketStatus'
        assigneeId:
          $ref: '#/components/schemas/ObjectId'
        startedAt:
          $ref: '#/components/schemas/IsoDateTime'
        endedAt:
          $ref: '#/components/schemas/IsoDateTime'
    TicketHistoryMessage:
      type: object
      additionalProperties: false
      required:
        - id
        - fromId
        - direction
        - text
        - attachments
      properties:
        id:
          type: string
          example: wamid.HBg...
        sentAt:
          $ref: '#/components/schemas/IsoDateTime'
        fromId:
          type: string
          example: '15551234567'
        direction:
          type: string
          enum:
            - incoming
            - outgoing
        text:
          type: string
          example: Hello
        attachments:
          type: array
          items: {}
        isDeleted:
          type: boolean
        broadcastReply: {}
    TicketStatus:
      type: string
      enum:
        - new
        - active
        - inactive
    IsoDateTime:
      type: string
      format: date-time
      description: ISO 8601 date-time string.
      example: '2026-05-08T12:00:00.000Z'
  responses:
    ValidationError:
      description: Validation error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: 40001
            message: Validation error
    Unauthorized:
      description: Invalid API credentials, stale timestamp, or invalid request signature.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: 40121
            message: Invalid API credentials
    Forbidden:
      description: API key scope is not sufficient for this operation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: 40361
            message: API key scope is not sufficient
    NotFound:
      description: Requested entity was not found or is not accessible for this company.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: 40471
            message: Ticket not found
    InternalServerError:
      description: Unexpected server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: 50001
            message: Internal server error
  securitySchemes:
    YoLeadPublicKey:
      type: apiKey
      in: header
      name: X-YoLead-Key
      description: Public API key generated in the YoLead UI.
    YoLeadTimestamp:
      type: apiKey
      in: header
      name: X-YoLead-Timestamp
      description: >-
        Unix timestamp in milliseconds. Requests must be signed within a
        5-minute window.
    YoLeadSignature:
      type: apiKey
      in: header
      name: X-YoLead-Signature
      description: >-
        Hex HMAC-SHA256 signature over `<timestamp>.<raw_body>` using the API
        secret.

````