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:
- Tracking net user and organization growth.
- Monitoring user churn.
- Identifying common auth errors.
- Creating custom dashboards for auth analysis.
- 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¶
From the Clerk UI, select Configure > Webhooks.
Select Add Endpoint.
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.
- 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".
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.
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
.Select the checkboxes for the Clerk events you want to send to Tinybird, and select Create.
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.