Send Clerk webhooks to Tinybird

Clerk is a developer-focused user management platform to handle user authentication with many prebuilt UI components. By integrating Clerk with Tinybird, you can analyze your user authentication data in real time and enrich it with other data sources.

Some common use cases for sending Clerk webhooks to Tinybird include:

  1. Tracking net user and organization growth.
  2. Monitoring user churn.
  3. Identifying common auth errors.
  4. Creating custom dashboards for auth analysis.
  5. Enriching other data sources with real-time auth metrics.

Read on to learn how to send data from Clerk to Tinybird.

Before you start

Before you connect Clerk to Tinybird, ensure:

  • You have a Clerk account.
  • You have a Tinybird Workspace.

Connect Clerk to Tinybird

  1. From the Clerk UI, select Configure > Webhooks.

  2. Select Add Endpoint.

  3. In Tinybird, create a Data Source (called clerk in this example), with the following schema:

SCHEMA >
  'ingest_timestamp' DateTime `json:$.time` DEFAULT now(),
  'record' JSON `json:$`

ENGINE "MergeTree"
ENGINE_SORTING_KEY "ingest_timestamp"
ENGINE_TTL ""
ENGINE_PARTITION_KEY ""

Using the JSON Data Type enables storing in a single column the semi-structured data you'll receive from Clerk. You can later extract various events and their metadata as needed in your Pipes.

  1. Back in Clerk, paste the Events API URL in your Webhook Endpoint URL. Use the query parameter name to match the name of the Data Source you created in Tinybird, for example: https://api.tinybird.co/v0/events?name=clerk.

Replace the Tinybird API hostname/region with the right API URL region that matches your Workspace. Your Token lives in the Workspace under "Tokens".

  1. Return to Tinybird, and copy a token with priveleges to write to the Data Source you created. You can use the admin token or create one with the required scope.

  2. Return to the Clerk Webhooks page, and update the URL to add a new search parameter token with the token you copied. The final URL looks like: https://api.tinybird.co/v0/events?name=clerk&token=p.eyXXXXX.

  3. Select the checkboxes for the Clerk events you want to send to Tinybird, and select Create.

  4. You're done. Any of the Clerk events you selected will automatically be sent to Tinybird via the Events API. You can test the integration from the Testing tab in the Clerk Webhooks UI.

See also

Was this page helpful?
Updated