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

# Register a webhook subscription

> Creates a webhook subscription and an optional list of event types to subscribe to (defaults to all when omitted). `kind: "http"` (the default) delivers signed JSON to a URL; the response includes the generated signing secret, which is returned only once at creation time and cannot be retrieved later. `kind: "integration"` posts each event as a message into a connected integration target (e.g. a Slack channel): pick the `capability` from `GET /webhooks/integrations` and the `args` from `GET /webhooks/integrations/{capabilityId}/targets`. Integration webhooks have no signing secret. Send an `Idempotency-Key` header to make the create safe to retry: the same key with the same body returns the existing webhook (status 201, `Idempotent-Replayed: true`) instead of creating a second one, and the same key with a different body is a 422. A replayed create does not return the signing secret again; use rotate-secret if the original response was lost. If that webhook was deleted in the meantime, the retry is a 404.



## OpenAPI

````yaml /api-reference/webhooks.yaml post /webhooks
openapi: 3.1.0
info:
  title: Webhooks
  version: v1
servers:
  - description: Droidrun Cloud API
    url: https://api.mobilerun.ai/v1
security:
  - bearerAuth: []
paths:
  /webhooks:
    post:
      tags:
        - Webhooks
      summary: Register a webhook subscription
      description: >-
        Creates a webhook subscription and an optional list of event types to
        subscribe to (defaults to all when omitted). `kind: "http"` (the
        default) delivers signed JSON to a URL; the response includes the
        generated signing secret, which is returned only once at creation time
        and cannot be retrieved later. `kind: "integration"` posts each event as
        a message into a connected integration target (e.g. a Slack channel):
        pick the `capability` from `GET /webhooks/integrations` and the `args`
        from `GET /webhooks/integrations/{capabilityId}/targets`. Integration
        webhooks have no signing secret. Send an `Idempotency-Key` header to
        make the create safe to retry: the same key with the same body returns
        the existing webhook (status 201, `Idempotent-Replayed: true`) instead
        of creating a second one, and the same key with a different body is a
        422. A replayed create does not return the signing secret again; use
        rotate-secret if the original response was lost. If that webhook was
        deleted in the meantime, the retry is a 404.
      operationId: createWebhook
      parameters:
        - description: >-
            Idempotency-Key: 1-255 printable ASCII characters. Same key with a
            different request body is a 422 idempotency_key_reused. A retryable
            in-flight duplicate is a 409 with Retry-After and x-should-retry:
            true; a terminal duplicate is a 409 with x-should-retry: false. A
            replay returns the current resource state with Idempotent-Replayed:
            true.
          in: header
          name: idempotency-key
          required: false
          schema:
            description: >-
              Idempotency-Key: 1-255 printable ASCII characters. Same key with a
              different request body is a 422 idempotency_key_reused. A
              retryable in-flight duplicate is a 409 with Retry-After and
              x-should-retry: true; a terminal duplicate is a 409 with
              x-should-retry: false. A replay returns the current resource state
              with Idempotent-Replayed: true.
            example: b3f6a9f0-6f1a-4e9a-9e7a-9c9b6b6a5a3f
            maxLength: 255
            minLength: 1
            pattern: ^[\x21-\x7E]{1,255}$
            type: string
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - properties:
                    description:
                      maxLength: 500
                      type: string
                    eventTypes:
                      example:
                        - task.run.completed
                        - task.run.failed
                      items:
                        maxLength: 256
                        minLength: 1
                        type: string
                      maxItems: 100
                      type: array
                    kind:
                      description: Delivery transport. Omitted ⇒ `http`.
                      enum:
                        - http
                      type: string
                    url:
                      example: https://example.com/webhooks/droidrun
                      format: uri
                      maxLength: 2048
                      type: string
                  required:
                    - url
                  type: object
                - properties:
                    args:
                      additionalProperties: {}
                      description: >-
                        Target args exactly as returned by `GET
                        /webhooks/integrations/{capabilityId}/targets`.
                      example:
                        channelId: C07ABCDEF
                      type: object
                    capability:
                      additionalProperties: false
                      properties:
                        id:
                          example: slack.post_message
                          maxLength: 128
                          minLength: 1
                          type: string
                        revision:
                          example: 1
                          minimum: 1
                          type: integer
                      required:
                        - id
                        - revision
                      type: object
                    description:
                      maxLength: 500
                      type: string
                    eventTypes:
                      example:
                        - task.run.completed
                        - task.run.failed
                      items:
                        maxLength: 256
                        minLength: 1
                        type: string
                      maxItems: 100
                      type: array
                    kind:
                      enum:
                        - integration
                      type: string
                  required:
                    - kind
                    - capability
                    - args
                  type: object
      responses:
        '201':
          content:
            application/json:
              schema:
                properties:
                  data:
                    properties:
                      blockedAt:
                        type:
                          - string
                          - 'null'
                      blockedReason:
                        description: >-
                          Why the webhook was blocked, e.g.
                          `integration_disconnected` (reconnect the integration)
                          or `integration_target_invalid` (the channel is gone
                          or not allowed).
                        type:
                          - string
                          - 'null'
                      createdAt:
                        type: string
                      createdBy:
                        description: >-
                          Id of the actor who created this endpoint. Null when
                          no creator was recorded.
                        format: uuid
                        type:
                          - string
                          - 'null'
                      description:
                        type:
                          - string
                          - 'null'
                      eventTypes:
                        items:
                          type: string
                        type: array
                      health:
                        description: >-
                          System-observed delivery health. `blocked` endpoints
                          are auto-disabled after sustained failure; PATCH
                          state=ACTIVE to re-enable.
                        enum:
                          - healthy
                          - failing
                          - blocked
                        type: string
                      id:
                        format: uuid
                        type: string
                      integration:
                        description: Integration target; null for `http` webhooks.
                        properties:
                          args:
                            additionalProperties: {}
                            type: object
                          capability:
                            additionalProperties: false
                            properties:
                              id:
                                example: slack.post_message
                                maxLength: 128
                                minLength: 1
                                type: string
                              revision:
                                example: 1
                                minimum: 1
                                type: integer
                            required:
                              - id
                              - revision
                            type: object
                          label:
                            description: Target name at creation time, e.g. `#ops`.
                            type: string
                        required:
                          - capability
                          - args
                          - label
                        type:
                          - object
                          - 'null'
                      kind:
                        description: >-
                          `http` posts signed JSON to `url`; `integration` posts
                          a message through a connected integration (e.g. a
                          Slack channel).
                        enum:
                          - http
                          - integration
                        type: string
                      secret:
                        description: >-
                          Signing secret for `http` webhooks — shown only once.
                          Store it now. Absent for `integration` webhooks.
                        type: string
                      signingEnabled:
                        description: Always false for `integration` webhooks.
                        type: boolean
                      state:
                        enum:
                          - ACTIVE
                          - DISABLED
                          - DELETED
                        type: string
                      updatedAt:
                        type: string
                      url:
                        description: Delivery URL; null for `integration` webhooks.
                        type:
                          - string
                          - 'null'
                    required:
                      - id
                      - kind
                      - url
                      - integration
                      - eventTypes
                      - state
                      - health
                      - blockedAt
                      - blockedReason
                      - signingEnabled
                      - description
                      - createdBy
                      - createdAt
                      - updatedAt
                    type: object
                required:
                  - data
                type: object
          description: >-
            Webhook created (secret shown once for http webhooks). A replayed
            create (same `Idempotency-Key`, same body) returns the current
            webhook without `secret` and with `Idempotent-Replayed: true`.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
          description: Unauthorized
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookHttpError'
          description: >-
            Integration or integration target not found, or the webhook created
            under this `Idempotency-Key` was deleted
        '409':
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/WebhookHttpError'
                  - properties:
                      code:
                        enum:
                          - idempotency_request_in_progress
                        type: string
                      message:
                        type: string
                      retryAfterSeconds:
                        type: number
                      traceId:
                        type: string
                    required:
                      - code
                      - message
                    type: object
          description: >-
            A webhook for this URL or integration target already exists, the
            integration is not connected, or a request with this
            `Idempotency-Key` is still in progress
            (`idempotency_request_in_progress`: retry after `Retry-After`)
          headers:
            Retry-After:
              description: >-
                Seconds to wait before retrying; set on
                `idempotency_request_in_progress` (always `1`).
              required: false
              schema:
                description: >-
                  Seconds to wait before retrying; set on
                  `idempotency_request_in_progress` (always `1`).
                example: '1'
                type: string
            x-should-retry:
              description: >-
                `true` on `idempotency_request_in_progress`: the same request
                may be retried.
              required: false
              schema:
                description: >-
                  `true` on `idempotency_request_in_progress`: the same request
                  may be retried.
                example: 'true'
                type: string
        '422':
          content:
            application/json:
              schema:
                properties:
                  code:
                    enum:
                      - idempotency_key_reused
                    type: string
                  message:
                    type: string
                  retryAfterSeconds:
                    type: number
                  traceId:
                    type: string
                required:
                  - code
                  - message
                type: object
          description: The `Idempotency-Key` was already used with a different request body
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookInternalServerError'
          description: Internal Server Error
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookHttpError'
          description: Integrations are not available right now
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Mobilerun from '@mobilerun/sdk';


            const client = new Mobilerun({
              apiKey: process.env['MOBILERUN_CLOUD_API_KEY'], // This is the default and can be omitted
            });


            const webhook = await client.webhooks.create({ url:
            'https://example.com/webhooks/droidrun' });


            console.log(webhook.data);
        - lang: Python
          source: |-
            import os
            from mobilerun_sdk import Mobilerun

            client = Mobilerun(
                api_key=os.environ.get("MOBILERUN_CLOUD_API_KEY"),  # This is the default and can be omitted
            )
            webhook = client.webhooks.create(
                url="https://example.com/webhooks/droidrun",
            )
            print(webhook.data)
components:
  schemas:
    ApiErrorEnvelope:
      properties:
        code:
          type: string
        details: {}
        message:
          type: string
        retryAfterSeconds:
          type: number
        traceId:
          type: string
      required:
        - code
        - message
      type: object
    WebhookHttpError:
      properties:
        code:
          $ref: '#/components/schemas/WebhookHttpErrorCode'
        details: {}
        message:
          example: webhook not found
          type: string
        traceId:
          type: string
      required:
        - code
        - message
      type: object
    WebhookInternalServerError:
      properties:
        code:
          $ref: '#/components/schemas/WebhookHttpErrorCode'
        details: {}
        message:
          type: string
        traceId:
          type: string
      required:
        - code
        - message
      type: object
    WebhookHttpErrorCode:
      enum:
        - bad_request
        - not_found
        - conflict
        - service_unavailable
        - internal_error
      type: string
  securitySchemes:
    bearerAuth:
      bearerFormat: Opaque
      description: Bearer token via Authorization header
      scheme: bearer
      type: http

````

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