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

# Create Webhook Source

> Creates a new webhook source for a knowledge base. A webhook source
defines how to fetch content from an external URL or execute a series
of steps to produce content. Requires either `steps` or `url`.
Requires `knowledge:upload` permission.




## OpenAPI

````yaml POST /api/knowledge-bases/{id}/webhooks
openapi: 3.1.0
info:
  title: Naturalead Knowledge Bases API
  version: 1.0.0
  description: >
    API for managing knowledge bases, documents, sitemap crawl jobs, and webhook

    sources in the Naturalead platform. All endpoints require API key
    authentication

    and are scoped to the caller's account.
servers:
  - url: '{baseUrl}'
    description: API server
    variables:
      baseUrl:
        default: http://localhost:3001
security:
  - BearerAuth: []
tags:
  - name: Knowledge Bases
    description: Knowledge base CRUD operations
  - name: Documents
    description: Document management within a knowledge base
  - name: Sitemap & Crawl Jobs
    description: Sitemap scanning and web crawl job management
  - name: Webhook Sources
    description: Webhook source management for auto-updating content
paths:
  /api/knowledge-bases/{id}/webhooks:
    post:
      tags:
        - Webhook Sources
      summary: Create webhook source
      description: |
        Creates a new webhook source for a knowledge base. A webhook source
        defines how to fetch content from an external URL or execute a series
        of steps to produce content. Requires either `steps` or `url`.
        Requires `knowledge:upload` permission.
      operationId: createWebhookSource
      parameters:
        - $ref: '#/components/parameters/KnowledgeBaseId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: Name of the webhook source
                steps:
                  type: array
                  items:
                    $ref: '#/components/schemas/Step'
                  description: Ordered list of steps to execute
                flowInputs:
                  type: array
                  items:
                    $ref: '#/components/schemas/FlowInput'
                  description: Input variables for the step flow
                url:
                  type: string
                  description: URL to fetch content from
                method:
                  type: string
                  description: HTTP method for the URL request
                headers:
                  type: object
                  additionalProperties:
                    type: string
                  description: HTTP headers for the URL request
                body:
                  type: string
                  description: Request body for the URL request
                auth:
                  type: object
                  description: Authentication configuration for the URL request
                intervalMinutes:
                  type: integer
                  description: Polling interval in minutes
                timeoutMs:
                  type: integer
                  description: Request timeout in milliseconds
              required:
                - name
      responses:
        '201':
          description: Created webhook source
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookSource'
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    KnowledgeBaseId:
      name: id
      in: path
      required: true
      description: Knowledge base ID
      schema:
        type: string
  schemas:
    Step:
      type: object
      description: A single execution step in a webhook source flow
      properties:
        name:
          type: string
          description: Unique step identifier within the flow
        order:
          type: integer
          description: Execution order (0-based)
        url:
          type: string
          description: >-
            HTTP endpoint URL. Supports template variables like
            `{{stepName.varName}}`
        method:
          type: string
          enum:
            - GET
            - POST
            - PUT
            - PATCH
            - DELETE
          default: GET
        headers:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
              value:
                type: string
          description: Request headers (support template variables)
        body:
          type: string
          description: Request body (for POST/PUT/PATCH). Supports template variables
        extractions:
          type: array
          items:
            $ref: '#/components/schemas/FlowStepExtraction'
          description: Variables to extract from the response via JSONPath
        fanOut:
          type: object
          description: Fan-out configuration to iterate over an array in the response
          properties:
            sourcePath:
              type: string
              description: JSONPath to the array to iterate over
            itemVariable:
              type: string
              default: item
              description: Variable name for the current item in the iteration
            rateLimit:
              type: object
              properties:
                delayMs:
                  type: integer
                  description: Delay in ms between each fan-out request
        retry:
          type: object
          properties:
            maxAttempts:
              type: integer
              default: 0
            initialDelayMs:
              type: integer
              default: 1000
            maxDelayMs:
              type: integer
              default: 30000
            backoffMultiplier:
              type: number
              default: 2
        onError:
          type: string
          enum:
            - fail
            - skip
            - retry
          default: fail
          description: Error handling strategy
        timeoutMs:
          type: integer
          description: Per-step timeout in milliseconds (1000-900000)
      required:
        - name
        - order
        - url
    FlowInput:
      type: object
      properties:
        name:
          type: string
          description: Input variable name
        value:
          type: string
          description: Input variable value
      required:
        - name
        - value
    WebhookSource:
      type: object
      properties:
        _id:
          type: string
          description: Unique identifier
        accountId:
          type: string
          description: Owning account ID
        knowledgeBaseId:
          type: string
          description: Parent knowledge base ID
        name:
          type: string
          description: Webhook source name
        enabled:
          type: boolean
          description: Whether the webhook source is active
        steps:
          type: array
          items:
            $ref: '#/components/schemas/Step'
          description: Ordered list of execution steps
        flowInputs:
          type: array
          items:
            $ref: '#/components/schemas/FlowInput'
          description: Input variables for the step flow
        url:
          type: string
          description: URL to fetch content from
        method:
          type: string
          description: HTTP method
        headers:
          type: object
          additionalProperties:
            type: string
          description: HTTP headers
        body:
          type: string
          description: Request body
        auth:
          type: object
          description: Authentication configuration
        intervalMinutes:
          type: integer
          description: Polling interval in minutes
        timeoutMs:
          type: integer
          description: Request timeout in milliseconds
        lastTriggeredAt:
          type: string
          format: date-time
          description: Timestamp of the last trigger
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      required:
        - _id
        - accountId
        - knowledgeBaseId
        - name
        - enabled
        - createdAt
        - updatedAt
    FlowStepExtraction:
      type: object
      description: Defines a variable to extract from a step's HTTP response
      properties:
        variableName:
          type: string
          description: Name of the variable to store the extracted value
        jsonPath:
          type: string
          description: JSONPath expression (must start with `$`)
        useAsContext:
          type: boolean
          default: false
          description: >-
            When true, the extracted value is included as context in subsequent
            steps' content before knowledge base processing. This ensures the
            value is stored in the vector store alongside the fetched content.
      required:
        - variableName
        - jsonPath
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
            required:
              - error
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
            required:
              - error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Bearer token using an API key (format nl_live_* or nl_test_*)

````