> ## 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 an Event

> Submits an Event to a Room. This endpoint is the programmatic Event source; Channels (Slack), Signals (Gmail), and scheduled runs are configured in the web app. Returns `202 Accepted` once persisted—factory replies arrive asynchronously via Room History and Subscriptions. Set `delivery` to `queue` (default), `steer`, or `context`. `context` Events do not wake the factory or emit webhooks. Include an `Idempotency-Key` header for safe retries. See [Events](/events).



## OpenAPI

````yaml /openapi.json post /v1/rooms/{roomId}/events
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}/events:
    parameters:
      - $ref: '#/components/parameters/RoomId'
    post:
      tags:
        - Events
      summary: Send an Event
      description: >-
        Submits an Event to a Room. This endpoint is the programmatic Event
        source; Channels (Slack), Signals (Gmail), and scheduled runs are
        configured in the web app. Returns `202 Accepted` once persisted—factory
        replies arrive asynchronously via Room History and Subscriptions. Set
        `delivery` to `queue` (default), `steer`, or `context`. `context` Events
        do not wake the factory or emit webhooks. Include an `Idempotency-Key`
        header for safe retries. See [Events](/events).
      operationId: submitEvent
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          description: >-
            Your unique key for this Event. 1 to 191 visible ASCII characters.
            If you send the same key with the same body to the same Room again,
            you get the same `eventId`. A body without `delivery` is the same as
            a body with `delivery` set to `queue`. Send one header only.
          schema:
            type: string
            pattern: ^[!-~]{1,191}$
          example: order-1188-shipped
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventSubmission'
            example:
              type: order.shipped
              content: Order 1188 for ticket 4821 is shipped with UPS.
              attributes:
                orderId: '1188'
                carrier: UPS
                trackingNumber: 1Z999AA10123456784
              delivery: queue
              modelContext:
                customerTier: gold
      responses:
        '202':
          description: The Event is accepted. The factory reads it later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventAccepted'
              example:
                eventId: b7e4c1d2-8a3f-4f6e-9d20-5c1a7e9b3f08
                delivery: queue
        '400':
          description: >-
            The body or the `Idempotency-Key` header is not valid. An unknown
            `delivery` value returns `Invalid Event body`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                statusCode: 400
                message: Invalid Event body
                error: Bad Request
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/RoomNotFound'
        '409':
          description: >-
            The `Idempotency-Key` is in use. `Idempotency key has a different
            Event body`: the body is different, also a different `delivery`.
            `Idempotency key is already in use`: the key was used in a different
            Room.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                statusCode: 409
                message: Idempotency key has a different Event body
                error: Conflict
        '413':
          description: The body is larger than 1 MiB.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                statusCode: 413
                message: Payload Too Large
                error: Payload Too Large
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '503':
          description: >-
            The service is not available now. Send the request again with the
            same `Idempotency-Key`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                statusCode: 503
                message: Event storage unavailable
                error: Service Unavailable
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.myworklayer.com/v1/rooms/cmhx3q7v20004l808sd5k2r1m/events"
            \
              -H "Authorization: Bearer $WORKLAYER_API_KEY" \
              -H "Content-Type: application/json" \
              -H "Idempotency-Key: order-1188-shipped" \
              -d '{
                "type": "order.shipped",
                "content": "Order 1188 for ticket 4821 is shipped with UPS.",
                "attributes": {
                  "orderId": "1188",
                  "carrier": "UPS",
                  "trackingNumber": "1Z999AA10123456784"
                },
                "delivery": "queue"
              }'
        - lang: javascript
          label: fetch
          source: >-
            const response = await
            fetch('https://api.myworklayer.com/v1/rooms/cmhx3q7v20004l808sd5k2r1m/events',
            {
              method: 'POST',
              headers: {
                Authorization: `Bearer ${process.env.WORKLAYER_API_KEY}`,
                'Content-Type': 'application/json',
                'Idempotency-Key': 'order-1188-shipped',
              },
              body: JSON.stringify({
                "type": "order.shipped",
                "content": "Order 1188 for ticket 4821 is shipped with UPS.",
                "attributes": {
                  "orderId": "1188",
                  "carrier": "UPS",
                  "trackingNumber": "1Z999AA10123456784"
                },
                "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
  schemas:
    EventSubmission:
      type: object
      additionalProperties: false
      required:
        - type
        - content
      properties:
        type:
          type: string
          minLength: 1
          maxLength: 120
          description: >-
            Your name for the kind of Event, for example `order.shipped`. It
            must not be blank.
        content:
          type: string
          description: The text of the Event. It must not be blank.
        attributes:
          allOf:
            - $ref: '#/components/schemas/JsonObject'
          description: >-
            Structured metadata stored with the Event (for example, internal
            IDs). The key `type` is disallowed. Defaults to `{}`.
        modelContext:
          allOf:
            - $ref: '#/components/schemas/JsonObject'
          description: >-
            Facts that the factory gets together with `content`. Put here what
            the factory must know to act. Default: {}.
        delivery:
          allOf:
            - $ref: '#/components/schemas/EventDelivery'
          default: queue
          description: 'When the factory reads the Event. Default: `queue`.'
    EventAccepted:
      type: object
      required:
        - eventId
        - delivery
      properties:
        eventId:
          type: string
          description: The id of the Event.
        delivery:
          allOf:
            - $ref: '#/components/schemas/EventDelivery'
          description: >-
            The `delivery` that the API uses for the Event. It is `queue` when
            you did not send 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.
    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.
    EventDelivery:
      type: string
      enum:
        - context
        - queue
        - steer
      description: >-
        Controls when the factory processes the Event. `queue` (default): after
        its current work, or immediately if idle. `steer`: mid-flight before the
        next step, or immediately if idle. `context`: stored silently without
        waking the factory and delivered on the next `queue` or `steer` Event.
        See [Events](/events#choose-when-the-factory-reads-an-event).
  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
    RoomNotFound:
      description: The Room is not found for this API key, or it is archived.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            statusCode: 404
            message: Room 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.