> ## 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 Factory History

> Returns the history entries of all Rooms of the factory as one log, newest first: user messages, Events, factory replies and Worker starts, each with its Room. `nextCursor` paginates to older entries. The API key must belong to the factory. See [Factory History](/rooms#factory-history).



## OpenAPI

````yaml /openapi.json get /v1/agents/{agentId}/history
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/agents/{agentId}/history:
    parameters:
      - $ref: '#/components/parameters/AgentId'
    get:
      tags:
        - Rooms
      summary: Get Factory History
      description: >-
        Returns the history entries of all Rooms of the factory as one log,
        newest first: user messages, Events, factory replies and Worker starts,
        each with its Room. `nextCursor` paginates to older entries. The API key
        must belong to the factory. See [Factory
        History](/rooms#factory-history).
      operationId: getAgentHistory
      parameters:
        - $ref: '#/components/parameters/Limit100'
        - $ref: '#/components/parameters/Cursor4096'
      responses:
        '200':
          description: A page of history entries of all Rooms.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentHistoryPage'
              example:
                entries:
                  - id: toolu_01HbW7q2Lk9sVd3XnR8cPz4m
                    kind: response
                    text: I refunded the duplicate charge for order 1188.
                    createdAt: '2026-11-19T17:52:08.311Z'
                    roomId: cmhx3q7v20004l808sd5k2r1m
                    roomName: Support ticket 4821
                    roomSource: api
                    roomKind: api
                  - id: cmhx3r0a10007l808m2c4t9xw
                    kind: event
                    text: Deploy failed on main.
                    createdAt: '2026-11-19T17:41:02.118Z'
                    eventId: b7e4c1d2-8a3f-4f6e-9d20-5c1a7e9b3f08
                    roomId: cmhw0b1k90001l808a1x7v3qf
                    roomName: '#ops'
                    roomSource: slack
                    roomKind: channel
                nextCursor: cmhx3q9f80005l8086b1n0d4k
        '400':
          description: A query parameter or the cursor is not valid.
          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':
          description: The API key does not belong to this factory.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                statusCode: 404
                message: Agent not found.
                error: Not Found
        '429':
          $ref: '#/components/responses/TooManyRequests'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl
            "https://api.myworklayer.com/v1/agents/support-V7EHih/history?limit=30"
            \
              -H "Authorization: Bearer $WORKLAYER_API_KEY"
        - lang: javascript
          label: fetch
          source: >-
            const response = await
            fetch('https://api.myworklayer.com/v1/agents/support-V7EHih/history?limit=30',
            {
              headers: {
                Authorization: `Bearer ${process.env.WORKLAYER_API_KEY}`,
              },
            });

            const data = await response.json();

            console.log(data);
components:
  parameters:
    AgentId:
      name: agentId
      in: path
      required: true
      description: >-
        The factory of the API key: its id, or its slug from the web app
        address, such as `support-V7EHih` in `/agents/support-V7EHih`.
      schema:
        type: string
        minLength: 1
        maxLength: 191
    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:
    AgentHistoryPage:
      type: object
      required:
        - entries
        - nextCursor
      properties:
        entries:
          type: array
          items:
            $ref: '#/components/schemas/AgentHistoryEntry'
          description: Newest first.
        nextCursor:
          type:
            - string
            - 'null'
          description: >-
            Send this value as `cursor` to get older entries. Null when there
            are no older entries.
    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.
    AgentHistoryEntry:
      allOf:
        - $ref: '#/components/schemas/RoomHistoryEntry'
        - type: object
          required:
            - roomId
            - roomName
            - roomSource
            - roomKind
          properties:
            roomId:
              type: string
              description: The id of the Room of the entry.
            roomName:
              type:
                - string
                - 'null'
              description: The display name of the Room, or null.
            roomSource:
              type: string
              enum:
                - web
                - api
                - slack
              description: The `source` of the Room.
            roomKind:
              type: string
              enum:
                - web_chat
                - api
                - channel
                - direct
                - group_direct
              description: The `kind` of the Room.
    RoomHistoryEntry:
      type: object
      required:
        - id
        - kind
        - createdAt
      properties:
        id:
          type: string
        kind:
          type: string
          enum:
            - user
            - event
            - response
            - worker_started
          description: >-
            `user`: a message from a person. `event`: an Event that the factory
            received. `response`: a response from the factory. `worker_started`:
            the factory started a Worker.
        text:
          type: string
          description: >-
            The text of a `user`, `event` or `response` entry. A
            `worker_started` entry has no text: show its `title`.
        createdAt:
          type: string
          format: date-time
        eventId:
          type: string
          description: 'Only when `kind` is `event`: the id of the Event.'
        event:
          type: object
          description: 'Only when `kind` is `event`: the public facts of the Event.'
          required:
            - source
            - kind
            - type
            - occurredAt
            - attributes
          properties:
            source:
              type: string
              description: The source of the Event, such as `API`, `SLACK` or `GMAIL`.
            kind:
              type: string
              enum:
                - CHANNEL
                - SIGNAL
            type:
              type: string
            occurredAt:
              type: string
              format: date-time
            attributes:
              $ref: '#/components/schemas/JsonObject'
        workerId:
          type: string
          description: 'Only when `kind` is `worker_started`: the id of the Worker.'
        title:
          type: string
          description: 'Only when `kind` is `worker_started`: the title of the Worker.'
        requestedByName:
          type:
            - string
            - 'null'
          description: >-
            Only when `kind` is `worker_started`: the person who asked for the
            Worker, or null.
        sourceMessageIds:
          type: array
          items:
            type: string
          description: >-
            Only when `kind` is `worker_started`: the ids of the entries that
            started the Worker.
    JsonObject:
      type: object
      additionalProperties: true
      description: >-
        A JSON object up to 32 KiB serialized, at most 8 levels deep, with up to
        128 keys per object. The keys `__proto__`, `prototype`, and
        `constructor` are disallowed.
  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
    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.