Skip to content

Policies

{
"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 fieldRules
idRequired. [A-Za-z0-9_.-], 1 to 64 characters, unique in the policy.
textRequired. 1 to 500 characters of natural language, English or Arabic.
langOptional: en or ar. Display only.
labelOptional 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 /v1/apps/{appId}/policy

Scope read:verdicts. The current version. 404 when the app has no policy yet (or does not exist).

Terminal window
curl -s https://api.ad80.dev/v1/apps/com.example.news/policy -H "Authorization: Bearer $AD80_API_KEY"
PUT /v1/apps/{appId}/policy

Scope write:policies. Body: rules (required) and note (optional, up to 200 characters).

Terminal window
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"}
]
}'

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: true and 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.
  • rescore estimates 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).
GET /v1/apps/{appId}/policy/versions

Scope read:verdicts. Every version, newest first: {"versions": [ ... ]}.

POST /v1/apps/{appId}/policy/estimate

Scope read:verdicts. Changes nothing. Body: rules (a draft) and sampleSize (1 to 200, the newest creatives of the app).

Terminal window
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.

POST /v1/apps/{appId}/policy/playground

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": [ "..." ] }
}
]
}