Skip to main content

Reward Used Callback

The signed call your server makes to mark a Digia Engage gamification reward as used: the request, how to sign it, and the responses.

Call this API from your server when a user redeems a reward, for example when the coupon is applied at checkout. The reward then moves to Used on the user's rewards page. Tapping the reward button doesn't mark it used.

Get the grantId from the reward.won webhook or from the {{grantId}} placeholder in a reward link.

Request​

POST https://app.digia.tech/api/v1/engage/inbound/rewards/used

Call it from your server, never from the app.

HeaderValue
Content-Typeapplication/json
x-digia-project-idYour project's API key, from Project settings → API Key.
x-digia-timestampThe current Unix time in seconds.
x-digia-signatureThe signature, in lowercase hex.

Body:

{ "grantId": "665f1c2e9a1b2c3d4e5f6a7b", "usedAt": "2026-11-20T10:15:00.000Z" }
Field
grantIdRequired. The ID of the win.
usedAtOptional. ISO 8601 time. Defaults to now.

Signature​

Sign the call with your webhook signing secret, the same way as the webhook signature. You get the secret when you save a webhook in Project settings → Webhook.

AlgorithmHMAC-SHA256
KeyThe signing secret, as a text string.
Signed text${timestamp}.${rawBody}: the x-digia-timestamp value, a dot, and the exact body you send.

Build the body string once, sign it, and send that same string.

import crypto from 'node:crypto';

export async function markRewardUsed(grantId, usedAt = new Date()) {
const body = JSON.stringify({ grantId, usedAt: usedAt.toISOString() });
const timestamp = Math.floor(Date.now() / 1000);
const signature = crypto
.createHmac('sha256', process.env.DIGIA_WEBHOOK_SECRET)
.update(`${timestamp}.${body}`)
.digest('hex');

const response = await fetch('https://app.digia.tech/api/v1/engage/inbound/rewards/used', {
method: 'POST',
headers: {
'content-type': 'application/json',
'x-digia-project-id': process.env.DIGIA_PROJECT_API_KEY,
'x-digia-timestamp': String(timestamp),
'x-digia-signature': signature,
},
body,
});
if (!response.ok) throw new Error(`Digia answered ${response.status}`);
}

Responses​

StatusMeaning
200The reward is marked used. Repeat calls are safe.
400The body is invalid.
401Authentication failed. Check the API key, timestamp, secret and signature.
404No win with that grantId in your project.
500A Digia error. Try again.