Receiving Webhooks
Handle webhooks from Stripe, GitHub, or any service without dropping events or blocking the sender. Acknowledge immediately, process reliably with Queue and Functions.
Why Queue + Functions?
Webhook providers expect a fast response (usually within a few seconds). If you do heavy work in the request handler, you risk timeouts and retries. The recommended pattern:
- Respond 200 immediately — so the provider marks the delivery as successful
- Enqueue the payload — push to RocketStack Queue in the same request or right after
- Process in a Function — your handler runs async with automatic retries and dead-letter behavior
Result: You absorb traffic spikes, avoid duplicate work from retries, and get full observability (logs, errors, retry counts) for every webhook.
Flow
Webhook hits your endpoint
Stripe, GitHub, or any service sends HTTP POST to your URL.
Acknowledge immediately
Return 200 quickly so the provider does not retry or timeout.
Enqueue for processing
Push the payload to RocketStack Queue with one API call.
Function processes reliably
Your Function runs with retries, DLQ, and observability.
Example: Enqueue from your endpoint
Your app exposes a webhook URL. When a request arrives, respond with 200 and enqueue the body for your Function to process.
// Webhook endpoint: acknowledge fast, process async
// Use an existing queue with deliveryTarget (webhook or function). Then enqueue:
app.post('/api/webhook', async (req, res) => {
res.status(200).send('OK');
await fetch(`https://api.rocketstack.dev/queues/${process.env.ROCKETSTACK_QUEUE_ID}/messages`, {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + process.env.ROCKETSTACK_API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({ payload: req.body })
});
}); Replace fn_process_webhook with your deployed Function URL. The Queue API delivers the payload to that URL with retries and backoff.
Best practices
Respond within seconds
Return 200 before doing any heavy work so providers don’t retry.
Verify signatures
Validate webhook signatures (e.g. Stripe, GitHub) before enqueueing.
Idempotent handlers
Design your Function so retries don’t cause duplicate side effects.
Secure your endpoint
Use API keys or signed URLs so only the provider can call you.