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

# Create webhook

> Creates a new webhook with event subscriptions. The signing secret is only returned in this response.



## OpenAPI

````yaml /api-reference/openapi.documented.json post /v1/webhook
openapi: 3.1.0
info:
  title: Roark Analytics API
  description: >-
    The Roark Analytics API gives you access to the same API that powers the
    award winning Roark Analytics platform.
  version: 1.0.0
servers:
  - description: Production
    url: https://api.roark.ai
security:
  - Bearer: []
tags:
  - name: Agent
  - name: Agent Endpoint
  - name: Call
  - name: Chat
  - name: Metric
  - name: Metric Policy
  - name: Metric Collection Job
  - name: Simulation Persona
  - name: Simulation Scenario
  - name: Simulation Run Plan
  - name: Simulation Run Plan Job
  - name: Simulation Job
  - name: HTTP Request Definition
  - name: Webhook
  - name: Issue
  - name: Knowledge Base
  - name: Call Analysis
  - name: Health
paths:
  /v1/webhook:
    post:
      tags:
        - Webhook
      summary: Create webhook
      description: >-
        Creates a new webhook with event subscriptions. The signing secret is
        only returned in this response.
      operationId: postV1Webhook
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWebhookInput'
      responses:
        '201':
          description: The created webhook with signing secret
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/CreateWebhookResponse'
                required:
                  - data
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Authentication error
              example:
                type: authentication
                code: unauthorized
                message: Authentication required
          description: Unauthorized
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Server error
              example:
                type: internal
                code: internal_error
                message: Internal server error
          description: Internal Server Error
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Roark from '@roarkanalytics/sdk';

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

            const webhook = await client.webhook.create({
              events: ['CALL_ANALYSIS_COMPLETED'],
              url: 'https://example.com',
            });

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

            client = Roark(
                bearer_token=os.environ.get("ROARK_API_BEARER_TOKEN"),  # This is the default and can be omitted
            )
            webhook = client.webhook.create(
                events=["CALL_ANALYSIS_COMPLETED"],
                url="https://example.com",
            )
            print(webhook.data)
components:
  schemas:
    CreateWebhookInput:
      type: object
      properties:
        url:
          type: string
          format: uri
          description: Webhook URL
        description:
          type:
            - string
            - 'null'
          description: Webhook description
        headers:
          type: object
          additionalProperties:
            type: string
          description: Request headers (e.g. authorization tokens)
        events:
          type: array
          items:
            type: string
            enum:
              - CALL_ANALYSIS_COMPLETED
              - CALL_ANALYSIS_FAILED
              - CALL_ANALYSIS_CANCELLED
              - CALL_EVALUATION_COMPLETED
              - CALL_EVALUATION_FAILED
              - SIMULATION_RUN_PLAN_JOB_STARTED
              - SIMULATION_RUN_PLAN_JOB_COMPLETED
              - SIMULATION_RUN_PLAN_JOB_FAILED
              - SIMULATION_RUN_PLAN_JOB_CANCELLED
              - SIMULATION_JOB_STARTED
              - SIMULATION_JOB_COMPLETED
              - SIMULATION_JOB_FAILED
              - SIMULATION_JOB_CANCELLED
              - METRIC_COLLECTION_JOB_COMPLETED
              - METRIC_COLLECTION_JOB_FAILED
              - CHAT_ANALYSIS_COMPLETED
              - CHAT_ANALYSIS_FAILED
              - ISSUE_OPENED
              - ISSUE_RESOLVED
          minItems: 1
          description: Event types to subscribe to (at least one required)
      required:
        - url
        - events
      description: Input for creating a webhook
    CreateWebhookResponse:
      allOf:
        - $ref: '#/components/schemas/WebhookResponse'
      properties:
        signingSecret:
          type: string
          description: Signing secret (only returned on creation)
      required:
        - signingSecret
      description: Webhook response with signing secret (returned on creation)
    ErrorResponse:
      type: object
      properties:
        type:
          type: string
          enum:
            - validation
            - authentication
            - forbidden
            - not_found
            - conflict
            - rate_limit
            - internal
          description: The error type category
          examples:
            - validation
            - authentication
        code:
          type: string
          description: Machine-readable error code identifier
          examples:
            - invalid_parameter
            - missing_required_field
            - unauthorized
        message:
          type: string
          description: Human-readable error message
          examples:
            - The request was invalid
            - Authentication required
        param:
          type: string
          description: The parameter that caused the error (if applicable)
          examples:
            - email
            - user_id
        details:
          description: Additional error context information
      required:
        - type
        - code
        - message
    WebhookResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Webhook ID
        description:
          type:
            - string
            - 'null'
          description: Webhook description
        url:
          type: string
          description: Webhook URL
        headers:
          type: object
          additionalProperties:
            type: string
          description: Request headers
        events:
          type: array
          items:
            type: string
            enum:
              - CALL_ANALYSIS_COMPLETED
              - CALL_ANALYSIS_FAILED
              - CALL_ANALYSIS_CANCELLED
              - CALL_EVALUATION_COMPLETED
              - CALL_EVALUATION_FAILED
              - SIMULATION_RUN_PLAN_JOB_STARTED
              - SIMULATION_RUN_PLAN_JOB_COMPLETED
              - SIMULATION_RUN_PLAN_JOB_FAILED
              - SIMULATION_RUN_PLAN_JOB_CANCELLED
              - SIMULATION_JOB_STARTED
              - SIMULATION_JOB_COMPLETED
              - SIMULATION_JOB_FAILED
              - SIMULATION_JOB_CANCELLED
              - METRIC_COLLECTION_JOB_COMPLETED
              - METRIC_COLLECTION_JOB_FAILED
              - CHAT_ANALYSIS_COMPLETED
              - CHAT_ANALYSIS_FAILED
              - ISSUE_OPENED
              - ISSUE_RESOLVED
          description: Event types this webhook is subscribed to
        createdAt:
          type: string
          description: Creation timestamp
        updatedAt:
          type: string
          description: Last update timestamp
      required:
        - id
        - description
        - url
        - headers
        - events
        - createdAt
        - updatedAt
      description: Webhook with its subscribed event types
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT

````