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

# Create a webhook subscription



## OpenAPI

````yaml specs/webhooks.yaml POST /v1/webhook-subscriptions
openapi: 3.0.3
info:
  title: AssemblyAI Voice Agent Webhooks API
  description: >
    Subscribe to session and call lifecycle events for your voice agents.
    AssemblyAI

    POSTs a signed JSON payload to your URL when each event fires. See

    [Webhooks](/voice-agents/voice-agent-api/webhooks).
  version: 1.0.0
  termsOfService: https://www.assemblyai.com/legal/terms-of-service
  contact:
    name: API Support
    email: support@assemblyai.com
    url: https://www.assemblyai.com/docs/
servers:
  - url: https://agents.assemblyai.com
    description: Production server
    x-fern-server-name: Default
security: []
paths:
  /v1/webhook-subscriptions:
    post:
      summary: Create a webhook subscription
      description: >-
        Subscribe a URL to one or more events. Scope to a single agent with
        agent_id, or omit it for account-wide events.
      operationId: createWebhookSubscription
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWebhookSubscriptionRequest'
      responses:
        '201':
          description: The created subscription.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookSubscription'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          description: Invalid request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - apiKey: []
components:
  schemas:
    CreateWebhookSubscriptionRequest:
      type: object
      required:
        - url
        - events
        - secret
      properties:
        url:
          type: string
          description: Delivery URL. Must be https and a public host.
          example: https://your-app.com/webhooks/assemblyai
        events:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/WebhookEvent'
        secret:
          type: string
          description: >-
            Signing secret, 32–256 printable ASCII chars (no whitespace).
            Write-only; never returned.
          minLength: 32
          maxLength: 256
        agent_id:
          type: string
          description: Scope to one agent. Omit for account-wide events.
          nullable: true
        enabled:
          type: boolean
          default: true
    WebhookSubscription:
      type: object
      description: A subscription. The signing secret is never returned, only its version.
      properties:
        id:
          type: string
        agent_id:
          type: string
          nullable: true
        url:
          type: string
        events:
          type: array
          items:
            $ref: '#/components/schemas/WebhookEvent'
        enabled:
          type: boolean
        secret_version:
          type: integer
          example: 1
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    Error:
      type: object
      properties:
        detail:
          type: string
          example: Unauthorized
    WebhookEvent:
      type: string
      enum:
        - session.started
        - session.completed
        - call.connected
        - call.ended
        - call.failed
  responses:
    Unauthorized:
      description: Unauthorized. Invalid or missing API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Your AssemblyAI API key in the Authorization header (raw key; a Bearer
        prefix is also accepted).

````