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_...'
Codes6 digits, 10 minutes, single use, 5 wrong tries end a code, 3 codes per email per 15 minutes
Session keyspols_..., 30 days; POST /api/auth/logout revokes one
API keyspol_live_..., from POST /api/keys; work wherever a session key works
Websitethe osec.one sign-in on this site works on the same routes

Routes

GET/api/public/policies/{id}.mdThe 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/consentsRecord 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/requestsA 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/templatesAll templates with their laws and [KEY] placeholders. /api/templates/{slug} for the text.
POST/api/authSign up / sign in with an email code; or swap an API key for a session key.
GET POST/api/projectsList / create projects. GET PUT DELETE /api/projects/{id}; POST /api/projects/{id}/consent-key rotates the key.
GET POST/api/policiesList (?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}/purposesConsent purposes (marketing_email, analytics ...): {key, label, wording, active}. PUT DELETE /api/purposes/{id}.
GET POST/api/projects/{id}/connectorsThe 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/requestsData 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-sitesSaved 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/themesPage themes. PUT DELETE /api/themes/{id}.
GET/api/consentsConsent records (?project_id, policy_id, purpose, subject). /api/consents.csv for a CSV file.
GET POST/api/keysLong-lived pol_live_ API keys (max 10, shown once). DELETE /api/keys/{id}.
GET DELETE/api/accountThe 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 -->
  1. The person gives their email; a 6-digit code goes to it (valid 30 minutes). Nothing runs until the code is right.
  2. Download: every export connector is called; the replies go into one zip, and a link valid for 7 days is emailed.
  3. Delete: the person confirms, and the delete connectors run after 7 days. The email has a cancel link until then.
  4. 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":{}}}'
authSign up or sign in (email → code → session key), or swap an API key.
list_templates / get_templateTemplates and their placeholders (no sign-in).
get_public_policyA published policy as readers see it (no sign-in).
check_trackersWhich outside services a web page loads, and which before consent (no sign-in).
tracker_policiesCookie and privacy policy markdown naming the services check_trackers found (no sign-in).
list_tracker_sites / save_tracker_site / delete_tracker_siteSaved sites, checked every month, an email on a new service.
list_projects / create_project / update_project / delete_projectProjects (one per website or app).
list_policies / get_policy / create_policy / update_policy / delete_policyPolicies; update_policy with is_active=true publishes.
create_policy_from_templateFill a template's placeholders and create the policy.
list_themes / create_theme / update_themePage themes: background colour or image, accent, font, width, dark/light.
list_purposes / create_purpose / update_purpose / delete_purposeConsent purposes and the exact wording people agree to.
list_consentsWho accepted which version or purpose, and when.
list_connectors / create_connector / update_connector / delete_connectorConnectors: the signed URLs called for each download or delete request (the secret is in the create reply only).
test_connectorSend a signed ping to a connector and show its reply.
list_requests / get_request / retry_requestData requests with their due dates; one request with each connector's result; run a failed one again.
get_account / create_api_keyThe account and long-lived keys.