Setup Webhooks
Configure webhooks for Stripe and other integrations
This guide walks you through setting up webhooks for various integrations in your Agentic Team OS.
Webhooks are configured in the API Template.
Overview
Webhooks are essential for handling asynchronous events from:
- Stripe (payments and subscriptions)
- Clerk (user authentication)
The checkout webhook is implemented in the billing module of the control plane using the AMU Pattern.
This guide covers setting up the webhook not implementing the billing logic.
By default a completed checkout session will trigger an update to the customers API with a refill to their API key.
Only the checkout.session.completed
event is supported.
You can implment a more custom billing model by modifying the billing module.
Configure Your Stripe Webhooks
-
Configure Stripe Dashboard
- Go to the Stripe Dashboard
- Add a new webhook endpoint with your API URL:
https://api.${DOMAIN_NAME}/checkout-webhook
- Copy the webhook signing secret
- Add it to your secrets as
StripeSecretKey
-
Configure your stripe product
- Go to the Stripe Dashboard
- Copy the price ID for your product
- Add it to your secrets as
StripePriceId
-
Enable Events
- Select the events you want to listen for
checkout.session.completed
-
Testing Webhooks
Deploy or start your API
Once you are satsified with the webhook deploy it to your production environment.
To learn more about Stripe webhooks click here
Clerk Webhooks
Clerk webhooks are also implemented in the control plane.
Preconfigured for you is a clerk webhook that will trigger when a user signs up.
This webhook will create a new user in the Database and create a new API key for them with Unkey.
Clerk webhooks are really extensible and go beyond just a trigger on signup.
Configure Your Clerk Webhooks
Set up webhook endpoint
- Go to the Webhooks page in Clerk Dashboard
- Select “Add Endpoint”
- Enter your endpoint URL
https://${stage}-api.${DOMAIN_NAME}/signup-webhook
- Select the
user.created
event which triggers when a new user registers - Create the endpoint
Add Signing Secret
- Copy the Signing Secret from your endpoint’s settings page
- Add it to your
.env.{stage}
file asClerkWebhookSecret
Test the webhook by creating a new user in the Clerk Dashboard.
- Create a JWT template in the clerk dashboard
- Login with a test user
- Generate a JWT token using the template via the console
This will return a JWT token that you can use to test the webhook that you can too env.test
where needed.
There are other methods to generate a JWT token for testing, but this is the most straightforward.
Learn more about Clerk JWT tokens here
Learn more about Clerk Webhooks here
Was this page helpful?