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

# Send a message to a Worker

> Sends a queued or mid-flight steering message to a Worker. The Worker executes with the factory owner's permissions.



## OpenAPI

````yaml /openapi.json post /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'
    post:
      tags:
        - Workers
      summary: Send a message to a Worker
      description: >-
        Sends a queued or mid-flight steering message to a Worker. The Worker
        executes with the factory owner's permissions.
      operationId: sendWorkerMessage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SendWorkerMessage'
            example:
              text: Also add a note that the parcel needs a signature.
              delivery: queue
      responses:
        '201':
          description: >-
            The message is saved. Read `status` to know if the Worker started
            work on it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SendWorkerMessageResult'
              example:
                messageId: 3c9d1e7a-52b4-4f0e-8a6d-0e2b7f4c9a15
        '400':
          description: >-
            The body is not valid, for example blank text or a `delivery` that
            is not `queue` or `steer`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                statusCode: 400
                message: >-
                  Supply nonblank text within the composer limit and a valid
                  delivery.
                error: Bad Request
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          description: >-
            The Worker could not start work on the message, and a retry does not
            help. The message is not saved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                statusCode: 402
                message: Worker turn could not start.
        '403':
          description: The factory owner does not have access to this Worker.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                statusCode: 403
                message: Environment owner cannot access this Worker.
                error: Forbidden
        '404':
          $ref: '#/components/responses/WorkerNotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '503':
          description: >-
            The Worker could not start work on the message. Try again later. The
            message is not saved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                statusCode: 503
                message: Worker turn could not start.
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.myworklayer.com/v1/rooms/cmhx3q7v20004l808sd5k2r1m/workers/6f1c2a9e-4b7d-4e2a-9c51-3d8e0b7a1f24/messages"
            \
              -H "Authorization: Bearer $WORKLAYER_API_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                "text": "Also add a note that the parcel needs a signature.",
                "delivery": "queue"
              }'
        - lang: javascript
          label: fetch
          source: >-
            const response = await
            fetch('https://api.myworklayer.com/v1/rooms/cmhx3q7v20004l808sd5k2r1m/workers/6f1c2a9e-4b7d-4e2a-9c51-3d8e0b7a1f24/messages',
            {
              method: 'POST',
              headers: {
                Authorization: `Bearer ${process.env.WORKLAYER_API_KEY}`,
                'Content-Type': 'application/json',
              },
              body: JSON.stringify({
                "text": "Also add a note that the parcel needs a signature.",
                "delivery": "queue"
              }),
            });

            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
  schemas:
    SendWorkerMessage:
      type: object
      additionalProperties: false
      required:
        - text
      properties:
        text:
          type: string
          maxLength: 16000
          description: The message. It must not be blank.
        delivery:
          type: string
          enum:
            - queue
            - steer
          default: queue
          description: >-
            `queue`: the Worker reads the message as a new request, after its
            current work. `steer`: the Worker reads the message during its
            current work, as new guidance. Workers do not accept `context`.
    SendWorkerMessageResult:
      type: object
      required:
        - messageId
      properties:
        messageId:
          type: string
          description: The id of the saved message.
        status:
          type: string
          enum:
            - execution_unconfirmed
            - not_started
          description: >-
            Omitted when the Worker started processing the message.
            `execution_unconfirmed`: the message was saved, but execution start
            could not be confirmed—don't resend; inspect the Worker's status or
            messages. `not_started`: the message was saved, but execution did
            not start.
        failure:
          type: string
          description: 'Only with `not_started`: a failure code, when there is one.'
    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.
  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.