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

# Create a subscription

> Creates a webhook Subscription for the selected event topics across all Rooms of your factory. Save the returned signing `secret` immediately—it is shown only once. See [Subscriptions](/subscriptions).



## OpenAPI

````yaml /openapi.json post /v1/subscriptions
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/subscriptions:
    post:
      tags:
        - Subscriptions
      summary: Create a subscription
      description: >-
        Creates a webhook Subscription for the selected event topics across all
        Rooms of your factory. Save the returned signing `secret` immediately—it
        is shown only once. See [Subscriptions](/subscriptions).
      operationId: createSubscription
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSubscription'
            example:
              name: Support backend
              url: https://hooks.example.com/worklayer
              events:
                - room.response
                - reviews.questions.created
                - reviews.approvals.created
      responses:
        '201':
          description: The new subscription, with its signing secret.
          headers:
            Cache-Control:
              description: Always `no-store`, because the body has a secret.
              schema:
                type: string
                const: no-store
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubscriptionWithSecret'
              example:
                id: 0f8e2b7c-5a1d-4c3e-9b6f-2d7a8c1e4f90
                name: Support backend
                url: https://hooks.example.com/worklayer
                enabled: true
                createdAt: '2026-11-20T15:02:44.120Z'
                updatedAt: '2026-11-20T15:02:44.120Z'
                events:
                  - room.response
                  - reviews.questions.created
                  - reviews.approvals.created
                secret: whsec_ZXhhbXBsZS1zaWduaW5nLXNlY3JldC1mb3ItZG9jczE=
        '400':
          description: >-
            The body is not valid, for example a URL that is not a public HTTPS
            URL, or an unknown field.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                statusCode: 400
                message: Invalid webhook request
                error: Bad Request
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.myworklayer.com/v1/subscriptions" \
              -H "Authorization: Bearer $WORKLAYER_API_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                "name": "Support backend",
                "url": "https://hooks.example.com/worklayer",
                "events": [
                  "room.response",
                  "reviews.questions.created",
                  "reviews.approvals.created"
                ]
              }'
        - lang: javascript
          label: fetch
          source: >-
            const response = await
            fetch('https://api.myworklayer.com/v1/subscriptions', {
              method: 'POST',
              headers: {
                Authorization: `Bearer ${process.env.WORKLAYER_API_KEY}`,
                'Content-Type': 'application/json',
              },
              body: JSON.stringify({
                "name": "Support backend",
                "url": "https://hooks.example.com/worklayer",
                "events": [
                  "room.response",
                  "reviews.questions.created",
                  "reviews.approvals.created"
                ]
              }),
            });

            const data = await response.json();

            console.log(data);
components:
  schemas:
    CreateSubscription:
      type: object
      additionalProperties: false
      required:
        - url
        - events
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
          description: 'The display name. Default: the host name of `url`.'
        url:
          $ref: '#/components/schemas/SubscriptionUrl'
        events:
          type: array
          items:
            $ref: '#/components/schemas/SubscriptionEvent'
          minItems: 1
          maxItems: 6
          uniqueItems: true
    SubscriptionWithSecret:
      allOf:
        - $ref: '#/components/schemas/Subscription'
        - type: object
          required:
            - secret
          properties:
            secret:
              type: string
              description: >-
                The signing secret. It starts with `whsec_`. The API returns it
                only in this response.
    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.
    SubscriptionUrl:
      type: string
      format: uri
      maxLength: 2048
      description: >-
        A public `https://` URL, at most 2,048 characters. It must not have a
        user name, a password or a fragment (`#`). It must not be `localhost`, a
        `.localhost` host, or a private or reserved IP address.
    SubscriptionEvent:
      type: string
      enum:
        - room.response
        - reviews.approvals.created
        - reviews.questions.created
        - reviews.connect_apps.created
        - room.status
        - worker.status
      description: An event type that the subscription receives.
    Subscription:
      type: object
      required:
        - id
        - name
        - url
        - events
        - enabled
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          description: Subscription ID.
        name:
          type: string
          description: The display name.
        url:
          type: string
          format: uri
          description: The HTTPS URL that receives the webhooks.
        events:
          type: array
          items:
            $ref: '#/components/schemas/SubscriptionEvent'
          description: The event types that the subscription receives.
        enabled:
          type: boolean
          description: >-
            False when a person turned the subscription off in the web app. The
            API cannot change it.
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
  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.