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

# Create Webhook

> Creates a new webhook subscription to receive notifications when database events occur.

Creates a new webhook subscription for the specified database. The webhook will receive HTTP POST notifications when the subscribed events occur.

## Event Types

Subscribe to any combination of these events:

| Event            | Description                                  |
| ---------------- | -------------------------------------------- |
| `record.created` | Triggered when new records are added         |
| `record.updated` | Triggered when existing records are modified |
| `record.deleted` | Triggered when records are deleted           |
| `table.created`  | Triggered when new tables are added          |
| `table.updated`  | Triggered when table properties change       |
| `table.deleted`  | Triggered when tables are deleted            |
| `field.created`  | Triggered when new fields are added          |
| `field.updated`  | Triggered when field properties change       |
| `field.deleted`  | Triggered when fields are deleted            |

## Filtering by Table

Use the optional `tableId` parameter to receive events only for a specific table:

```json theme={null}
{
  "url": "https://your-server.com/webhook",
  "events": ["record.created", "record.updated"],
  "tableId": "tbl_abc123"
}
```

Omit `tableId` to receive events from all tables in the database.

## Example: Subscribe to Record Changes

```bash theme={null}
curl -X POST "https://tables.zite.com/api/v1/bases/{databaseId}/webhooks" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-server.com/webhooks/zite",
    "events": ["record.created", "record.updated", "record.deleted"]
  }'
```

**Response:**

```json theme={null}
{
  "id": 123,
  "secret": "a1b2c3d4e5f6..."
}
```

<Warning>
  Store the `secret` securely - it is only returned once on creation and cannot be retrieved later. You'll need this secret to verify webhook signatures.
</Warning>


## OpenAPI

````yaml help/database/openapi.json POST /bases/{databaseId}/webhooks
openapi: 3.0.1
info:
  title: Zite DB REST API
  description: >-
    A REST API for managing Zite databases, tables, fields, and records. Build
    database-driven applications with programmatic access to your structured
    data.


    ## What is REST API


    A **REST API** simplifies interaction with your database data, allowing for
    automation and integration. Following RESTful principles, it seamlessly
    connects to retrieve, create, and modify database data.


    ## Getting Started


    ### Authentication

    All API requests require authentication using your Zite API key in the
    Authorization header:

    ```

    Authorization: Bearer YOUR_API_KEY

    ```


    ### Base URL

    https://tables.zite.com/api/v1


    ### Rate Limits

    API requests are rate limited to ensure service quality. Standard rate
    limits apply to all endpoints.


    ### Error Handling

    The API returns standard HTTP status codes and JSON error responses with
    detailed error messages.
  version: 1.0.0
servers:
  - url: https://tables.zite.com/api/v1
    description: Zite DB API
security:
  - bearerAuth: []
tags:
  - name: Databases
    description: Operations for managing databases
  - name: Tables
    description: Operations for managing tables within databases
  - name: Fields
    description: Operations for managing fields within tables
  - name: Records
    description: Operations for managing records within tables
  - name: Webhooks
    description: >-
      Operations for managing webhook subscriptions to receive real-time
      notifications when database events occur
paths:
  /bases/{databaseId}/webhooks:
    post:
      tags:
        - Webhooks
      summary: Create webhook
      description: >-
        Creates a new webhook subscription for database events. Webhooks receive
        HTTP POST requests when specified events occur.
      operationId: createWebhook
      parameters:
        - name: databaseId
          in: path
          required: true
          schema:
            type: string
          description: The unique identifier of the database
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWebhookRequest'
      responses:
        '200':
          description: Webhook created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                    description: Unique identifier for the webhook
                  secret:
                    type: string
                    description: >-
                      The webhook secret for HMAC signature verification. Store
                      this securely - it is only returned once on creation.
                required:
                  - id
                  - secret
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    CreateWebhookRequest:
      type: object
      properties:
        url:
          type: string
          format: uri
          maxLength: 2048
          description: The URL to receive webhook POST requests
        events:
          type: array
          items:
            $ref: '#/components/schemas/WebhookEventType'
          minItems: 1
          description: Array of event types to subscribe to
        tableId:
          type: string
          description: >-
            Optional table ID to filter events. Omit to receive events from all
            tables.
      required:
        - url
        - events
      example:
        url: https://your-server.com/webhooks/zite
        events:
          - record.created
          - record.updated
          - record.deleted
        tableId: tbl_abc123
    WebhookEventType:
      type: string
      enum:
        - record.created
        - record.updated
        - record.deleted
        - table.created
        - table.updated
        - table.deleted
        - field.created
        - field.updated
        - field.deleted
      description: The type of database event that triggers the webhook
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Error code
            message:
              type: string
              description: Human-readable error message
          required:
            - code
            - message
      required:
        - error
  responses:
    BadRequest:
      description: Invalid request data or validation failure
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            invalidRecordId:
              value:
                error:
                  code: INVALID_RECORD_ID
                  message: Record ID is not in valid UUID format
            validationError:
              value:
                error:
                  code: BAD_REQUEST
                  message: Invalid request data or validation failure
    Unauthorized:
      description: Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: UNAUTHORIZED
              message: Invalid or missing API key
    NotFound:
      description: Requested resource does not exist
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: NOT_FOUND
              message: Requested resource does not exist
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Enter your Zite API key. Format: Bearer <api_key>'

````