{"uid":"cap_AgQbrQoemGMbv3gJoPksB","slug":"writerslogic-sql-safety-checker-927b89bf","name":"WritersLogic SQL Safety Checker","description":"Pay-per-call agents settled in USDC on Base via x402. Every response carries a signed provenance envelope.","url":"https://agents.writerslogic.com/api/v1/sql-check?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"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."}}},"responseSchema":{"type":"json"},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.005","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.005/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.005","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.005","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_5vycZdD01GMTMP8G567wX","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.005","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"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","exampleAgentPrompt":"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'","exampleUseCases":[{"title":"Guard agent-generated database queries","prompt":"I'm letting an AI agent generate SQL to answer user questions, but before it executes anything I need you to verify each query is a single read-only SELECT in PostgreSQL dialect and only touches these tables: users, sessions, events. Here's the query to check: SELECT user_id, COUNT(*) FROM events WHERE created_at > NOW() - INTERVAL '7 days' GROUP BY user_id"},{"title":"Detect multi-statement SQL injection attempt","prompt":"Can you check this SQLite query a user submitted through our API? I need to know if it's a single statement and doesn't do anything except read — allowed tables are products and categories: SELECT * FROM products; DROP TABLE products;"},{"title":"Audit MySQL query for writable CTEs or locking reads","prompt":"Before my pipeline runs this MySQL query, check whether it has any writable CTEs, locking reads, or side-effect functions — it should be read-only and only allowed to access the reports and report_items tables: WITH ranked AS (SELECT * FROM reports WHERE year = 2024) SELECT * FROM ranked JOIN report_items ON ranked.id = report_items.report_id FOR UPDATE"}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-11-19T12:35:06.900Z","isFirstParty":false,"canonicalSlug":"writerslogic-sql-safety-checker-927b89bf"}