Skip to main content

Webhooks

Receive Digia webhooks on your server: setup, headers, signature check and delivery.

Digia sends a webhook to your server when something happens in your project. All events use one URL and one signing secret.

EventSent whenPage
reward.wonA user wins a reward in a gamification campaignGamification: reward.won
submission.createdThe app sends a submission, such as a survey answerSurveys: submission.created

Set up​

In the dashboard, open Project settings → Webhook.

  1. Enter the HTTPS URL of your endpoint.
  2. Choose Copy next to the signing secret and store it on your server.
  3. Tick the events you want.
  4. Turn the webhook On and choose Save.

Request​

Digia sends a POST with a JSON body.

HeaderValue
Content-Typeapplication/json
X-Digia-EventThe event name, such as reward.won.
X-Digia-Delivery-IdA unique ID for the delivery.
X-Digia-TimestampWhen the request was signed, in Unix seconds.
X-Digia-SignatureThe signature, in lowercase hex.

Every event has the same body shape, so one handler with a switch on event covers them all.

{
"event": "reward.won",
"test": false,
"grant": { "grantId": "665f1c2e9a1b2c3d4e5f6a7b", "...": "..." },
"occurredAt": "2026-11-20T10:15:00.000Z"
}
FieldMeaning
eventThe event name. Same as the X-Digia-Event header.
testtrue when a dashboard test sent it. Don't give anything real for a test event.
occurredAtWhen it happened, in ISO 8601 UTC.
One object named after the eventThe event's data, such as grant or submission. It holds its own ID, such as grantId or submissionId.

Verify the signature​

Check the signature before you trust a request.

AlgorithmHMAC-SHA256
KeyThe signing secret, as a text string.
Signed text${timestamp}.${rawBody}: the X-Digia-Timestamp value, a dot, and the exact body bytes.

Sign the raw body, not a re-written copy. Reject a timestamp more than 5 minutes from your clock.

import crypto from 'node:crypto';
import express from 'express';

const app = express();
const SECRET = process.env.DIGIA_WEBHOOK_SECRET;
const seen = new Set(); // use your database in production

// express.raw keeps the body as bytes, which is what Digia signed.
app.post('/webhooks/digia', express.raw({ type: 'application/json' }), (req, res) => {
const timestamp = req.get('X-Digia-Timestamp') ?? '';
const signature = req.get('X-Digia-Signature') ?? '';
if (!/^\d+$/.test(timestamp) || Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) {
return res.sendStatus(400);
}

const expected = crypto
.createHmac('sha256', SECRET)
.update(`${timestamp}.`)
.update(req.body)
.digest('hex');
const given = Buffer.from(signature);
const wanted = Buffer.from(expected);
if (given.length !== wanted.length || !crypto.timingSafeEqual(given, wanted)) {
return res.sendStatus(401);
}

const deliveryId = req.get('X-Digia-Delivery-Id');
if (!seen.has(deliveryId)) {
const event = JSON.parse(req.body.toString('utf8'));
if (!event.test) {
// Handle event.event ("reward.won", "submission.created") here.
}
seen.add(deliveryId);
}
res.sendStatus(200);
});

app.listen(3000);

Delivery​

Reply with any 2xx status within 2 seconds. Save the event first and do slow work after you reply.

Digia retries failed deliveries for up to 38 hours. A retry can arrive twice or out of order, so make your endpoint idempotent: skip any X-Digia-Delivery-Id you already handled.

Test plays send reward.won with "test": true. Check it before you give anything real.