This guide walks through the steps to ingest data from HubSpot into Materialize using the Webhook source.

Before you begin

Ensure that you have:

Step 1. (Optional) Create a cluster

NOTE: If you are prototyping and already have a cluster to host your webhook source (e.g. quickstart), you can skip this step. For production scenarios, we recommend separating your workloads into multiple clusters for resource isolation.

To create a cluster in Materialize, use the CREATE CLUSTER command:

CREATE CLUSTER webhooks_cluster (SIZE = '25cc');

SET CLUSTER = webhooks_cluster;

Step 2. Create a secret

To validate requests between HubSpot and Materialize, you must create a secret:

CREATE SECRET hubspot_webhook_secret AS '<secret_value>';

Change the <secret_value> to a unique value that only you know and store it in a secure location.

Step 3. Set up a webhook source

Using the secret the previous step, create a webhook source in Materialize to ingest data from HubSpot. By default, the source will be created in the active cluster; to use a different cluster, use the IN CLUSTER clause.

CREATE SOURCE hubspot_source
    CHECK (
      WITH (
        BODY AS body,
        SECRET hubspot_webhook_secret AS validation_secret
      -- The constant_time_eq validation function **does not support** fully
      -- qualified secret names. We recommend always aliasing the secret name
      -- for ease of use.
      constant_time_eq(headers->'authorization', validation_secret)

After a successful run, the command returns a NOTICE message containing the unique webhook URL that allows you to POST events to the source. Copy and store it. You will need it for the next step.

The URL will have the following format:


If you missed the notice, you can find the URLs for all webhook sources in the mz_internal.mz_webhook_sources system table.

Access and authentication

WARNING! Without a CHECK statement, all requests will be accepted. To prevent bad actors from injecting data into your source, it is strongly encouraged that you define a CHECK statement with your webhook sources.

The CHECK clause defines how to validate each request. At the time of writing, HubSpot supports API key authentication, which you can use to validate requests.

The above webhook source uses basic authentication. This enables a simple and rudimentary way to grant authorization to your webhook source.

Step 4. Create a webhook workflow in HubSpot

A webhook in HubSpot is a workflow action that sends data to a webhook URL. You can create a webhook workflow in HubSpot to send data to the webhook source you created in the previous step.

  1. In HubSpot, go to Automation > Workflows.

  2. Click the Name of the workflow you want to add the webhook to, or create a new one.

  3. Click the + icon to add an action.

  4. In the right panel, search for Send a webhook.

  5. Click the Method dropdown menu, then select POST.

  6. Enter the URL from Step 3..

  7. Authenticate the request using the API key option. Use the secret created in Step 2..

  8. For the API Key Name, enter authorization. This is the key used in the CHECK clause of the webhook source.

  9. Click Save.

Step 5. Configure the request body in HubSpot

The request body is the data that HubSpot sends to the webhook URL. You can configure the request body to send the data you want to ingest into Materialize.

  1. In HubSpot, go to the webhook workflow created in Step 4..

  2. Go to the Request body section, and click Customize request body.

  3. In the Request body section, click Add property.

  4. From the dropdown menu, select the property you want to send to Materialize. Repeat this step for each property you want to send to Materialize.

  5. Click Test Mapping to validate that the webhook is working. If Test Mapping fails and throws a failed to validate the request error, this means that the secret is not correct. To fix this:

    1. In HubSpot, go to the webhook workflow.
    2. Go to the Authentication section.
    3. Enter the secret created in Step 2..
    4. Verify that the API Key Name is authorization.
    5. Click Save.
  6. After a succesful test, click Save.

Step 6. Validate incoming data

With the source set up in Materialize and the webhook workflow configured in HubSpot, you can now query the incoming data:

  1. In the Materialize console, navigate to the SQL Shell.

  2. Use SQL queries to inspect and analyze the incoming data:

    SELECT * FROM hubspot_source LIMIT 10;

Step 7. Transform incoming data

JSON parsing

Webhook data is ingested as a JSON blob. We recommend creating a parsing view on top of your webhook source that uses jsonb operators to map the individual fields to columns with the required data types.

    body->>'city' AS city,
    body->>'firstname' AS firstname,
    body->>'ip_city' AS ip_city,
    -- Add all of the fields you want to ingest
FROM hubspot_source;
Manually parsing JSON-formatted data in SQL can be tedious. 🫠 You can use the widget below to automatically turn a sample JSON payload into a parsing view with the individual fields mapped to columns.

Target object type

Timestamp handling

We highly recommend using the try_parse_monotonic_iso8601_timestamp function when casting from text to timestamp, which enables temporal filter pushdown.


With the vast amount of data processed and potential network issues, it’s not uncommon to receive duplicate records. You can use the DISTINCT ON clause to efficiently remove duplicates. For more details, refer to the webhook source reference documentation.

Next steps

With Materialize ingesting your HubSpot data, you can start exploring it, computing real-time results that stay up-to-date as new data arrives, and serving results efficiently. For more details, check out the HubSpot documentation and the webhook source reference documentation.

Back to top ↑