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

# Webhooks setup guide

> Ingesting webhook events into Propel

<div />

This guide will show you how to send JSON events to Propel over HTTPS from any application or SaaS service.

You will learn how to:

1. [Create a Webhook Data Pool](#step-1-create-a-webhook-data-pool)
2. [Send events to the Webhook Data Pool](#step-2-send-events-to-the-webhook-data-pool)
3. [View your events in the Data Pool](#step-3-view-your-events-in-the-data-pool)

***

## Requirements

* You have a [Propel account](https://console.propeldata.com/get-started).

***

## Step 1: Create a Webhook Data Pool

<Tabs>
  <Tab title="Console">
    <Steps>
      <Step title="Navigate to Data Pools">
        In the Console, click on **"Data Pools"** in the left-hand menu. Click on **"Create Data Pool"** and select **"Webhook"**.

        <Frame>
          <img src="https://mintcdn.com/propeldocs/Dnye5EmtO6L5-zx0/images/docs/2024-09-webhook-data-pool-01.png?fit=max&auto=format&n=Dnye5EmtO6L5-zx0&q=85&s=ab4070cc9404eeab93daf47d706c8ce4" alt="A screenshot demonstrating how to select a Webhook Data Pool in the Propel Console" width="1650" height="687" data-path="images/docs/2024-09-webhook-data-pool-01.png" />
        </Frame>
      </Step>

      <Step title="Define the schema">
        The default schema contains two columns:

        | Column                 | Type      | Description                                        |
        | ---------------------- | --------- | -------------------------------------------------- |
        | \_propel\_received\_at | TIMESTAMP | The timestamp when the event was collected in UTC. |
        | \_propel\_payload      | JSON      | The JSON Payload of the event.                     |

        In the Payload section on the right-hand side, you can enter or paste a sample JSON event. This feature allows you to:

        1. Visualize the structure of your incoming data
        2. Automatically extract top-level and nested JSON keys
        3. Create specific columns for these extracted keys

        <Frame>
          <img src="https://mintcdn.com/propeldocs/Dnye5EmtO6L5-zx0/images/docs/2024-09-webhook-data-pool-02.png?fit=max&auto=format&n=Dnye5EmtO6L5-zx0&q=85&s=e39b90b425cc0ae477f3cbc0cf983985" alt="A screenshot demonstrating how to define the schema for a new Webhook Data Pool in the Propel Console." width="1441" height="1038" data-path="images/docs/2024-09-webhook-data-pool-02.png" />
        </Frame>

        By providing a sample event, you can easily customize your Data Pool's schema to match your data structure.

        For this guide, we'll use the TacoSoft sample data:

        ```json theme={"system"}
        {
          "customer_id": 5,
          "order_id": 34,
          "store_id": 4445,
          "order_details": {
            "taco_count": 5,
            "total_price": 30.4,
            "checkout_time": "2022-08-01T09:03:32Z"
          },
          "created_at": "2022-08-01T09:02:15Z"
        }
        ```

        After adding the sample JSON, click on **"Extract nested properties"** to create columns representing the nested JSON keys.

        Set `created_at` as your default timestamp. Click **"Next"**.

        <Warning>
          If a required field is missing from the sample event, Propel will reject the event with an `HTTP 400 Bad Request` error.
        </Warning>
      </Step>

      <Step title="Configure Authentication">
        Configure authentication for your webhook URL:

        * To enable HTTP basic authentication, specify a username and password.
        * For initial testing, you can leave these fields blank.
        * You can always edit these settings later.

        After configuring (or skipping) authentication, click **"Next"** to proceed.

        <Frame>
          <img src="https://mintcdn.com/propeldocs/Dnye5EmtO6L5-zx0/images/docs/2024-09-webhook-data-pool-03.png?fit=max&auto=format&n=Dnye5EmtO6L5-zx0&q=85&s=a797b483729b29e4d5e8424e0a8cd83c" alt="A screenshot demonstrating how to configure authentication for a new Webhook Data Pool in the Propel Console." width="1443" height="415" data-path="images/docs/2024-09-webhook-data-pool-03.png" />
        </Frame>
      </Step>

      <Step title="Configure data type and settings">
        Select whether your data is "Append-only" or "Mutable data".

        To learn more, read out guide on [Selecting table engine and sorting key](/docs/guides/table-engine-and-sorting-key).

        <Frame>
          <img src="https://mintcdn.com/propeldocs/Dnye5EmtO6L5-zx0/images/docs/2024-09-webhook-data-pool-04.png?fit=max&auto=format&n=Dnye5EmtO6L5-zx0&q=85&s=b358e106dcadde0fb2eed17d7242df93" alt="A screenshot demonstrating how to configure authentication for a new Webhook Data Pool in the Propel Console." width="1442" height="482" data-path="images/docs/2024-09-webhook-data-pool-04.png" />
        </Frame>

        Answer the questions in the wizard to complete the setup.

        <Frame>
          <img src="https://mintcdn.com/propeldocs/Dnye5EmtO6L5-zx0/images/docs/2024-09-webhook-data-pool-05.png?fit=max&auto=format&n=Dnye5EmtO6L5-zx0&q=85&s=9d75e009214bd7eaf56f3287a1de3711" alt="A screenshot demonstrating how to configure authentication for a new Webhook Data Pool in the Propel Console." width="1444" height="548" data-path="images/docs/2024-09-webhook-data-pool-05.png" />
        </Frame>

        Confirm your table settings and click **“Continue”**.

        <Frame>
          <img src="https://mintcdn.com/propeldocs/Dnye5EmtO6L5-zx0/images/docs/2024-09-webhook-data-pool-06.png?fit=max&auto=format&n=Dnye5EmtO6L5-zx0&q=85&s=f167b629bb4fd4c6e194dd89a48ae71a" alt="A screenshot demonstrating how to configure authentication for a new Webhook Data Pool in the Propel Console." width="1444" height="827" data-path="images/docs/2024-09-webhook-data-pool-06.png" />
        </Frame>
      </Step>

      <Step title="Set a name and description">
        Enter a name and description for your new Data Pool and click **"Next"**.

        <Frame>
          <img src="https://mintcdn.com/propeldocs/Dnye5EmtO6L5-zx0/images/docs/2024-09-webhook-data-pool-07.png?fit=max&auto=format&n=Dnye5EmtO6L5-zx0&q=85&s=e8b4633e33f85b34e3f8dea135441ec2" alt="A screenshot demonstrating how to add a name and description to a new Webhook Data Pool in the Propel Console." width="1446" height="535" data-path="images/docs/2024-09-webhook-data-pool-07.png" />
        </Frame>

        After creating the Data Pool, you'll be provided with a unique HTTP URL. This URL is where you'll send your JSON data for ingestion.

        <Frame>
          <img src="https://mintcdn.com/propeldocs/Dnye5EmtO6L5-zx0/images/docs/2024-09-webhook-data-pool-08.png?fit=max&auto=format&n=Dnye5EmtO6L5-zx0&q=85&s=fcf75bf0f2e76bbcc13a134d5d815d96" alt="A screenshot demonstrating a new Webhook Data Pool in the Propel Console." width="1043" height="786" data-path="images/docs/2024-09-webhook-data-pool-08.png" />
        </Frame>
      </Step>
    </Steps>
  </Tab>

  <Tab title="API">
    For the Webhook Data Pool, creating the Data Source below automatically creates the Data Pool.

    ```graphql theme={"system"}
    mutation {
      createWebhookDataSource(input: {
        uniqueName: "WebhookCredentials"
        description:"My Webhook Credentials"
        connectionSettings: {
          basicAuth: {
            username: "propel-user"
            password: "<SUPER_SECURE_PASSWORD>"
          }
          columns: [
            { name: "created_at", jsonProperty: "created_at", type: TIMESTAMP, nullable: false },
            { name: "customer_id", jsonProperty: "customer_id", type: INT32, nullable: false },
            { name: "order_id", jsonProperty: "order_id", type: INT32, nullable: false },
            { name: "store_id", jsonProperty: "store_id", type: INT32, nullable: false },
            { name: "order_details", jsonProperty: "order_details", type: JSON, nullable: false }
          ]
          accessControlEnabled: true,
          tableSettings: {
            engine: {
              mergeTree: {
                type: MERGE_TREE
              }
            }
            orderBy: ["created_at"],
            partitionBy: ["toYYYYMM(created_at, 'UTC')"]
          }
        }

      }){
        dataSource {
          id
          uniqueName
          status
        }
      }
    }
    ```
  </Tab>

  <Tab title="Terraform">
    For the Webhook Data Pool, creating the Data Source below automatically creates the Data Pool.

    ```hcl theme={"system"}
    resource "propel_data_source" "my_webhook {
      unique_name = "WebhookCredentials"
      description = "My Webhook Credentials"
      type        = "WEBHOOK"
      webhook_connection_settings {
        timestamp = "created_at"
        column {
          name = "created_at"
          type = "TIMESTAMP"
          nullable = false
          json_property = "created_at"
        }
        column {
          name = "customer_id"
          type = "INT32"
          nullable = false
          json_property = "customer_id"
        }
        column {
          name = "order_id"
          type = "INT32"
          nullable = false
          json_property = "order_id"
        }
        column {
          name = "store_id"
          type = "INT32"
          nullable = false
          json_property = "store_id"
        }
        column {
          name = "order_details"
          type = "JSON"
          nullable = false
          json_property = "order_details"
        }

        basic_auth {
          username = "propel-user"
          password = var.http_basic_auth_password
        }
        access_control_enabled = true
        table_settings {
          engine {
            merge_tree {
              type = "MERGE_TREE"
            }
          }
          order_by = ["created_at"]
          partition_by = ["toYYYYMM(created_at, 'UTC')"]
        }
      }
    }

    variable "http_basic_auth_password" {
      type = string
      sensitive = true
    }
    ```
  </Tab>
</Tabs>

***

## Step 2: Send events to the Webhook Data Pool

<Steps>
  <Step title="Prepare your data">
    Create a JSON array of events you want to send to the Webhook Data Pool.

    Here's an example:

    ```json theme={"system"}
    [
      {
        "customer_id": 5,
        "order_id": 34,
        "store_id": 4445,
        "order_details": {
          "taco_count": 7,
          "total_price": 25.90,
          "checkout_time": "2023-07-31T15:20:10Z"
        },
        "created_at": "2023-07-31T14:50:35Z"
      },
      {
        "customer_id": 8,
        "order_id": 22,
        "store_id": 1199,
        "order_details": {
          "taco_count": 3,
          "total_price": 15.75,
          "checkout_time": "2023-07-31T12:40:21Z"
        },
        "created_at": "2023-07-31T12:30:55Z"
      }
    ]
    ```
  </Step>

  <Step title="Send the data">
    Send a POST request to the Webhook Data Pool's URL using curl or any HTTP client. Here's an example using curl:

    ```bash theme={"system"}
    curl https://webhooks.us-east-2.propeldata.com/v1/WHK... \
    -X POST \
    -H "Content-Type: application/json" \
    -d '[
      {
        "customer_id": 5,
        "order_id": 34,
        "store_id": 4445,
        "order_details": {
          "taco_count": 7,
          "total_price": 25.90,
          "checkout_time": "2023-07-31T15:20:10Z"
        },
        "created_at": "2023-07-31T14:50:35Z"
      },
      {
        "customer_id": 8,
        "order_id": 22,
        "store_id": 1199,
        "order_details": {
          "taco_count": 3,
          "total_price": 15.75,
          "checkout_time": "2023-07-31T12:40:21Z"
        },
        "created_at": "2023-07-31T12:30:55Z"
      }
    ]'
    ```
  </Step>

  <Step title="Check the response">
    You should expect a `200 OK` with multiple "Event processed successfully" messages in the body of the response, one for each event.
  </Step>
</Steps>

## Step 3: View your events in the Data Pool

<Steps>
  <Step title="Navigate to your Data Pool">
    Click on **"Data Pools"** in the Console, and then select your Data Pool.
  </Step>

  <Step title="View the data">
    Head over to the **"Preview Data"** tab, and you should see the events data as POSTed, reflected in the schema we defined.

    <Frame>
      <img src="https://mintcdn.com/propeldocs/Dnye5EmtO6L5-zx0/images/docs/2024-09-webhook-data-pool-09.png?fit=max&auto=format&n=Dnye5EmtO6L5-zx0&q=85&s=d37c9dffc670ca51ed144df75daf1f9d" alt="A screenshot demonstrating the Webhook Data Pool in the Propel Console." width="1050" height="443" data-path="images/docs/2024-09-webhook-data-pool-09.png" />
    </Frame>
  </Step>
</Steps>
