Verify webhook
Confirm a webhook is coming from Duplo
Validating webhook signature
An example of the verify hash header
header: {
'DP_HASH_VERIFY': '6F4B941015BC08D44FUAMCAJ.948249SJHE',
'DP-HASH-VERIFY': '6F4B941015BC08D44FUAMCAJ.948249SJHE',
'Content-Type': 'application/json'
}Responding to webhook request
Example
// In an Express or Express-like app:
app.post("/receive-webhook", (req, res) => {
// If you specified a verify hash, check for the signature
const verifyHash = process.env.DP_SECRET_HASH;
const signature = req.headers["DP_HASH_VERIFY"];
if (!signature || (signature !== verifyHash)) {
// This request isn't from Duplo; discard
res.status(401).end();
}
const payload = req.body;
// It's a good idea to log all received events.
log(payload);
// Do something (that doesn't take too long) with the payload
res.status(200).end()
});// In a Laravel-like app:
Route::post('/receive-webhook', function (\Illuminate\Http\Request $request) {
// If you specified a verify hash, check for the signature
$verifyHash = config('services.duplo.secret_hash');
$signature = $request->header('DP_HASH_VERIFY');
if (!$signature || ($signature !== $verifyHash)) {
// This request isn't from Duplo; discard
abort(401);
}
$payload = $request->all();
// It's a good idea to log all received events.
Log::info($payload);
// Do something (that doesn't take too long) with the payload
return response(200);
});We currently support the following event notifications.
Webhook Type
Description
Last updated