Docs
API reference
Version 1. Two endpoints. JSON in, JSON out. Bearer token auth.
Base URL: https://api.zerwone.com
POST /v1/verify
Rebuilds the schema in a sandbox, tests access, writes a fix and tests again. Runs take seconds to a few minutes; set a client timeout of 10 minutes.
Request body
| Field | Type | Meaning |
|---|---|---|
| format | string | Always zerwone.verify-request.v1. |
| request_id | string | Your id for this run. Returned unchanged. |
| schema | object | The schema export (zerwone.schema-export.v1): tables, policies, views, functions. At most 30 tables per request. |
| app_description | string, optional | One sentence on what the app should allow. Strongly recommended: it decides what is a leak. |
| confirmed_guards | string[], optional | Check ids the owner confirmed as intended access, from a previous result. |
| rule_checks | boolean, optional | Default true. Adds fixed checks that do not depend on a model. |
{
"format": "zerwone.verify-request.v1",
"request_id": "chat-app-0001",
"app_description": "Recipients should be able to see messages sent to them; only the sender should be able to edit a message's text.",
"confirmed_guards": [],
"schema": {
"format": "zerwone.schema-export.v1",
"tables": [ /* 1 table */ ],
"policies": [ /* 3 policies */ ],
"views": [],
"functions": []
}
}Response body
| Field | Type | Meaning |
|---|---|---|
| format | string | zerwone.verify-result.v1 |
| request_id | string | Your request_id. |
| model | string | The model that wrote the checks and the fix. |
| findings | object[] | One per leak: title, severity (critical for anonymous access, otherwise high), location, check_ids. |
| checks | object[] | Every check: id, role, sql, expect, category before the fix, passes_after, intent_dependent, rule. |
| migration.sql | string | null | The fix. Only access changes: row level security, policies, grants, view and function security settings. |
| migration.ran_clean | boolean | Every statement ran without error on the copy. |
| migration.rounds | number | How many tries the fix took (at most 3). |
| migration.errors | string[] | Statements that failed or were out of scope, and places where the copy differs from your database. |
{
"format": "zerwone.verify-result.v1",
"request_id": "chat-app-0001",
"findings": [
{
"title": "recipient bob cannot edit alice's message",
"severity": "high",
"location": "public.messages",
"check_ids": [
"c_1e1c855edcf3"
]
}
],
"checks": [
{
"id": "c_1e1c855edcf3",
"role": "user_b",
"expect": "denied",
"category": "leak",
"description": "recipient bob cannot edit alice's message",
"passes_after": true
},
{
"id": "c_47f5a21275cc",
"role": "user_b",
"expect": "denied",
"category": "leak",
"description": "bob cannot reassign alice's message to himself",
"passes_after": true
},
{
"id": "c_e5f98d289d27",
"role": "user_b",
"expect": "denied",
"category": "leak",
"description": "[rule] bob as recipient_id cannot rewrite body of alice's messages row",
"passes_after": true
},
{
"id": "c_066f5ee46e2b",
"role": "user_a",
"expect": "allowed",
"category": "guard",
"description": "alice reads messages she sent or received",
"passes_after": true
},
"... 14 more checks"
],
"migration": {
"sql": "-- 1. anon has no business touching this table.\nrevoke all on table \"public\".\"messages\" from anon;\n\n-- 2. Only the sender may update a message. Replace the participants-update\n-- policy with a sender-only one, and pin sender_id in WITH CHECK so a\n-- sender cannot hand the row to someone else.\ndrop policy \"participants update\" on \"public\".\"messages\";\n\ncreate policy \"sender updates\" on \"public\".\"messages\"\n as permissive for update to \"authenticated\"\n using (((select auth.uid()) = sender_id))\n with check (((select auth.uid()) = sender_id));",
"ran_clean": true,
"rounds": 1,
"errors": []
}
}Check categories
| Field | Type | Meaning |
|---|---|---|
| leak | expect denied, but allowed before the fix | A hole. passes_after true means it closed. |
| guard | expect allowed, and allowed before the fix | Access the app needs. passes_after true means the fix kept it. |
| blocked | expect allowed, but denied before the fix | A feature that does not work today. Reported, not fixed. |
| ok | expect denied, and denied before the fix | Already safe. Must stay safe after the fix. |
Roles
user_a and user_b are two signed-in users (Alice and Bob), anon is a visitor with the public key, service_role bypasses row level security and is only used to observe.
GET /healthz
No auth. Returns {"ok": true} when the service is up.