SQL execution certificate verify

FREE with proof-of-work · or $0.001 in USDC · POST /api/sql-cert-verify

Verify an Ed25519 execution certificate against the exact SQL statement you are about to run - the gate your database layer calls before it obeys an agent. Send POST /api/sql-cert-verify with the required fields sql and certificate and pay $0.001 per call over x402 or MPP, or call it free by solving a proof-of-work challenge. It returns a JSON object with valid, reason and payload.

Checks the signature, the certificate version, the expiry, and that the statement's SHA-256 matches the one certified, so a certificate for a different (or edited) statement is rejected. Returns { valid, reason, payload } and never throws on a malformed token, so the executor always gets one uniform answer. Pass publicKey to verify a certificate issued by another deployment; omit it to use this one's.

Category: Validation & parsing · Tags: sql postgres certificate verify ed25519 firewall safety database

TRY IN PLAYGROUND →

Parameters

NameTypeRequiredDescription
sqlstringyesthe exact statement the certificate should cover
certificatestringyesthe token from sql-guard (payload.signature)
publicKeystringnoPEM public key of the issuer (default: this deployment's)

Example request

curl -i -X POST https://agent402.tools/api/sql-cert-verify \
  -H "Content-Type: application/json" \
  -d '{"sql":"UPDATE users SET plan = '\''pro'\'' WHERE id = 42","certificate":"eyJ2IjoxLCJzaGEyNTYiOiI2MzVjZjIwYTdhMzM3NzFjOGJiZjY3OTljOTJlNTdkOTRiNGY0MmFjMTYzMzkyMTg3MTg1Zjc5OWE4OGFjYTAyIiwidmVyZGljdCI6InBhc3MiLCJwb2xpY3kiOiI1MzljNzhjZDhiZTZjMzUwIiwiaWF0IjoxNzg1MDAwMDAwLCJleHAiOjQwNzA5MDg4MDB9.iOLcl81N_N2-b3Tq1YdLCbRkmgQB8fWG9TA0oRQG81CgXtLrvBi4dsk6Oww-FR3mWqtDmLxT0TZLbDxbBo5dBw","publicKey":"-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEA+dgN+1FKr9VoA3fbT4bimUF4W8ORBYKwR6XiZldGxgw=\n-----END PUBLIC KEY-----\n"}'

Without payment this returns HTTP 402 Payment Required with the exact price for sql-cert-verify; any x402 v2 or MPP client pays it and retries.

Example response

{
  "valid": true,
  "reason": null,
  "payload": {
    "v": 1,
    "verdict": "pass",
    "sha256": "635cf20a…",
    "exp": 4070908800
  }
}
FieldTypeAlways presentIn the example
validbooleanyestrue
reasonnullnonull
payloadobjectyes4 fields: v, verdict, sha256, exp

From an MCP client

catalog.call {
  "slug": "sql-cert-verify",
  "params": {
    "sql": "UPDATE users SET plan = 'pro' WHERE id = 42",
    "certificate": "eyJ2IjoxLCJzaGEyNTYiOiI2MzVjZjIwYTdhMzM3NzFjOGJiZjY3OTljOTJlNTdkOTRiNGY0MmFjMTYzMzkyMTg3MTg1Zjc5OWE4OGFjYTAyIiwidmVyZGljdCI6InBhc3MiLCJwb2xpY3kiOiI1MzljNzhjZDhiZTZjMzUwIiwiaWF0IjoxNzg1MDAwMDAwLCJleHAiOjQwNzA5MDg4MDB9.iOLcl81N_N2-b3Tq1YdLCbRkmgQB8fWG9TA0oRQG81CgXtLrvBi4dsk6Oww-FR3mWqtDmLxT0TZLbDxbBo5dBw",
    "publicKey": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEA+dgN+1FKr9VoA3fbT4bimUF4W8ORBYKwR6XiZldGxgw=\n-----END PUBLIC KEY-----\n"
  }
}

On the hosted connector at https://agent402.tools/mcp, catalog.call runs sql-cert-verify free (rate-limited, no wallet). Local install: npx -y agent402-mcp.

Errors and behavior

Paid call (JavaScript agent)

import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
client.setSpendControls?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/api/sql-cert-verify", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "sql": "UPDATE users SET plan = 'pro' WHERE id = 42",
    "certificate": "eyJ2IjoxLCJzaGEyNTYiOiI2MzVjZjIwYTdhMzM3NzFjOGJiZjY3OTljOTJlNTdkOTRiNGY0MmFjMTYzMzkyMTg3MTg1Zjc5OWE4OGFjYTAyIiwidmVyZGljdCI6InBhc3MiLCJwb2xpY3kiOiI1MzljNzhjZDhiZTZjMzUwIiwiaWF0IjoxNzg1MDAwMDAwLCJleHAiOjQwNzA5MDg4MDB9.iOLcl81N_N2-b3Tq1YdLCbRkmgQB8fWG9TA0oRQG81CgXtLrvBi4dsk6Oww-FR3mWqtDmLxT0TZLbDxbBo5dBw",
    "publicKey": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEA+dgN+1FKr9VoA3fbT4bimUF4W8ORBYKwR6XiZldGxgw=\n-----END PUBLIC KEY-----\n"
  }),
});

No wallet? Pay with compute

Fetch a challenge, solve the sha256 puzzle (16 leading zero bits, a fraction of a second of CPU), and resend with the X-Pow-Solution header:

import { createHash } from "node:crypto";
const lz = (b) => { let t = 0; for (const x of b) { if (!x) { t += 8; continue; } t += Math.clz32(x) - 24; break; } return t; };
const c = await (await fetch("https://agent402.tools/api/pow/challenge?slug=sql-cert-verify")).json();
let n = 0;
while (lz(createHash("sha256").update(c.challenge + ":" + n).digest()) < c.difficulty) n++;
await fetch("https://agent402.tools/api/sql-cert-verify", { method: "POST", headers: { "X-Pow-Solution": c.token + ":" + n, "Content-Type": "application/json" }, body: JSON.stringify({"sql":"UPDATE users SET plan = 'pro' WHERE id = 42","certificate":"eyJ2IjoxLCJzaGEyNTYiOiI2MzVjZjIwYTdhMzM3NzFjOGJiZjY3OTljOTJlNTdkOTRiNGY0MmFjMTYzMzkyMTg3MTg1Zjc5OWE4OGFjYTAyIiwidmVyZGljdCI6InBhc3MiLCJwb2xpY3kiOiI1MzljNzhjZDhiZTZjMzUwIiwiaWF0IjoxNzg1MDAwMDAwLCJleHAiOjQwNzA5MDg4MDB9.iOLcl81N_N2-b3Tq1YdLCbRkmgQB8fWG9TA0oRQG81CgXtLrvBi4dsk6Oww-FR3mWqtDmLxT0TZLbDxbBo5dBw","publicKey":"-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEA+dgN+1FKr9VoA3fbT4bimUF4W8ORBYKwR6XiZldGxgw=\n-----END PUBLIC KEY-----\n"}) });

Related tools

SQL execution certificate firewall

$0.004 · POST /api/sql-guard

Review a SQL statement an agent is about to run against production, and certify it. Returns a policy verdict (pass / war…

Check an x402 seller's trust evidence

FREE w/ compute · or $0.005 · GET /api/x402/seller-trust

Trust evidence for any x402 seller origin: is it indexed, does its manifest parse, how many tools does it publish, which…

Card number validate

FREE w/ compute · or $0.001 · POST /api/card-validate

Validate a payment card number (Luhn checksum) and detect the brand. Numbers are not stored or logged.

Color convert

FREE w/ compute · or $0.001 · POST /api/color

Convert a color between hex, RGB, and HSL. Accepts "#1a2b3c", "rgb(26,43,60)", or "hsl(210,40%,17%)".

CSV lint

FREE w/ compute · or $0.001 · POST /api/csv-lint

Validate CSV structure: consistent column counts across rows, properly closed quotes, delimiter detection. Returns row/c…

Email validate

$0.001 · POST /api/email-validate

Validate an email address: syntax check plus live MX record lookup on the domain (deliverability signal, not a guarantee…