Policies
The rule and version objects
Section titled “The rule and version objects”{ "version": 3, "policyHash": "9b1c...", "rules": [ { "id": "no-alcohol", "text": "No ads showing alcoholic drinks, bars, or alcohol brands.", "lang": "en", "label": "Alcohol" }, { "id": "no-riba", "text": "لا إعلانات عن القروض بفائدة أو البطاقات الائتمانية.", "lang": "ar" } ], "note": "Added riba", "createdAt": "2026-10-27T10:00:00Z", "createdBy": "user:31"}| Rule field | Rules |
|---|---|
id | Required. [A-Za-z0-9_.-], 1 to 64 characters, unique in the policy. |
text | Required. 1 to 500 characters of natural language, English or Arabic. |
lang | Optional: en or ar. Display only. |
label | Optional display name, up to 60 characters. Display only. |
A policy has 1 to 20 rules. id and text decide the version and the policyHash; lang and label do not.
Get the current policy
Section titled “Get the current policy”Scope read:verdicts. The current version. 404 when the app has no policy yet (or does not exist).
curl -s https://api.ad80.dev/v1/apps/com.example.news/policy -H "Authorization: Bearer $AD80_API_KEY"Save a policy
Section titled “Save a policy”Scope write:policies. Body: rules (required) and note (optional, up to 200 characters).
curl -s -X PUT https://api.ad80.dev/v1/apps/com.example.news/policy \ -H "Authorization: Bearer $AD80_API_KEY" -H "Content-Type: application/json" \ -d '{ "note": "Initial policy", "rules": [ {"id": "no-alcohol", "text": "No ads showing alcoholic drinks, bars, or alcohol brands.", "lang": "en"}, {"id": "no-gambling", "text": "No ads for gambling: casinos, betting, lotteries or slot machines.", "lang": "en"} ] }'import os, requests
rules = [ {"id": "no-alcohol", "text": "No ads showing alcoholic drinks, bars, or alcohol brands.", "lang": "en"}, {"id": "no-dating", "text": "لا إعلانات عن تطبيقات أو خدمات المواعدة والتعارف العاطفي.", "lang": "ar"},]r = requests.put( "https://api.ad80.dev/v1/apps/com.example.news/policy", headers={"Authorization": f"Bearer {os.environ['AD80_API_KEY']}"}, json={"rules": rules, "note": "Initial policy"}, timeout=30,)r.raise_for_status()body = r.json()print("version", body["version"]["version"], "unchanged" if body["unchanged"] else "new")const res = await fetch('https://api.ad80.dev/v1/apps/com.example.news/policy', { method: 'PUT', headers: { Authorization: `Bearer ${process.env.AD80_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ note: 'Initial policy', rules: [{ id: 'no-alcohol', text: 'No ads showing alcoholic drinks, bars, or alcohol brands.', lang: 'en' }], }),});const body = await res.json();console.log(body.version.version, body.unchanged);Response:
{ "version": { "version": 4, "policyHash": "...", "rules": [ "..." ], "note": "Initial policy", "createdAt": "...", "createdBy": "key:ck_3" }, "unchanged": false, "rescore": { "creatives": 120, "classifications": 120, "remaining": 186, "allowed": true }}- Identical rules create no new version:
unchanged: trueand the current version. - On plans with SDK integration, saving re-scores the app’s SDK creatives seen in the last 7 days. This does not use manual classifications.
rescoreestimates how many manual classifications a draft test of the app’s recent creatives would use.- The first policy of an app counts toward the plan’s active-policy limit; beyond it, 403
entitlement: max_active_policies. - 400 explains any invalid rule (count, id, length, duplicate id, language, label).
List versions
Section titled “List versions”Scope read:verdicts. Every version, newest first: {"versions": [ ... ]}.
Estimate a draft test
Section titled “Estimate a draft test”Scope read:verdicts. Changes nothing. Body: rules (a draft) and sampleSize (1 to 200, the newest creatives of
the app).
curl -s -X POST https://api.ad80.dev/v1/apps/com.example.news/policy/estimate \ -H "Authorization: Bearer $AD80_API_KEY" -H "Content-Type: application/json" \ -d '{"sampleSize": 50, "rules": [{"id": "no-alcohol", "text": "No ads showing alcohol."}]}'{ "playground": { "creatives": 50, "classifications": 50, "remaining": 186, "allowed": true }, "rescore": { "creatives": 50, "classifications": 50, "remaining": 186, "allowed": true }}classifications is the number of manual classifications the run would use (creatives already scored with exactly
this draft are free); remaining is what is left this period (null = no fixed limit); allowed is false when
the run would exceed it.
Run a draft test
Section titled “Run a draft test”Scope write:policies. Same body as the estimate. Scores the draft against the newest sampleSize creatives, next
to their current verdicts. The draft never becomes the app’s policy or its verdicts. Each creative scored for the
draft uses one manual classification; when the allowance cannot cover the run: 403 entitlement. 503 when draft
testing is temporarily unavailable.
{ "runId": "...", "charged": 50, "remaining": 136, "currentVersion": 3, "rows": [ { "creativeId": "ad80px1:...", "width": 960, "height": 150, "imageUrl": "https://api.ad80.dev/v1/images/...", "current": { "state": "OK", "violates": false, "scores": [ "..." ], "policyVersion": 3 }, "draft": { "state": "OK", "violates": true, "scores": [ "..." ] } } ]}