API
Webhooks
A webhook means HalalAdz sends a POST to your server's address when something happens — no need to keep asking.
Events
| Event | For | When | data |
|---|---|---|---|
campaign.approved | Advertiser | The halal review approved the whole campaign | campaignId, autoApproved? |
campaign.rejected | Advertiser | The halal review rejected the campaign (with the reason); the budget goes back | campaignId, reason |
campaign.paused | Advertiser | A campaign was paused — by you, by HalalAdz, or because money ran out | campaignId, previousStatus |
campaign.budget_spent | Advertiser | A campaign used its whole budget | campaignId, billing (payg | upfront) |
creative.approved | Advertiser | A HalalAdz reviewer approved an ad | creativeId, campaignId |
creative.rejected | Advertiser | An ad was rejected (with the reason) | creativeId, campaignId, reason |
campaign.goal_reached | Advertiser | A campaign delivered everything it bought and ended | campaignId |
wallet.low_balance | Advertiser | The balance is low, or a campaign paused for lack of money | currency, balanceMicros, pausedCampaignId? |
payout.approved | Publisher | A withdrawal was approved | payoutId, currency, amountMicros |
payout.sent | Publisher | The money was sent | payoutId, currency, amountMicros, reference |
earnings.finalised | Publisher | A month's earnings are final (monthly statement) | statementId, month, currency, netMicros |
property.approved | Publisher | A site, app or channel was approved | propertyId |
property.rejected | Publisher | A site, app or channel was rejected (with the reason) | propertyId, reason |
report.daily_ready | Advertiser, publisher | Yesterday's report is ready — once a day, after 6:00 account time | day, timezone, reports |
test.ping | Everyone | You pressed "Send a test message" | message, endpointId |
Campaign events
campaign.paused comes however it was paused — API, dashboard, HalalAdz, or money running out. campaign.budget_spent comes when a pay-as-you-go campaign has used its whole budget, or an upfront campaign has delivered everything it paid for. Their ids are stable (evt_ce…), so one event never reaches one address twice. Events of test campaigns go only to test addresses, with "livemode": false.
Daily report ready
report.daily_ready comes once a day, when the account's local time passes 6:00 and yesterday's numbers are final (advertisers: the account's time zone; publishers: Bangladesh time). Its id is always evt_rdr_<account>_<day> — so one day's event never comes twice, and a missed run is caught up later. data.reports holds the Reports API paths to call.
{
"id": "evt_rdr_42_2026-12-04",
"type": "report.daily_ready",
"created": "2026-12-05T00:07:12.000Z",
"livemode": true,
"accountId": 42,
"data": {
"day": "2026-12-04",
"timezone": "Asia/Dhaka",
"reports": { "campaigns": "/api/v1/reports/campaigns?from=2026-12-04&to=2026-12-04" }
}
}Adding an address
- Dashboard → Settings → Webhooks → add an address.
- Choose the events, and "real events" or "test events only". At most 10 addresses per account.
- The signing secret (
whsec_…) is shown only once — put it on your server right away.
The message
{
"id": "evt_n918273",
"type": "creative.rejected",
"created": "2026-12-05T08:15:02.000Z",
"livemode": true,
"accountId": 42,
"data": { "creativeId": 5521, "campaignId": 123, "reason": "Picture not allowed" }
}| Header | Value |
|---|---|
X-HalalAdz-Signature | t=<unix seconds>,v1=<hex HMAC-SHA256(secret, "<t>.<raw body>")> |
X-HalalAdz-Event | The event type, e.g. creative.rejected |
X-HalalAdz-Delivery | The event id (same as body.id) |
Check the signature
Compute the HMAC-SHA256 of <t>.<raw body> with your secret, compare it with v1 in constant time, and refuse a timestamp older than 5 minutes. Always use the raw body bytes, not re-encoded JSON.
import crypto from "node:crypto";
import express from "express";
const app = express();
const secret = process.env.HALALADZ_WEBHOOK_SECRET; // whsec_...
// Check the RAW body, before any JSON parsing.
app.post("/halaladz/webhook", express.raw({ type: "application/json" }), (req, res) => {
const parts = Object.fromEntries((req.get("X-HalalAdz-Signature") || "").split(",").map((p) => p.split("=", 2)));
const t = Number(parts.t);
if (!t || !parts.v1 || Math.abs(Date.now() / 1000 - t) > 300) return res.sendStatus(400);
const want = crypto.createHmac("sha256", secret).update(`${t}.${req.body}`).digest();
const got = Buffer.from(parts.v1, "hex");
if (got.length !== want.length || !crypto.timingSafeEqual(got, want)) return res.sendStatus(400);
const event = JSON.parse(req.body.toString("utf8"));
// event.id: skip an event you already handled (a retry repeats it)
res.sendStatus(200); // answer fast, do slow work afterwards
});<?php
$secret = getenv('HALALADZ_WEBHOOK_SECRET'); // whsec_...
$body = file_get_contents('php://input');
$parts = [];
foreach (explode(',', $_SERVER['HTTP_X_HALALADZ_SIGNATURE'] ?? '') as $p) {
[$k, $v] = array_pad(explode('=', $p, 2), 2, '');
$parts[$k] = $v;
}
$t = (int) ($parts['t'] ?? 0);
if (!$t || abs(time() - $t) > 300) { http_response_code(400); exit; }
$want = hash_hmac('sha256', $t . '.' . $body, $secret);
if (!hash_equals($want, $parts['v1'] ?? '')) { http_response_code(400); exit; }
$event = json_decode($body, true);
http_response_code(200);import hashlib, hmac, os, time
from flask import Flask, request, abort
app = Flask(__name__)
SECRET = os.environ["HALALADZ_WEBHOOK_SECRET"].encode() # whsec_...
@app.post("/halaladz/webhook")
def halaladz_webhook():
raw = request.get_data() # the raw body bytes
parts = dict(p.split("=", 1) for p in request.headers.get("X-HalalAdz-Signature", "").split(",") if "=" in p)
t = int(parts.get("t", "0") or 0)
if not t or abs(time.time() - t) > 300:
abort(400)
want = hmac.new(SECRET, f"{t}.".encode() + raw, hashlib.sha256).hexdigest()
if not hmac.compare_digest(want, parts.get("v1", "")):
abort(400)
event = request.get_json()
return "", 200Answer and retries
- Answer with any 2xx within 10 seconds; do slow work afterwards.
- Anything else (timeout, network error, a redirect) is retried: 1 minute, 2, 4, 8 … at most 6 hours apart.
- After 8 tries the message goes to the "not delivered" list; fix your server and press "Send again".
- A retry repeats the event: use
idto skip one you already handled.
Security
- Public https addresses on the default port only. IP addresses, localhost and internal network names are refused — checked when you save and again at every send.
- "New secret" makes a new secret and the old one stops at once — update your server right away.