HalalAdz Public API
Start in three steps
- In the dashboard open Settings → API keys and make a test key (
hz_test_…). Choose what it may do (its scopes). The key is shown once; keep it like a password. - Call the API with it: everything works, nothing real changes.
- When your integration works, make a live key (
hz_live_…) and switch.
curl https://api.halaladz.com/api/v1/me \
-H "Authorization: Bearer hz_test_1a2b3c4d_YOUR_SECRET"
Base URL and format
Base URL: https://api.halaladz.com/api/v1. JSON in, JSON out (Content-Type: application/json). The full machine-readable description is OpenAPI 3.1: https://api.halaladz.com/api/v1/openapi.json (no key needed).
- Money is always integer micros as a JSON string in the platform currency (BDT), for accounts in every country:
"1500000"= 1.50. A JSON number for money is refused. Accounts outside Bangladesh: wallets, prices and earnings are still BDT; a payout sent in another currency also carriespayoutCurrency,payoutAmountMicrosandfxRateE12(how many units of that currency one taka bought, × 1012, fixed when the payout was requested) — see Payouts. - Ids are numbers, times ISO-8601 UTC (convert them to your own time zone), days
YYYY-MM-DDbusiness days in Bangladesh time (Asia/Dhaka, UTC+6) for every account, wherever it is. - Lists take
?limit=1..200(default 50) and?cursor=, newest first, and answer{"items": [...], "nextCursor": 123 | null}. PassnextCursorback ascursor.
Keys: live and sandbox
Send the key as Authorization: Bearer <key> (or X-Api-Key: <key>). Only the key's prefix and a peppered hash are stored by HalalAdz.
| Key | What it does |
|---|---|
hz_live_… | Real campaigns, ads, wallet and reports. Every request goes through exactly the same checks as the dashboard: halal review, minimum budget, the profile check, the wallet. Write scopes on live keys only after HalalAdz turned them on, and each live key has a daily spend limit set by HalalAdz. |
hz_test_… | Sandbox. The same validation and the same human halal review run; campaigns are test campaigns paid with test money (never your wallet), shown only on your own places with Test ads on, never to real publishers. Reports and earnings answer zeros. Events of test campaigns go to your TEST endpoints. |
A key acts with the current role of the team member who made it, cut down to its scopes. If that member is removed, the key stops (401 key_owner_removed); if they become read-only, writes are refused.
Scopes
| Scope | Allows | Account |
|---|---|---|
reports:read | List campaigns, read reports | Advertiser |
campaigns:write | Create, quote, change budget and dates, launch, pause, resume and end campaigns | Advertiser |
creatives:write | Upload files and add creatives (they always go to halal review) | Advertiser |
conversions:write | Send server-to-server conversions (POST /v1/conversions) | Advertiser |
earnings:read | Earnings and payouts | Publisher |
GET /me
The key's account, kind, mode, scopes, role and rate limit.
curl https://api.halaladz.com/api/v1/me \
-H "Authorization: Bearer hz_test_1a2b3c4d_YOUR_SECRET"
{"accountId": 42, "accountKind": "advertiser", "mode": "test", "keyPrefix": "hz_test_1a2b3c4d", "scopes": ["campaigns:write", "reports:read"], "role": "owner", "rateLimitPerMinute": 60}
Rate limits
Per key, per minute: by default 120 requests for a live key, 60 for a test key. HalalAdz may change them; GET /me (rateLimitPerMinute) and X-RateLimit-Limit always show your current limit. Every answer carries:
| Header | Meaning |
|---|---|
X-RateLimit-Limit | Requests allowed in this minute |
X-RateLimit-Remaining | Requests left in this minute |
X-RateLimit-Reset | Seconds until the window starts again |
Over the limit you get 429 rate_limited with Retry-After: <seconds>. Wait that long, then retry.
Idempotency keys
Every POST, PATCH and DELETE must send Idempotency-Key: <1-200 letters, digits, _ . : -> (else 400 idempotency_key_required). The first answer is kept for 24 hours: a repeat with the same key and the same body gets the same answer with Idempotent-Replayed: true (a launch is never paid twice). The same key with another body is 422 idempotency_key_reused; while the first request still runs, 409 idempotency_in_progress. A 5xx answer frees the key so you can retry.
curl -X POST https://api.halaladz.com/api/v1/campaigns/123/launch \
-H "Authorization: Bearer $HZ_KEY" \
-H "Idempotency-Key: launch-order-7781" \
-H "Content-Type: application/json" \
-d '{"expectedTotalMicros": "300000000"}'
Errors
Every error is {"error": "<code>", "message": "...", "issues"?: [{"path", "message"}], "details"?: {...}}.
| Status | When |
|---|---|
400 validation_error | The body or query is wrong; issues lists every problem |
401 invalid_api_key | Missing, malformed, wrong or revoked key |
401 key_owner_removed | The member who made the key left the account |
403 insufficient_scope | The key lacks the scope |
403 forbidden | Wrong account kind for this endpoint, or the maker's role may not write |
403 campaign_write_off | A live key with write scopes while HalalAdz has not turned the campaign write API on for live keys |
403 spend_limit_reached | The live key's daily spend limit would be passed (details: limitMicros, usedMicros, remainingMicros) |
403 account_suspended | The account is not active |
404 not_found | Does not exist, or belongs to another account |
402 / 409 / 422 | A business rule: insufficient_funds, price_changed, invalid_status, no_creatives, below_min_budget, domain_blocked … |
429 rate_limited | Too many requests; see Retry-After |