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

# Subscribe to a workflow

> Every run of the workflow that finishes, however it was started, is POSTed to `webhook_url` with the same body, signature and retries as a `callback_url`. Test runs are not sent. Revoking the key ends deliveries.



## OpenAPI

````yaml POST /api/webhooks/subscribe
openapi: 3.1.0
info:
  title: HITL API
  version: 1.0.0
  description: >-
    Run the workflows you build in HITL, follow each run until a person has
    answered, and manage who reviews them.
servers:
  - url: https://api.hitl.sh/v1
security:
  - bearerAuth: []
tags:
  - name: Workflows
  - name: Runs
  - name: Reviewers
  - name: Webhooks
  - name: Account
  - name: Uploads
paths:
  /api/webhooks/subscribe:
    post:
      tags:
        - Webhooks
      summary: Subscribe to a workflow
      description: >-
        Every run of the workflow that finishes, however it was started, is
        POSTed to `webhook_url` with the same body, signature and retries as a
        `callback_url`. Test runs are not sent. Revoking the key ends
        deliveries.
      operationId: webhooks-subscribe
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - webhook_url
                - events
                - workflow_id
              properties:
                webhook_url:
                  type: string
                events:
                  type: array
                  items:
                    type: string
                    enum:
                      - execution.finished
                workflow_id:
                  type: string
            example:
              webhook_url: https://example.com/hitl
              events:
                - execution.finished
              workflow_id: 6af2ce4e8207961501f59472
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: boolean
                  msg:
                    type: string
                  data:
                    $ref: '#/components/schemas/Webhook'
              example:
                data:
                  active: true
                  events:
                    - execution.finished
                  webhook_id: 6af2cf21c6a9f1dc71efd5e8
                  webhook_url: https://httpbin.org/post
                  workflow_id: 6af2ce4e8207961501f59472
                error: false
                msg: Webhook subscribed successfully
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
components:
  schemas:
    Webhook:
      type: object
      properties:
        webhook_id:
          type: string
        webhook_url:
          type: string
        events:
          type: array
          items:
            type: string
            enum:
              - execution.finished
        workflow_id:
          type: string
        active:
          type: boolean
    Error:
      type: object
      required:
        - error
        - msg
      properties:
        error:
          type: boolean
          example: true
        msg:
          type: string
          description: What went wrong, in plain words
        code:
          type: string
          description: >-
            A machine-readable reason, when there is one (for example
            `confirmation_required`)
  responses:
    E400:
      description: Invalid input; `msg` says what to fix
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: true
            msg: Invalid execution id
    E401:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: true
            msg: Invalid API key
    E403:
      description: The key lacks the scope, or the signup is not confirmed yet
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: true
            code: confirmation_required
            msg: 'Confirm the signup first: ask your human for the code in the email'
    E404:
      description: Not found, or not yours
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: true
            msg: Workflow not found
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Your API key: `hitl_live_…`'

````

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