Start
Keys and security
A key lets your software read your HalalAdz account's reports and (with the scope) run campaigns. Keep it secret like a password.
Two kinds of keys
| Key | What it does | Who can make it |
|---|---|---|
Test hz_test_… | For trying things out. Campaigns are test campaigns — test money only, shown only on your own test places; no real money moves and reports have no rows. | The account's owner or an admin |
Live hz_live_… | Works on your real account, with exactly the same rules as the dashboard. | Only the account owner — or a HalalAdz admin at the owner's request |
Send the key in a header: Authorization: Bearer <key> (or X-Api-Key: <key>). Every answer carries X-HalalAdz-Mode: live|test.
curl https://api.halaladz.com/api/v1/me -H "Authorization: Bearer $HALALADZ_KEY"const res = await fetch("https://api.halaladz.com/api/v1/me", { headers: { Authorization: `Bearer ${process.env.HALALADZ_KEY}` } });
console.log(await res.json(), res.headers.get("X-RateLimit-Remaining"));<?php
$ch = curl_init('https://api.halaladz.com/api/v1/me');
curl_setopt_array($ch, [CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('HALALADZ_KEY')], CURLOPT_RETURNTRANSFER => true]);
print_r(json_decode(curl_exec($ch), true));import os
import requests
r = requests.get("https://api.halaladz.com/api/v1/me", headers={"Authorization": f"Bearer {os.environ['HALALADZ_KEY']}"}, timeout=30)
print(r.json(), r.headers.get("X-RateLimit-Remaining"))Making a key
- Dashboard → Settings → API keys → "Make a new key".
- Give it a name (e.g. "Shop server"), choose the kind (test or live) and, if you like, the IP addresses it may be used from.
- The full key is shown only once. Copy it into your server's secret settings. If you lose it, stop it and make a new one.
At most 20 keys can be on at once. The list shows each key's name, kind, scopes, who made it, and when and from which country it was last used. An agency acting for a client cannot make a live key — the client account's owner makes it.
Scopes
| Scope | Allows | Account | When |
|---|---|---|---|
read | Read only: see reports and lists (every read request of the account kind) | Advertiser, publisher | Now |
conversions:write | Send sales and leads from your server (order tracking guide) | Advertiser | Now |
campaigns:write | Create campaigns, change budget and dates, launch, pause, resume, end (Campaign API) | Advertiser | Now: always on test keys; on live keys once HalalAdz turns it on |
creatives:write | Upload pictures / videos and add ads (each goes to human halal review) | Advertiser | Now: always on test keys; on live keys once HalalAdz turns it on |
Choose the scopes when you make a key. The campaign scopes (campaigns:write, creatives:write) can always go on a test key; on a live key only after HalalAdz turned them on for live keys — before that 422 campaign_write_off. Publisher keys can only read. Keys made earlier keep their scopes and keep working (reports:read / earnings:read are now covered by read).
Daily spend limit (live keys)
Every live key with the campaign scopes has a daily spend limit set by HalalAdz (0 at first = no campaign can be launched until a limit is set). If the budgets launched with this key today plus the new one go over it, you get 403 spend_limit_reached before any money moves. Settings → API keys shows the limit and today's spend. Test keys have no daily limit (test money only). Details.
IP allowlist
Optionally a key works only from certain addresses: up to 20 IPv4 or IPv6 addresses or ranges (e.g. 203.0.113.7 or 198.51.100.0/24). A call from anywhere else gets 403 ip_not_allowed. Empty = any address. Settings → API keys → "Allowed addresses"; only the owner can change a live key's list.
Call log
Every call of every key is kept for 90 days: what was called, the result (status), the time and how many milliseconds it took — never what was sent, never the caller's IP. Settings → API keys → "Calls".
Who a key acts as
A key acts with the current role of the member who made it, cut down to its scopes. If that member leaves the team, the key stops (401 key_owner_removed).
Stopping a key
Settings → API keys → "Stop key". It stops at once; software still using it gets 401 invalid_api_key. Stop a key right away if it leaked or went to the wrong place. HalalAdz may also stop a key it sees misused or leaked — you then get a notice with the reason.
Keeping keys safe
- Keep keys on your server only — never in a web page, a mobile app or a public code repository.
- Store them in environment variables or a secrets store; never write a key to a log.
- If your server's address is fixed, set the IP allowlist — a leaked key then works nowhere else.
- Make one key per piece of software, so stopping one leaves the others running.
- To rotate: make a new key → put it in your software → stop the old one.
- HalalAdz never stores the full key: only its prefix and a peppered hash. Our logs blank out the Authorization header.