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

# Create webhook

> Register a new webhook endpoint. Requires `webhooks:write`; subscribing to retrieval events also requires `retrievals:read`. The secret is returned only in this response.



## OpenAPI

````yaml POST /v2/webhooks
openapi: 3.0.1
info:
  title: Tavrn Platform API
  version: 1.0.0
  description: >-
    Enterprise API for medical record retrieval: cases, retrieval requests,
    retrieved records and provider invoices, case documents, and webhook
    notifications.
  contact:
    name: Tavrn Support
    email: contact@tavrn.ai
servers:
  - url: https://enterprise.tavrn.ai
    description: Production server
security:
  - bearerAuth: []
tags:
  - name: Cases
    description: Case management operations
  - name: Documents
    description: Document upload and management
  - name: Retrieval Requests
    description: Medical record retrieval requests submitted to healthcare facilities
  - name: Requestors
    description: Multiple retrieval profiles within one organization
  - name: Webhooks
    description: Webhook registration and event notifications
paths:
  /v2/webhooks:
    post:
      tags:
        - Webhooks
      summary: Create webhook
      description: >-
        Register a new webhook endpoint. Requires `webhooks:write`; subscribing
        to retrieval events also requires `retrievals:read`. The secret is
        returned only in this response.
      operationId: createWebhook
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookCreate'
      responses:
        '201':
          description: Webhook created successfully (secret is ONLY returned here!)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookCreateResponse'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >-
            The API key lacks a scope required by the requested events (for
            example, retrievals:read for a retrieval request event).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: >-
            A webhook with this name already exists, or `limit_exceeded`: the
            organization already has the maximum of 20 webhooks
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    WebhookCreate:
      type: object
      required:
        - name
        - url
        - events
      properties:
        name:
          type: string
          minLength: 1
          description: Webhook name, unique within your organization
          example: Production webhook
          maxLength: 100
        url:
          type: string
          format: uri
          description: Webhook endpoint URL (must use HTTP/HTTPS)
          example: https://client.example.com/webhooks/tavrn
          maxLength: 2048
        events:
          type: array
          items:
            type: string
            enum:
              - retrieval_request.status_changed
              - retrieval_request.action_required
              - retrieval_request.documents_available
          minItems: 1
          description: Event types to subscribe to (at least one required)
          example:
            - retrieval_request.status_changed
            - retrieval_request.documents_available
        description:
          type: string
          nullable: true
          description: Optional webhook description
          example: Production webhook for retrieval events
          maxLength: 500
    WebhookCreateResponse:
      type: object
      description: Creation response. Read or list the webhook for delivery health fields.
      required:
        - id
        - name
        - url
        - description
        - events
        - secret
        - is_enabled
        - auto_disabled_at
        - last_failure
        - created_at
      properties:
        id:
          type: string
          description: Opaque webhook identifier.
          example: 507f1f77bcf86cd799439016
        name:
          type: string
          description: Webhook name, unique within your organization
          example: Production webhook
        url:
          type: string
          format: uri
          example: https://client.example.com/webhooks/tavrn
        description:
          type: string
          nullable: true
          description: Optional webhook description
        events:
          type: array
          items:
            type: string
            enum:
              - retrieval_request.status_changed
              - retrieval_request.action_required
              - retrieval_request.documents_available
        secret:
          type: string
          description: Webhook secret, returned only on creation. Store it securely.
          example: whsec_XyZ789AbCdEfGhIjKlMnOpQrSt
        is_enabled:
          type: boolean
          example: true
        auto_disabled_at:
          type: string
          format: date-time
          nullable: true
          description: Always null when the webhook is created
        last_failure:
          type: object
          nullable: true
          description: Always null when the webhook is created
        created_at:
          type: string
          format: date-time
          example: '2026-10-08T12:00:00.000Z'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Machine-readable error code
              example: validation_error
            message:
              type: string
              description: Human-readable error message
              example: The patient.date_of_birth field is required
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        API key authentication. Use format: `Authorization: Bearer
        tavrn_sk_live_...`

````