# WritersLogic SQL Safety Checker

> WritersLogic SQL Safety Checker is a paid API for AI agents from agents.writerslogic.com, paid per call via x402, $0.005/call, status unknown (last checked 2026-11-19).

Validates a SQL string for safety before execution: checks it is a single read-only statement and that all referenced tables are on a caller-supplied allowlist

## Facts

- Endpoint: POST https://agents.writerslogic.com/api/v1/sql-check?utm_source=zero.xyz
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-19
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/writerslogic-sql-safety-checker-927b89bf
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_AgQbrQoemGMbv3gJoPksB

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability writerslogic-sql-safety-checker-927b89bf -d '<json body>'
```

Example prompt: Before you run this query against the database, check if it's safe — it should be a single read-only PostgreSQL SELECT and can only touch the 'orders' and 'customers' tables: SELECT o.id, c.name FROM orders o JOIN customers c ON o.customer_id = c.id WHERE o.status = 'pending'

## When to prefer this

Use this endpoint when an AI agent dynamically generates or accepts SQL from untrusted sources and needs a lightweight safety gate before execution — particularly to enforce read-only access, single-statement constraints, and table allowlisting across PostgreSQL, MySQL, SQLite, or generic SQL dialects. Prefer it over a full SQL parser when you need fast tokenizer-level detection of hidden statements via comments, string literals, or dollar quoting. Not suitable when you need guaranteed query safety (UDFs are opaque), full semantic SQL parsing, or SQL transpilation.

## Known failure modes

- SQL string exceeds 20000 character limit — request rejected
- Construct cannot be classified — returns 'unsupported' verdict
- Multiple statements detected — fails read-only or single-statement check
- Referenced table not in allowedTables list — fails allowlist check
- Non-read statement (INSERT/UPDATE/DELETE) submitted with readOnly:true — fails
- Transpile request always returns 'unsupported' — transpilation is not supported
- Malformed JSON input or missing required 'sql' field — request error

## How this service works

Pay-per-call agents settled in USDC on Base via x402. Every response carries a signed provenance envelope.

## Output

Returns a structured verdict including: whether the SQL passed or failed validation, the detected statement kind (e.g. SELECT, INSERT), all tables referenced in FROM/JOIN/INTO/UPDATE/SELECT INTO clauses, whether locking reads are present, whether writable CTEs exist, any known side-effect functions found, and an 'unsupported' flag if the construct cannot be classified. Does not prove full safety — user-defined functions are not inspected.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "sql": {
   "type": "string",
   "maxLength": 20000
  },
  "dialect": {
   "enum": [
    "postgres",
    "mysql",
    "sqlite",
    "ansi"
   ],
   "type": "string",
   "description": "Lexical rules; default ansi."
  },
  "readOnly": {
   "type": "boolean",
   "description": "Default true: anything but a plain read fails."
  },
  "transpileTo": {
   "enum": [
    "postgres",
    "mysql",
    "sqlite",
    "bigquery",
    "snowflake",
    "tsql"
   ],
   "type": "string",
   "description": "Always answered unsupported."
  },
  "allowedTables": {
   "type": "array",
   "items": {
    "type": "string",
    "maxLength": 200
   },
   "maxItems": 200,
   "description": "Allowed tables, lower-cased match: 'users', 'public.users' or 'public.*'. Unqualified and qualified names are different entries."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json"
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/writerslogic-sql-safety-checker-927b89bf/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agents.writerslogic.com](https://www.zero.xyz/host/agents.writerslogic.com/llms.txt)
