API and MCP server
Base URL https://policies.biz59.net/api. JSON in and out. Interactive reference: /api/docs. For agents: llms.txt.
Sign up with an email code
The same account as the website sign-in. A new email is signed up on the second call.
curl -X POST https://policies.biz59.net/api/auth -H 'Content-Type: application/json' -d '{"email":"you@example.com"}'
# {"otp_sent": true, "expires_in_seconds": 600, "next": "Call auth again with the same email and the 6-digit otp..."}
curl -X POST https://policies.biz59.net/api/auth -H 'Content-Type: application/json' -d '{"email":"you@example.com","otp":"123456"}'
# {"session_key": "pols_...", "token_type": "Bearer", "expires_at": "...", "new_account": true}
curl https://policies.biz59.net/api/projects -H 'Authorization: Bearer pols_...'| Codes | 6 digits, 10 minutes, single use, 5 wrong tries end a code, 3 codes per email per 15 minutes |
| Session keys | pols_..., 30 days; POST /api/auth/logout revokes one |
| API keys | pol_live_..., from POST /api/keys; work wherever a session key works |
| Website | the osec.one sign-in on this site works on the same routes |
Routes
| GET | /api/public/policies/{id}.md | The policy as raw markdown. No key. ?v=1.0 for an older version. |
| GET | /api/public/policies/{id} | The policy as JSON: markdown, version, theme, published versions. No key. |
| GET | /api/page?pageid={id} | The first version's route, unchanged (markdown is base64 when an appcode header is sent). |
| POST | /api/public/consents | Record accept / withdraw: {policy_id or purpose, subject, consent_key, action}. No sign-in; the project's consent key. |
| GET | /api/public/consents/status | ?policy_id&subject&consent_key → accepted, accepted_version, needs_accept. ?purpose= → granted; neither → every purpose. |
| GET | /api/public/purposes | ?consent_key → the project's active purposes (key, label, wording) for sign-up boxes and preference panels. |
| GET | /api/public/projects/{id} | What the hosted privacy page shows: the project's name, site, active purposes and connector count. No key. |
| POST | /api/public/requests | A person asks for a copy of their data or to be deleted: {project_id or consent_key, email, kind: export|delete|preferences}. A 6-digit code goes to the email; keep the token. |
| POST | /api/public/requests/{id}/verify | {token, code}. Export: the connectors run and a zip link (7 days) is emailed. Delete: waits for /confirm. Preferences: open for an hour. |
| POST | /api/public/requests/{id}/confirm | {token}. The delete runs after a 7-day grace period; the email has a cancel link. POST /cancel {token} stops it. |
| GET POST | /api/public/requests/{id}/preferences | ?token / {token, choices: {purpose: true|false}}. The person's purposes, subject sha256(email); only changes add rows. |
| POST | /api/public/tracker-check | {url} → the outside services the page loads (analytics, ad pixels, chat, embeds, consent tools) with account ids, before_consent yes|held|unknown, cookies set before any click, and rows for a cookie policy table. The page is opened in a headless browser for a few seconds with no clicks (method "browser"); when that can't run, its code is read (method "static"). No sign-in; 20 checks an hour per network. |
| POST | /api/public/tracker-check/policies | {site_url, services, honours_gpc?, does_not_sell?} (services from a tracker check) → cookie_policy and privacy_policy markdown with a row and a line per service, warnings and questions for the owner; the Global Privacy Control and no-sale lines go in only when those two are true. Save with POST /api/policies as drafts. No sign-in. |
| GET | /api/templates | All templates with their laws and [KEY] placeholders. /api/templates/{slug} for the text. |
| POST | /api/auth | Sign up / sign in with an email code; or swap an API key for a session key. |
| GET POST | /api/projects | List / create projects. GET PUT DELETE /api/projects/{id}; POST /api/projects/{id}/consent-key rotates the key. |
| GET POST | /api/policies | List (?project_id=) / create policies. GET PUT DELETE /api/policies/{id}. |
| POST | /api/policies/from-template | {project_id, template, values, publish} → a policy with the placeholders filled; missing_keys lists the rest. |
| GET POST | /api/projects/{id}/purposes | Consent purposes (marketing_email, analytics ...): {key, label, wording, active}. PUT DELETE /api/purposes/{id}. |
| GET POST | /api/projects/{id}/connectors | The URLs we call for data requests: {name, export_url, delete_url}; the secret is in the create reply only. PUT DELETE /api/connectors/{id}, POST /secret rotates, POST /test pings. |
| GET | /api/requests | Data requests to your projects with due dates (?project_id, status, kind, email). /api/requests.csv; POST /api/requests/{id}/retry after a failure. |
| GET POST | /api/tracker-sites | Saved sites for the tracker check: {url, services?, method?} (services from a check just run, or left out to check now). Each is checked again every month and you get an email when a service shows up that wasn't there before. POST /api/tracker-sites/{id}/check checks now (no email; new lists what's new); DELETE /api/tracker-sites/{id}. Up to 10. |
| GET POST | /api/themes | Page themes. PUT DELETE /api/themes/{id}. |
| GET | /api/consents | Consent records (?project_id, policy_id, purpose, subject). /api/consents.csv for a CSV file. |
| GET POST | /api/keys | Long-lived pol_live_ API keys (max 10, shown once). DELETE /api/keys/{id}. |
| GET DELETE | /api/account | The account. GET /api/account/export downloads everything; DELETE ?confirm=<email> erases it all. |
Privacy page, widget and connectors
Each project has a hosted page at /privacy/<project id>where people ask for a copy of their data, ask to be deleted, or change their email preferences. The widget adds a "Privacy choices" link to your footer that opens the same choices in a panel, and an unticked consent box for a sign-up form.
<script src="https://policies.biz59.net/privacy.js" data-project="<project id>"
data-consent-key="pol_ck_..." defer></script>
<div data-privacy-consent="marketing_email"></div> <!-- in the sign-up form -->- The person gives their email; a 6-digit code goes to it (valid 30 minutes). Nothing runs until the code is right.
- Download: every export connector is called; the replies go into one zip, and a link valid for 7 days is emailed.
- Delete: the person confirms, and the delete connectors run after 7 days. The email has a cancel link until then.
- Each request shows in the console (Data requests) with the date it is due: one month after it was made.
A connector is a URL in your app. The hub POSTs {"kind", "email", "request_id", "project_id"} with the header X-Policies-Signature: t=<unix>,v1=<hex>, where hex is HMAC-SHA256 of <t>.<body> with the connector's secret. Reject a bad signature or a tolder than 5 minutes. Answer an export with the person's data as JSON, a delete with counts, and {"kind":"ping"} with {"ok": true}.
import hashlib, hmac, time
def signed(secret: str, header: str, body: bytes) -> bool:
parts = dict(p.split("=", 1) for p in header.split(","))
if abs(time.time() - int(parts["t"])) > 300:
return False
want = hmac.new(secret.encode(), f"{parts['t']}.".encode() + body, hashlib.sha256).hexdigest()
return hmac.compare_digest(want, parts["v1"])Show a policy
Link to https://policies.biz59.net/page?pageid=<id>. Readers can switch dark and light and print. Add &theme=dark to open dark, &v=1.0 for an older version. To collect consent on the page itself, add &subject=<your user id>&ck=<consent key>: it shows an "I agree" button, asks again after a new version, and posts a POLICIES_CONSENT message to the opener or parent frame.
// render it yourself
const md = await fetch("https://policies.biz59.net/api/public/policies/<id>.md").then(r => r.text());MCP server
Streamable HTTP at https://policies.biz59.net/api/mcp (JSON-RPC 2.0, plain JSON replies). Sign in with the auth tool, then send the session key as a header. Function-calling schema for other agents: /api/mcp/schema.
{
"mcpServers": {
"policies": {
"type": "http",
"url": "https://policies.biz59.net/api/mcp",
"headers": { "Authorization": "Bearer pols_..." }
}
}
}curl -X POST https://policies.biz59.net/api/mcp -H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_templates","arguments":{}}}'| auth | Sign up or sign in (email → code → session key), or swap an API key. |
| list_templates / get_template | Templates and their placeholders (no sign-in). |
| get_public_policy | A published policy as readers see it (no sign-in). |
| check_trackers | Which outside services a web page loads, and which before consent (no sign-in). |
| tracker_policies | Cookie and privacy policy markdown naming the services check_trackers found (no sign-in). |
| list_tracker_sites / save_tracker_site / delete_tracker_site | Saved sites, checked every month, an email on a new service. |
| list_projects / create_project / update_project / delete_project | Projects (one per website or app). |
| list_policies / get_policy / create_policy / update_policy / delete_policy | Policies; update_policy with is_active=true publishes. |
| create_policy_from_template | Fill a template's placeholders and create the policy. |
| list_themes / create_theme / update_theme | Page themes: background colour or image, accent, font, width, dark/light. |
| list_purposes / create_purpose / update_purpose / delete_purpose | Consent purposes and the exact wording people agree to. |
| list_consents | Who accepted which version or purpose, and when. |
| list_connectors / create_connector / update_connector / delete_connector | Connectors: the signed URLs called for each download or delete request (the secret is in the create reply only). |
| test_connector | Send a signed ping to a connector and show its reply. |
| list_requests / get_request / retry_request | Data requests with their due dates; one request with each connector's result; run a failed one again. |
| get_account / create_api_key | The account and long-lived keys. |