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

# Create webhook

> Create a webhook subscription endpoint. The server generates a 32-char hex secret and returns it ONCE in this response (masked on every subsequent read). Store it client-side for HMAC verification. target_url must be https:// and public (non-RFC1918); each events[] value is validated against WebhookEventTypeEnum; the same target_url cannot be registered twice per team. State-changing.

Contract:
- MCP tool `create_webhook`, registry package `mcp.orchestration/webhooks`, mount `orchestration.webhooks`.
- Operation `create`, response envelope `create`.
- Flags: dangerous: the MCP layer gates it behind a preview/commit token, and the effect cannot be undone through this API.



## OpenAPI

````yaml /api-reference/orchestration/openapi.yaml post /api/webhooks
openapi: 3.0.3
info:
  title: 'GTM API public contract: gtm.service.orchestration'
  description: >-
    The cross-service execution plane: the platform-wide webhook registry and
    delivery log, plus mass actions (preview, commit, pace, pause, resume,
    canary) and their per-item child rows.


    GENERATED. This document is projected from the Zod MCP tool registry in
    `product/mcp/gtm.mcp` (one tool per public endpoint, 1:1). Do not edit it by
    hand; edit the tool definition and regenerate with `pnpm openapi:public`.


    Surface: the public `/api` contract of `gtm.service.orchestration`, 21
    operations. Internal (`/internal`) and health endpoints are deliberately
    absent; the code-faithful spec that documents those lives in
    `product/openapi/gtm.openapi.tech`.


    Conventions:

    - Auth is a bearer JWT, optionally narrowed by the `Team-SID` header.

    - Every success body is an MCP envelope: `success: true` plus one typed
    `operation` shape (`search`, `get`, `create`, `update`, `delete`, `metrics`,
    `group_by`, `action`), and a `meta` block with `trace_id` for support.

    - Every failure is the same `McpError` envelope with a code from a fixed
    16-code taxonomy, so a client maps errors once.

    - Lists page with `page_size` (0 to 500, default 50) plus an opaque forward
    `cursor`; `page_size: 0` returns counts only.

    - On `GET` and `DELETE`, object-valued query parameters (`filter`, `sort`)
    travel as JSON text and array-valued ones repeat as `name[]=value`.

    - The MCP-only `_meta` field (usage analytics) never reaches the backend and
    is not part of this contract.
  version: '1.0'
  contact:
    name: GTM API
    url: https://gtm-api.com
    email: support@gtm-api.com
  license:
    name: Proprietary
    url: https://gtm-api.com/license
servers:
  - url: https://app.gtm-api.com/orchestration/v4
    description: Production, through the app.gtm-api.com gateway
  - url: http://localhost:8025
    description: Local Docker (gtm_orchestration_nginx_dev)
security:
  - BearerJwt: []
    TeamSid: []
tags:
  - name: mass_action_items
    description: >-
      Registry package `mcp.orchestration/mass_action_items`, served on MCP
      mount `orchestration.mass_actions`.
  - name: mass_actions
    description: >-
      Registry package `mcp.orchestration/mass_actions`, served on MCP mount
      `orchestration.mass_actions`.
  - name: webhook_logs
    description: >-
      Registry package `mcp.orchestration/webhook_logs`, served on MCP mount
      `orchestration.webhooks`.
  - name: webhooks
    description: >-
      Registry package `mcp.orchestration/webhooks`, served on MCP mount
      `orchestration.webhooks`.
paths:
  /api/webhooks:
    post:
      tags:
        - webhooks
      summary: Create webhook
      description: >-
        Create a webhook subscription endpoint. The server generates a 32-char
        hex secret and returns it ONCE in this response (masked on every
        subsequent read). Store it client-side for HMAC verification. target_url
        must be https:// and public (non-RFC1918); each events[] value is
        validated against WebhookEventTypeEnum; the same target_url cannot be
        registered twice per team. State-changing.


        Contract:

        - MCP tool `create_webhook`, registry package
        `mcp.orchestration/webhooks`, mount `orchestration.webhooks`.

        - Operation `create`, response envelope `create`.

        - Flags: dangerous: the MCP layer gates it behind a preview/commit
        token, and the effect cannot be undone through this API.
      operationId: create_webhook
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWebhookRequest'
      responses:
        '200':
          description: '`create` success envelope.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateWebhookResponse'
        4XX:
          $ref: '#/components/responses/McpClientError'
        5XX:
          $ref: '#/components/responses/McpServerError'
components:
  schemas:
    CreateWebhookRequest:
      type: object
      description: Request body of `create_webhook`.
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
        target_url:
          type: string
          maxLength: 2048
          description: https:// only, public IP only.
        events:
          type: array
          items:
            type: string
            enum:
              - linkedin-accounts.created
              - linkedin-accounts.restored
              - linkedin-accounts.deleted
              - linkedin-accounts.initial-sync-started
              - linkedin-accounts.initial-sync-done
              - linkedin-accounts.sync-reset
              - linkedin-accounts.premium-changed
              - linkedin-accounts.login-succeeded
              - linkedin-accounts.login-failed
              - linkedin-accounts.logged-out
              - linkedin-accounts.heartbeat-stale
              - linkedin-account-block-log.recorded
              - linkedin-account-snapshot.captured
              - linkedin-account-quota-hits.recorded
              - linkedin-account-smart-limits.limit-reached
              - linkedin-account-smart-limits.limit-released
              - linkedin-account-smart-limits.smart-limit-recomputed
              - linkedin-connection-requests.sent
              - linkedin-connection-requests.accepted
              - linkedin-connection-requests.withdrawn
              - linkedin-connection-requests.expired-detected
              - linkedin-connection-requests.resend-available
              - linkedin-connection-requests.sync-completed
              - linkedin-connection-invitations.received
              - linkedin-connection-invitations.accepted
              - linkedin-connection-invitations.ignored
              - linkedin-connection-invitations.expired-detected
              - linkedin-connection-invitations.sync-completed
              - linkedin-connections.added
              - linkedin-connections.removed
              - linkedin-connections.sync-completed
              - linkedin-followers.added
              - linkedin-messages.received
              - linkedin-messages.sent
              - linkedin-messages.send-failed
              - linkedin-conversations.created
              - linkedin-conversations.sync-completed
              - data-requests.completed
              - data-requests.failed
              - linkedin-auto-scrape-runs.completed
              - linkedin-auto-scrape-runs.failed
              - linkedin-auto-scrapes.paused
              - antidetect-browsers.logged-in
              - antidetect-browsers.logged-out
              - antidetect-browsers.started
              - antidetect-browsers.stopped
              - antidetect-browsers.start-failed
              - antidetect-browsers.running-issue
              - antidetect-browsers.error-investigation
              - antidetect-browsers.maintenance
              - antidetect-browsers.proxy-issue
              - antidetect-browsers.proxy-back-alive
              - antidetect-browsers.idle
              - account-shares.created
              - account-shares.returned
              - account-shares.recalled
              - account-shares.failed
              - account-transfers.completed
              - account-transfers.failed
              - webhooks.failed
              - email-accounts.connected
              - email-accounts.reconnect-required
              - email-accounts.sending-paused
              - email-accounts.sending-resumed
              - email-accounts.disconnected
              - email-accounts.deleted
              - email-accounts.sync-completed
              - email-messages.received
              - email-messages.sent
              - email-messages.bounced
              - email-messages.complained
              - email-messages.failed
              - email-messages.deleted
              - email-threads.updated
              - email-engagements.opened
              - email-engagements.clicked
              - email-engagements.unsubscribed
              - email-account-health.snapshot-captured
              - email-account-health.score-critical
              - email-suppressions.created
              - email-suppressions.deleted
              - email-tracking-domains.verified
              - email-tracking-domains.failed
              - email-sending-domains.verified
              - email-sending-domains.failed
              - mass-actions.created
              - mass-actions.paused
              - mass-actions.resumed
              - mass-actions.settled
          minItems: 1
          description: At least one WebhookEventTypeEnum value.
        filters:
          type: object
          properties:
            account_sid:
              type: string
              minLength: 18
              maxLength: 18
              description: >-
                char(18) account sid (ln_ac_… / em_ac_…): only deliver events
                for this account.
          description: Optional narrowing (e.g. status, events).
      required:
        - name
        - target_url
        - events
    CreateWebhookResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - create
        item:
          type: object
          properties:
            sid:
              type: string
            team_sid:
              type: string
            name:
              type: string
            target_url:
              type: string
            events:
              type: array
              items:
                type: string
            filters:
              type: object
              additionalProperties: {}
            secret:
              type: string
              nullable: true
            status:
              type: string
              enum:
                - 'on'
                - 'off'
                - failed
            consecutive_failed_attempts:
              type: number
            last_failure_at:
              type: string
              nullable: true
            created_by:
              type: object
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                permissions:
                  type: object
                  additionalProperties: {}
                request_sid:
                  type: string
                  nullable: true
                reason:
                  type: string
                  nullable: true
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
            deleted_by:
              type: object
              nullable: true
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                permissions:
                  type: object
                  additionalProperties: {}
                request_sid:
                  type: string
                  nullable: true
                reason:
                  type: string
                  nullable: true
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
            created_at:
              type: string
            updated_at:
              type: string
            deleted_at:
              type: string
              nullable: true
          required:
            - sid
            - team_sid
            - name
            - target_url
            - events
            - filters
            - status
            - consecutive_failed_attempts
            - last_failure_at
            - created_by
            - deleted_by
            - created_at
            - updated_at
            - deleted_at
        already_exists:
          type: boolean
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            debug_url:
              type: string
              description: Deep link to the post-call analysis UI.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
            - debug_url
      required:
        - success
        - operation
        - item
        - already_exists
        - meta
    McpError:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - validation_failed
                - nothing_to_update
                - not_found
                - relation_not_found
                - invalid_transition
                - limit_exceeded
                - payment_required
                - duplicate_rejected
                - conflict
                - delete_blocked
                - unauthorized
                - forbidden
                - rate_limited
                - internal_error
                - service_unavailable
                - not_implemented
            message:
              type: string
            recoverable:
              type: boolean
            suggestion:
              type: string
            field_errors:
              type: object
              additionalProperties:
                type: array
                items:
                  anyOf:
                    - type: string
                    - type: object
                      properties:
                        rule:
                          type: string
                        message:
                          type: string
                      required:
                        - rule
                        - message
            blockers:
              type: array
              items:
                type: object
                properties:
                  type:
                    type: string
                    description: >-
                      Machine-readable blocker type (active_flow, pending_tasks,
                      …).
                  severity:
                    type: string
                    enum:
                      - hard
                      - soft
                    description: >-
                      hard = external action required; soft = acknowledge is
                      enough.
                  description:
                    type: string
                  entity_sid:
                    type: string
                    nullable: true
                  count:
                    type: integer
                  resolution:
                    type: string
                    description: 'Hard: tool name to call. Soft: code for acknowledge[].'
                  resolution_hint:
                    type: string
                required:
                  - type
                  - severity
                  - description
                  - entity_sid
                  - resolution
                  - resolution_hint
            context:
              type: object
              additionalProperties: {}
          required:
            - code
            - message
            - recoverable
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            debug_url:
              type: string
              description: Deep link to the post-call analysis UI.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
            - debug_url
      required:
        - success
        - error
  responses:
    McpClientError:
      description: >-
        MCP error envelope. `error.code` is one of validation_failed,
        nothing_to_update, not_found, relation_not_found, invalid_transition,
        limit_exceeded, payment_required, duplicate_rejected, conflict,
        delete_blocked, unauthorized, forbidden, rate_limited, not_implemented.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/McpError'
    McpServerError:
      description: >-
        MCP error envelope with `error.code` internal_error or
        service_unavailable.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/McpError'
  securitySchemes:
    BearerJwt:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Access token issued by gtm.service.id. Its `access_identity` claim
        carries `team_sid`, `actor_sid` and `actor_type`, and that team scope is
        authoritative.
    TeamSid:
      type: apiKey
      in: header
      name: Team-SID
      description: >-
        Team scope for tokens that do not carry one. Ignored when the token
        already names a team.

````