Recipe

Receive your first webhook

Go from nothing to a verified webhook in four steps: expose an HTTPS endpoint, register it, verify the Credicorp-Signature, and return 200. This recipe wires the minimum handler you can build on.

2 min read

4 stepsEnd to end
200Acknowledge fast
HMACVerify first

1. Expose an HTTPS endpoint

Any framework works. The handler must read the raw body before parsing — you need the exact bytes to verify the signature (see signature verification).

app.post('/credicorp/webhooks', express.raw({type:'*/*'}), (req, res) => {
  const sig = req.header('Credicorp-Signature');
  if (!verify(req.body, sig, process.env.WHSEC)) return res.status(400).end();
  const evt = JSON.parse(req.body);
  enqueue(evt);            // do real work async
  res.status(200).end();   // acknowledge within 10s
});

2. Register it

Register the URL and subscribe to the events you care about. See Register a webhook endpoint. Store the returned whsec_ secret in your environment.

3. Verify every delivery

Recompute the HMAC over {t}.{rawbody} and compare in constant time, rejecting anything older than the 300-second tolerance.

4. Acknowledge fast

Return 200 immediately and process asynchronously so you never trip the 10-second timeout.

Frequently asked questions

Do I need a public URL to test?

For a real delivery, yes — but you can tunnel a local server. See Test a webhook locally.

What if I subscribe to the wrong events?

Edit the endpoint’s enabled_events at any time. Changes apply to future deliveries.

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.