2 min read
Receive and enqueue
The webhook handler does the minimum and returns immediately.
app.post('/webhooks', express.raw({type:'*/*'}), async (req, res) => {
if (!verify(req.body, req.header('Credicorp-Signature'), SECRET))
return res.status(400).end();
await queue.push(req.body.toString()); // raw event
res.status(200).end();
});
Process from the queue
Workers parse, dedupe on the event id, and apply effects. If a worker fails, your queue retries — separate from Credicorp’s delivery retries.
Why this shape
It cleanly separates receipt (must be fast and reliable) from processing (can be slow, can fail, can retry). It is the most robust pattern for high-volume webhooks.
Frequently asked questions
Do I still need idempotency if I have a queue?
Yes. Credicorp may deliver an event twice, so two copies can enter your queue. Dedupe on the event id when you process. See idempotency.
Should I verify before or after enqueuing?
Before. Never let an unverified body into your system. Verify, then enqueue.
Funding for UK limited companies
Credicorp lends to your company, not to you personally — short-term working capital with no personal guarantee. See what your business could access.