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

# Create webhook

> Create an HTTPS webhook subscription for your teamspace. Datagrid returns the signing secret only in this response; store it securely and use it to verify future `Datagrid-Signature` headers.



## OpenAPI

````yaml post /webhooks
openapi: 3.0.3
info:
  version: 0.1.1
  title: Datagrid API
  description: Datagrid API
servers:
  - url: https://api.datagrid.com/v1
security:
  - BearerAuth: []
paths:
  /webhooks:
    post:
      tags:
        - Webhooks
      summary: Create webhook
      description: >-
        Create an HTTPS webhook subscription for your teamspace. Datagrid
        returns the signing secret only in this response; store it securely and
        use it to verify future `Datagrid-Signature` headers.
      operationId: Webhooks.createWebhook
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWebhookRequestBody'
      responses:
        '201':
          description: Successfully created webhook
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookWithSecret'
        '429':
          description: >-
            Rate limit exceeded. The request has been throttled because the rate
            limit for this endpoint has been reached. Check the `Retry-After`
            response header and retry after the specified number of seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Datagrid from 'datagrid-ai';

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

            const webhook = await client.webhooks.create({
              events: ['batch_prediction.completed', 'batch_prediction.failed'],
              url: 'https://example.com/webhooks/datagrid',
            });

            console.log(webhook);
        - lang: Python
          source: |-
            import os
            from datagrid_ai import Datagrid

            client = Datagrid(
                api_key=os.environ.get("DATAGRID_API_KEY"),  # This is the default and can be omitted
            )
            webhook = client.webhooks.create(
                events=["batch_prediction.completed", "batch_prediction.failed"],
                url="https://example.com/webhooks/datagrid",
            )
            print(webhook)
components:
  schemas:
    CreateWebhookRequestBody:
      type: object
      required:
        - url
        - events
      properties:
        url:
          type: string
          description: HTTPS destination URL for webhook deliveries.
        events:
          type: array
          items:
            $ref: '#/components/schemas/WebhookEventType'
          minItems: 1
          description: >-
            List of event types to subscribe to. Currently delivered events
            include `knowledge.processing.completed`,
            `batch_prediction.completed`, `batch_prediction.failed`,
            `batch_prediction.expired`, and `batch_prediction.cancelled`.
      example:
        url: https://example.com/webhooks/datagrid
        events:
          - batch_prediction.completed
          - batch_prediction.failed
    WebhookWithSecret:
      allOf:
        - $ref: '#/components/schemas/Webhook'
        - type: object
          required:
            - secret
          properties:
            secret:
              type: string
              description: The signing secret shown only when creating a webhook.
    RateLimitError:
      type: object
      description: >-
        Returned when the rate limit is exceeded. Rate limits are enforced per
        teamspace, endpoint path, and HTTP method over a 60-second sliding
        window. Each endpoint may have its own limit — check the
        X-RateLimit-Limit response header for the effective value.
      required:
        - error
        - message
        - retryable
        - status_code
      properties:
        status_code:
          type: integer
          description: The HTTP status code (429).
        statusCode:
          type: integer
          deprecated: true
          description: Deprecated. Use status_code instead.
        error:
          type: string
          enum:
            - rate_limit_exceeded
          description: The error code identifying this as a rate limit error.
        message:
          type: string
          description: A human-readable error message.
        mitigation:
          type: string
          description: Suggested action to resolve the error.
        retryable:
          type: boolean
          description: Whether the request can be retried after a delay.
        details:
          type: object
          properties:
            reason:
              type: string
              description: A detailed explanation of why the rate limit was exceeded.
    WebhookEventType:
      type: string
      enum:
        - knowledge.processing.completed
        - batch_prediction.completed
        - batch_prediction.failed
        - batch_prediction.expired
        - batch_prediction.cancelled
    Webhook:
      type: object
      description: The `webhook` object represents an outbound webhook subscription.
      required:
        - object
        - id
        - url
        - events
        - enabled
        - created_at
        - updated_at
      properties:
        object:
          type: string
          enum:
            - webhook
          description: The object type, which is always `webhook`.
        id:
          type: string
          description: The webhook identifier.
        url:
          type: string
          description: The destination URL for webhook deliveries.
        events:
          type: array
          items:
            $ref: '#/components/schemas/WebhookEventType'
          description: >-
            The subscribed event types. Currently delivered events include
            `knowledge.processing.completed`, `batch_prediction.completed`,
            `batch_prediction.failed`, `batch_prediction.expired`, and
            `batch_prediction.cancelled`.
        enabled:
          type: boolean
          description: Whether delivery is enabled for this webhook.
        created_at:
          type: string
          format: date-time
          description: The ISO string for when the webhook was created.
        updated_at:
          type: string
          format: date-time
          description: The ISO string for when the webhook was last updated.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````