HalalAdzDevelopers বাংলা · EN Go to dashboard
Docs menu

API

Webhooks

A webhook means HalalAdz sends a POST to your server's address when something happens — no need to keep asking.

Events

EventForWhendata
campaign.approvedAdvertiserThe halal review approved the whole campaigncampaignId, autoApproved?
campaign.rejectedAdvertiserThe halal review rejected the campaign (with the reason); the budget goes backcampaignId, reason
campaign.pausedAdvertiserA campaign was paused — by you, by HalalAdz, or because money ran outcampaignId, previousStatus
campaign.budget_spentAdvertiserA campaign used its whole budgetcampaignId, billing (payg | upfront)
creative.approvedAdvertiserA HalalAdz reviewer approved an adcreativeId, campaignId
creative.rejectedAdvertiserAn ad was rejected (with the reason)creativeId, campaignId, reason
campaign.goal_reachedAdvertiserA campaign delivered everything it bought and endedcampaignId
wallet.low_balanceAdvertiserThe balance is low, or a campaign paused for lack of moneycurrency, balanceMicros, pausedCampaignId?
payout.approvedPublisherA withdrawal was approvedpayoutId, currency, amountMicros
payout.sentPublisherThe money was sentpayoutId, currency, amountMicros, reference
earnings.finalisedPublisherA month's earnings are final (monthly statement)statementId, month, currency, netMicros
property.approvedPublisherA site, app or channel was approvedpropertyId
property.rejectedPublisherA site, app or channel was rejected (with the reason)propertyId, reason
report.daily_readyAdvertiser, publisherYesterday's report is ready — once a day, after 6:00 account timeday, timezone, reports
test.pingEveryoneYou 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.

JSON
{
  "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

  1. Dashboard → Settings → Webhooks → add an address.
  2. Choose the events, and "real events" or "test events only". At most 10 addresses per account.
  3. The signing secret (whsec_…) is shown only once — put it on your server right away.

The message

JSON
{
  "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" }
}
HeaderValue
X-HalalAdz-Signaturet=<unix seconds>,v1=<hex HMAC-SHA256(secret, "<t>.<raw body>")>
X-HalalAdz-EventThe event type, e.g. creative.rejected
X-HalalAdz-DeliveryThe 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.

JavaScript
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
<?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);
Python
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 "", 200

Answer 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 id to 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.