{"uid":"cap_9zz12F7lu5XPhHT1Ng_54","slug":"agent402-sql-guard-b4d89e4c","name":"Agent402 SQL Guard","description":"Review a SQL statement before running it against production: a pass / warn / block verdict naming concrete risks (unbounded UPDATE or DELETE, tautological WHERE, DROP, TRUNCATE, statement stacking, privilege changes, catalog writes) and, on pass, an Ed25519 certificate bound to the statement's SHA-256 that a database layer can verify before executing. Use it as the last check between an agent and a destructive query.","url":"https://agent402.tools/api/sql-guard","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"sql":{"type":"string","description":"the exact statement you are about to execute"},"allow":{"type":"array","description":"risk ids to downgrade from block to warn (see riskCatalogue in the response)"},"ttlSeconds":{"type":"number","description":"certificate lifetime, 30-3600 (default 300)"},"allowMultiStatement":{"type":"boolean","description":"permit more than one statement in the submission (default false)"}}},"responseSchema":{"type":"json","example":{"risks":[],"sha256":"635cf20a…","verdict":"pass","mutating":true,"certificate":{"token":"eyJ2Ijox….signature","expiresAt":"2026-07-28T20:05:00Z"},"statementCount":1}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.004","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.004/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.004","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.004","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_9lGfiTrBoNPs4ixMluaXr","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.004","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Validates and risk-audits a SQL statement before execution, returning a signed certificate and verdict indicating whether the query is safe to run.","exampleAgentPrompt":"Before I run this query against the database, check if it's safe: SELECT * FROM users WHERE id = 42 — use a 5-minute certificate lifetime and flag any risks you find.","exampleUseCases":[{"title":"Guard agent-generated SQL before execution","prompt":"I'm about to let my AI agent run this SQL it generated — can you audit it for safety and give me a signed certificate I can attach to the execution request? The query is: DELETE FROM orders WHERE status = 'cancelled'"},{"title":"Enforce read-only SQL in a multi-tenant app","prompt":"Before running this query from a user submission, check it for any mutating or destructive operations and block it if it does anything other than SELECT — the SQL is: UPDATE accounts SET balance = 0 WHERE user_id = 99"},{"title":"Pre-approve a batch of analyst SQL queries","prompt":"I need to validate this SQL query before handing it off to the analytics pipeline — scan it for injection risks or missing WHERE clauses and give me a 10-minute certificate if it passes: SELECT revenue, region FROM sales WHERE quarter = 'Q1'"}],"resultDescription":"Returns a JSON object with a verdict ('pass', 'warn', or 'block'), a list of detected risks with IDs, a SHA-256 hash of the submitted statement, a flag indicating whether the statement is mutating, the count of statements detected, and a signed certificate token with an expiry timestamp that downstream systems can use to prove the SQL was pre-audited.","failureModes":["SQL contains multiple statements without allowMultiStatement=true → returns block verdict or error","High-risk operation (e.g. DROP, TRUNCATE) not in allow list → verdict='block'","Invalid or empty SQL string → validation error response","TTL outside 30–3600 range → parameter error","Payment not received or insufficient → x402 payment required response","Malformed JSON body → HTTP 400 bad request"],"whenToPreferThis":"Use this endpoint when an AI agent or application dynamically generates SQL and needs a security checkpoint before execution — especially to prevent injection attacks, accidental destructive queries, or unauthorized mutations. Prefer this over manual review when you need a machine-readable verdict and a cryptographically signed certificate to enforce pre-approval in downstream systems. Ideal for agentic pipelines where SQL is generated from natural language and must be audited before touching a production database.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T01:18:30.714Z","isFirstParty":false}