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

# Get Worker Messages

> Returns a Worker's saved message history in AI SDK `UIMessage` format. Internal execution steps and tool inputs are omitted.



## OpenAPI

````yaml /openapi.json get /v1/rooms/{roomId}/workers/{workerId}/messages
openapi: 3.1.0
info:
  title: Worklayer Factory API
  version: 1.0.0
  description: >-
    Create custom interfaces to interact with your Worklayer factory—an
    always-on workspace with its own connected apps, skills, memory, files, and
    background Workers (also called an Environment in parts of the web app).
    Send Events into Rooms, read Room History, resolve human Reviews, follow or
    steer Workers, and receive real-time updates via signed Subscriptions.
servers:
  - url: https://api.myworklayer.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Rooms
    description: >-
      Create and manage isolated Rooms and read Room History. Every factory
      includes a main Room (`web`) and supports creating additional Rooms via
      the API. Room History is read-only.
  - name: Events
    description: Send Events into a Room and retrieve stored API Events.
  - name: Workers
    description: Inspect, stream, and steer background Workers spawned by your factory.
  - name: Review
    description: >-
      List and resolve pending approvals, questions, and app connections
      blocking a Worker.
  - name: Subscriptions
    description: >-
      Create, update, rotate, and delete HTTPS webhook endpoints for your
      factory.
  - name: Subscription events
    description: Signed webhook payloads delivered by Worklayer when factory events occur.
paths:
  /v1/rooms/{roomId}/workers/{workerId}/messages:
    parameters:
      - $ref: '#/components/parameters/RoomId'
      - $ref: '#/components/parameters/WorkerId'
    get:
      tags:
        - Workers
      summary: Get Worker Messages
      description: >-
        Returns a Worker's saved message history in AI SDK `UIMessage` format.
        Internal execution steps and tool inputs are omitted.
      operationId: getWorkerMessages
      parameters:
        - name: order
          in: query
          description: '`asc`: oldest first. `desc`: newest first.'
          schema:
            type: string
            enum:
              - asc
              - desc
            default: asc
        - $ref: '#/components/parameters/Limit100'
        - $ref: '#/components/parameters/Cursor4096'
      responses:
        '200':
          description: A page of messages.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkerMessagePage'
              example:
                messages:
                  - id: msg_01
                    role: user
                    parts:
                      - type: text
                        text: >-
                          Send the tracking number of order 1188 to the customer
                          of ticket 4821.
                  - id: msg_02
                    role: assistant
                    parts:
                      - type: dynamic-tool
                        toolCallId: toolu_01Qx8
                        toolName: zendesk_add_comment
                        input: null
                        state: output-available
                        output: null
                      - type: text
                        text: >-
                          I added the tracking number 1Z999AA10123456784 to
                          ticket 4821.
                nextCursor: null
        '400':
          description: >-
            A query parameter is not valid, or the cursor does not match this
            request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                statusCode: 400
                message: Invalid cursor for this request.
                error: Bad Request
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/WorkerNotFound'
        '422':
          description: >-
            The API cannot return the history, because one part of it is too
            large.
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                properties:
                  code:
                    const: worker_history_group_too_large
                  message:
                    type: string
              example:
                code: worker_history_group_too_large
                message: More than 512 stored rows share a timestamp.
        '429':
          $ref: '#/components/responses/TooManyRequests'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl
            "https://api.myworklayer.com/v1/rooms/cmhx3q7v20004l808sd5k2r1m/workers/6f1c2a9e-4b7d-4e2a-9c51-3d8e0b7a1f24/messages?order=asc&limit=30"
            \
              -H "Authorization: Bearer $WORKLAYER_API_KEY"
        - lang: javascript
          label: fetch
          source: >-
            const response = await
            fetch('https://api.myworklayer.com/v1/rooms/cmhx3q7v20004l808sd5k2r1m/workers/6f1c2a9e-4b7d-4e2a-9c51-3d8e0b7a1f24/messages?order=asc&limit=30',
            {
              headers: {
                Authorization: `Bearer ${process.env.WORKLAYER_API_KEY}`,
              },
            });

            const data = await response.json();

            console.log(data);
components:
  parameters:
    RoomId:
      name: roomId
      in: path
      required: true
      description: >-
        Room ID. Pass `web` to target your factory's main Room (the conversation
        in the Worklayer web app).
      schema:
        type: string
        minLength: 1
        maxLength: 191
      example: cmhx3q7v20004l808sd5k2r1m
    WorkerId:
      name: workerId
      in: path
      required: true
      description: The Worker id.
      schema:
        type: string
      example: 6f1c2a9e-4b7d-4e2a-9c51-3d8e0b7a1f24
    Limit100:
      name: limit
      in: query
      description: The maximum number of items on the page.
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 30
    Cursor4096:
      name: cursor
      in: query
      description: The `nextCursor` of the previous page.
      schema:
        type: string
        minLength: 1
        maxLength: 4096
        pattern: ^[A-Za-z0-9_-]+$
  schemas:
    WorkerMessagePage:
      type: object
      required:
        - messages
        - nextCursor
      properties:
        messages:
          type: array
          items:
            $ref: '#/components/schemas/UIMessage'
        nextCursor:
          type:
            - string
            - 'null'
          description: >-
            Send this value as `cursor`, with the same `order`, to get the next
            page. Null on the last page.
    Error:
      type: object
      description: The error body. Most errors have this shape.
      required:
        - statusCode
        - message
      properties:
        statusCode:
          type: integer
          description: The HTTP status code.
        message:
          type: string
          description: A short description of the error.
        error:
          type: string
          description: The name of the HTTP status.
    UIMessage:
      type: object
      description: A message in the AI SDK `UIMessage` format.
      required:
        - id
        - role
        - parts
      properties:
        id:
          type: string
        role:
          type: string
          enum:
            - user
            - assistant
        parts:
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/TextPart'
              - $ref: '#/components/schemas/ReasoningPart'
              - $ref: '#/components/schemas/FilePart'
              - $ref: '#/components/schemas/SourceUrlPart'
              - $ref: '#/components/schemas/SourceDocumentPart'
              - $ref: '#/components/schemas/ToolPart'
    TextPart:
      title: text
      type: object
      required:
        - type
        - text
      properties:
        type:
          const: text
        text:
          type: string
    ReasoningPart:
      title: reasoning
      type: object
      required:
        - type
        - text
      properties:
        type:
          const: reasoning
        text:
          type: string
    FilePart:
      title: file
      type: object
      required:
        - type
        - mediaType
        - url
      properties:
        type:
          const: file
        mediaType:
          type: string
        url:
          type: string
        filename:
          type: string
    SourceUrlPart:
      title: source-url
      type: object
      required:
        - type
        - sourceId
        - url
      properties:
        type:
          const: source-url
        sourceId:
          type: string
        url:
          type: string
        title:
          type: string
    SourceDocumentPart:
      title: source-document
      type: object
      required:
        - type
        - sourceId
        - mediaType
        - title
      properties:
        type:
          const: source-document
        sourceId:
          type: string
        mediaType:
          type: string
        title:
          type: string
        filename:
          type: string
    ToolPart:
      title: dynamic-tool
      type: object
      description: >-
        A tool call made by the Worker. Tool inputs are omitted, so `input` is
        always `null`.
      required:
        - type
        - toolCallId
        - toolName
        - input
        - state
      properties:
        type:
          const: dynamic-tool
        toolCallId:
          type: string
        toolName:
          type: string
        input:
          type: 'null'
        state:
          type: string
          enum:
            - input-streaming
            - input-available
            - output-available
            - output-error
        output:
          description: >-
            Only when `state` is `output-available`. Null, except when the
            Worker showed files to a person. Then it is `{ files: [...] }`.
        errorText:
          type: string
          description: Only when `state` is `output-error`. Always `Tool failed.`
  responses:
    Unauthorized:
      description: >-
        The API key is missing, not valid or revoked. The response has the
        header `WWW-Authenticate: Bearer`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            statusCode: 401
            message: Unauthorized
    WorkerNotFound:
      description: The Room or the Worker is not found, or the Worker is not in this Room.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            statusCode: 404
            message: Worker not found.
            error: Not Found
    TooManyRequests:
      description: Too many requests in a short time. Wait, then send the request again.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            statusCode: 429
            message: 'ThrottlerException: Too Many Requests'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: wrk-…
      description: >-
        Your factory's Worklayer API key (`wrk-...`). See [Get an API
        key](/quickstart#get-an-api-key) and [Authentication](/authentication).
        Requests sent from the playground execute live against your factory.

````

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