Skip to content

Webhooks

Latch uses Stripe webhooks to keep subscription state in sync.

POST /api/v1/webhooks/stripe

This route uses Stripe signature verification instead of API keys.

Stripe eventLatch behavior
checkout.session.completedCreates or updates a subscription for the existing customerId stored in checkout metadata
customer.subscription.createdStores a new Stripe-backed subscription
customer.subscription.updatedUpdates subscription state and billing period
customer.subscription.deletedMarks a subscription cancelled
invoice.payment_failedMarks a subscription past_due
invoice.payment_succeededMarks a subscription active
customer.createdUpdates stored Stripe customer metadata
customer.updatedUpdates stored Stripe customer metadata

When you save your Stripe secret key in Settings > Stripe, Latch automatically creates a webhook endpoint in your Stripe account with the correct URL and events. No manual configuration needed.

Stripe can’t reach localhost, so automatic webhook creation is skipped. Use the Stripe CLI instead:

Terminal window
stripe listen --forward-to http://localhost:4000/api/v1/webhooks/stripe

Then either:

  • Set STRIPE_WEBHOOK_SECRET=whsec_... in your environment, or
  • Pass the signing secret when saving Stripe settings in the dashboard

If you prefer to create the webhook endpoint yourself in the Stripe Dashboard, select the events listed above and point the URL to https://your-api-domain/api/v1/webhooks/stripe. Pass the signing secret as webhookSecret when saving Stripe settings — Latch will skip automatic creation when a manual secret is provided.

Latch validates webhook signatures with the configured Stripe webhook secret.

It can use:

  • the environment-level webhook secret (STRIPE_WEBHOOK_SECRET)
  • the per-publication stored webhook secret (auto-created or manual)

Requests with missing or invalid signatures are rejected.

When Stripe is available, webhook events are queued and retried asynchronously. If queueing is unavailable, the route falls back to synchronous handling.

Stripe statusLatch status
activeactive
trialingtrialing
past_duepast_due
canceledcancelled
unpaidpast_due