{"slug":"sqlpermit-schemasure-com-v1-guard-sql-534a9a","title":"Decide whether an agent-authored PostgreSQL statement complies with an execution","host":"sqlpermit.schemasure.com","method":"POST","resource":"https://sqlpermit.schemasure.com/v1/guard/sql","category":"code","description":"Decide whether an agent-authored PostgreSQL statement complies with an execution policy, using PostgreSQL's own parser rather than pattern matching. Detects statement stacking, data-modifying CTEs, COPY PROGRAM, privilege changes, and dangerous functions that read as ordinary SELECTs. Returns reason","price_listed":0.01,"price_asked":0.01,"state":"answering","state_label":"Answering","checks_7d":1,"answered_7d":1,"latency_ms_median":1037,"reported_calls_30d":40,"reported_payers_30d":6,"networks":["eip155:8453"],"badge":"unverified","paid_checks_7d":0,"paid_ok_7d":0,"example_input":{"body":{"audience":"executor:acme-prod-01","dialect":"postgresql","issue_permit":true,"policy":{"allow_multi_statement":false,"allowed_functions":["count","sum","avg"],"allowed_schemas":["analytics"],"allowed_tables":["analytics.orders"],"max_rows":1000,"read_only":true},"sql":"SELECT id, total FROM analytics.orders ORDER BY created_at DESC LIMIT 100","target_pg_major":18},"bodyType":"json","method":"POST","type":"http"},"output_schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"input":{"additionalProperties":false,"properties":{"body":{"additionalProperties":false,"properties":{"audience":{"description":"Identity of the ONE executor the permit is for. Required when issue_permit is true. Wildcards are rejected.","type":"string"},"dialect":{"enum":["postgresql"],"type":"string"},"issue_permit":{"type":"boolean"},"policy":{"additionalProperties":false,"properties":{"allow_multi_statement":{"description":"Permit more than one statement in the input. Defaults to false.","type":"boolean"},"allow_returning":{"description":"Accept RETURNING on a permitted write without a warning.","type":"boolean"},"allow_row_locks":{"description":"Accept SELECT ... FOR UPDATE without a warning.","type":"boolean"},"allowed_functions":{"description":"Added to the built-in allowlist. Bare name, or schema.function to admit one of your own.","items":{"type":"string"},"type":"array"},"allowed_languages":{"description":"Permitted CREATE FUNCTION languages. Defaults to none.","items":{"type":"string"},"type":"array"},"allowed_schemas":{"description":"Schemas the statement may reference.","items":{"type":"string"},"type":"array"},"allowed_tables":{"description":"Permitted relations as schema.table, or a bare name to match an unqualified reference.","items":{"type":"string"},"type":"array"},"max_rows":{"description":"Row ceiling. Becomes a permit obligation the executor enforces.","minimum":1,"type":"integer"},"read_only":{"description":"Reject anything that can change data or schema, including writes reached through a CTE.","type":"boolean"},"statement_timeout_ms":{"description":"Timeout written into the permit obligations. Defaults to 30000.","minimum":1,"type":"integer"}},"type":"object"},"sql":{"maxLength":100000,"minLength":1,"type":"string"},"subject":{"description":"Opaque caller label recorded as the permit subject.","type":"string"},"target_pg_major":{"description":"Required. The PostgreSQL major the statement will run on. Only 18 is supported in v1: a permit issued under one grammar and verified against another is a parser differential.","enum":[18],"type":"integer"}},"required":["dialect","target_pg_major","sql"],"type":"object"},"bodyType":{"enum":["json","form-data","text"],"type":"string"},"method":{"enum":["POST"],"type":"string"},"type":{"const":"http","type":"string"}},"required":["type","method","bodyType","body"],"type":"object"},"output":{"properties":{"example":{"properties":{"confidence":{"type":"number"},"data_versions":{"type":"object"},"evidence":{"items":{"properties":{"code":{"description":"Stable reason code, e.g. DATA_MODIFYING_CTE.","type":"string"},"data":{"type":"object"},"detail":{"type":"string"},"disposition":{"enum":["block","warn","info"],"type":"string"},"severity":{"enum":["info","low","medium","high","critical"],"type":"string"},"source":{"type":"string"},"span":{"properties":{"end":{"type":"integer"},"start":{"type":"integer"}},"type":"object"}},"required":["code","severity","detail","disposition"],"type":"object"},"type":"array"},"ok":{"type":"boolean"},"policy_version":{"type":"string"},"request_hash":{"type":"string"},"result":{"properties":{"classification":{"enum":["read_only","write","ddl","mixed"],"type":"string"},"findings":{"items":{"properties":{"code":{"description":"Stable reason code, e.g. DATA_MODIFYING_CTE.","type":"string"},"data":{"type":"object"},"detail":{"type":"string"},"disposition":{"enum":["block","warn","info"],"type":"string"},"severity":{"enum":["info","low","medium","high","critical"],"type":"string"},"source":{"type":"string"},"span":{"properties":{"end":{"type":"integer"},"start":{"type":"integer"}},"type":"object"}},"required":["code","severity","detail","disposition"],"type":"object"},"type":"array"},"grammar":{"type":"string"},"normalized_sql":{"description":"Deparsed canonical statement. This, not your original text, is what a permit binds.","type":"string"},"obligations":{"properties":{"max_rows":{"type":["integer","null"]},"require_read_only_tx":{"type":"boolean"},"statement_timeout_ms":{"type":"integer"}},"required":["max_rows","statement_timeout_ms","require_read_only_tx"],"type":"object"},"permit":{"description":"Compact JWS. Present only when requested and the verdict is not block.","type":"string"},"permit_expires_at":{"type":"string"},"permit_kid":{"type":"string"},"policy_hash":{"type":"string"},"referenced_functions":{"items":{"type":"string"},"type":"array"},"referenced_schemas":{"items":{"type":"string"},"type":"array"},"referenced_tables":{"items":{"type":"string"},"type":"array"},"statement_count":{"type":"integer"},"statement_types":{"items":{"type":"string"},"type":"array"},"stmt_fingerprint":{"description":"ADVISORY ONLY — never authorize on this. libpg-query fingerprints discard literal constants, so 'WHERE id = 1' and 'WHERE id = 999999' share one fingerprint.","type":"string"},"stmt_hash":{"description":"BINDING. sha256 of normalized_sql. The executor recomputes this from the statement it is about to run.","type":"string"},"target_pg_major":{"type":"integer"}},"required":["statement_count","statement_types","referenced_schemas","referenced_tables","referenced_functions","classification","findings","normalized_sql","stmt_hash","stmt_fingerprint","policy_hash","grammar","target_pg_major","obligations"],"type":"object"},"risk_codes":{"items":{"type":"string"},"type":"array"},"verdict":{"enum":["pass","warn","block"],"type":"string"},"warnings":{"items":{"type":"string"},"type":"array"}},"required":["ok","verdict","confidence","risk_codes","evidence","result","policy_version","request_hash","data_versions","warnings"],"type":"object"},"type":{"type":"string"}},"required":["type"],"type":"object"}},"required":["input"],"type":"object"},"history":[{"day":"2026-09-24","reachable":true,"status":402,"valid_402":true,"asked_usdc":0.01,"price_match":true,"latency_ms":1037,"error":null}],"description_full":"Decide whether an agent-authored PostgreSQL statement complies with an execution policy, using PostgreSQL's own parser rather than pattern matching. Detects statement stacking, data-modifying CTEs, COPY PROGRAM, privilege changes, and dangerous functions that read as ordinary SELECTs. Returns reason codes and an optional short-lived signed permit bound to the exact normalized statement. Never connects to your database.","last_updated":"2026-09-24T07:39:16.308Z","schemes":["exact"]}