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

# Webhooks

> An in-depth look at the structure and purpose of the `webhooks` table in the Serial database

## Introduction to the Webhooks Table

The Webhooks table is designed to store and manage webhook configurations for companies within the Serial application. This table plays a crucial role in enabling real-time notifications and integrations with external systems based on specific triggers within the application.

## Table Structure

The Webhooks table is structured to maintain essential information about each webhook configuration. Here's a detailed breakdown of its columns:

| Column Name   | Data Type                | Constraints                      | Description                                       |
| ------------- | ------------------------ | -------------------------------- | ------------------------------------------------- |
| id            | uuid                     | primary key                      | Unique identifier for each webhook configuration  |
| company\_id   | uuid                     | foreign key references companies | The company associated with the webhook           |
| trigger\_type | text                     |                                  | The type of event that triggers the webhook       |
| url           | text                     |                                  | The URL to which the webhook payload will be sent |
| created\_at   | timestamp with time zone |                                  | Timestamp of when the webhook was created         |
| updated\_at   | timestamp with time zone |                                  | Timestamp of the last update to the webhook       |

## Usage and Functionality

The Webhooks table is designed to be flexible and secure, allowing companies to configure their own integrations. Here are some key points about its usage:

1. **Company-Specific Configurations**: Each webhook is associated with a specific company through the `company_id` foreign key, ensuring that companies can manage their own webhook integrations independently.

2. **Trigger-Based Notifications**: The `trigger_type` column allows for different types of events to be configured as webhook triggers, providing flexibility in integration scenarios.

3. **Security and Access Control**: Row-level security policies are implemented to restrict access to webhook data. Only users with the ADMIN role for a specific company can SELECT, INSERT, UPDATE, or DELETE webhook records for that company.

4. **Automatic Updates**: A function is in place to update process revisions when a process is updated, which may trigger webhooks to notify external systems of these changes.

## Notes

* The table implements timestamps for creation and updates, allowing for auditing and tracking of webhook configuration changes.

* The table is designed to work in conjunction with other tables and functions in the database, particularly for process-related updates and notifications.

By leveraging the Webhooks table, the Serial application can provide a robust and flexible system for real-time integrations, allowing companies to automate workflows and keep external systems synchronized with events occurring within the Serial platform.
