Webhook Handling
Webhooks allow Cortado to receive data from external services like Stripe, Lemon Squeezy, or Slack. When something happens—such as a user making a purchase or submitting a form—a webhook sends a request to your server with event data. In this guide, you’ll learn how to set up a route in Cortado to catch these incoming events, validate their authenticity, and trigger backend workflows. Webhooks are essential for automation, real-time responses, and keeping your app in sync with third-party platforms.
Intermediate
14 min
Step 1: Understand Webhook Flow
A webhook is an HTTP POST request sent from a third-party service to your backend when an event occurs. Here’s how it works:
You register a route (e.g.
/webhooks/stripe
) with a third-party serviceWhen an event is triggered (like "invoice paid"), the service sends JSON payload to your route
Your server receives it, verifies it (using secret keys or signatures), and processes the event
You can update databases, send emails, unlock content, or trigger other workflows
It’s a passive but powerful system: your backend reacts only when needed.
Step 2: Plan Your Webhook Endpoint
To build a clean webhook system, consider the following:
Endpoint Naming: Use clear paths like
/webhooks/stripe
or/webhooks/squeezy
Payload Format: Know what structure each service sends (headers + body)
Verification: Always validate the request (HMAC, signature headers, secrets)
Idempotency: Avoid duplicate processing—track event IDs or timestamps
Event Mapping: Plan which events trigger which actions in your app
This structured approach ensures your webhook system is secure, scalable, and testable.
Step 3: Common Event Handling Table
For each service, understand the event types and what actions should happen inside Cortado. You can route different webhook types to different internal workflows or queue them for later processing.
Common Webhook Scenarios
When building webhook integrations, it's important to clearly define how your backend should respond to different types of events. For example, when Stripe sends an invoice.paid
event, your backend might unlock premium content or activate a subscription. If Lemon Squeezy triggers an order_created
event, Cortado could grant access to a product or send a welcome email. Similarly, FramerAuth may notify you when a user signs up, prompting you to create their profile in your system. Thinking through these flows helps you build robust, automated backend behavior that reacts in real time to external systems.
Last updated on
Aug 9, 2025