Query API
Single query
Section titled “Single query”curl -X POST https://postdb.dev/api/query \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "sql": "SELECT * FROM users WHERE email = $1", "params": ["alice@acme.com"] }'Return one row
Section titled “Return one row”curl -X POST https://postdb.dev/api/query/one \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "sql": "SELECT * FROM users WHERE id = $1", "params": ["user-123"] }'Returns the first row or null — useful for lookups.
Security
Section titled “Security”All queries must be parameterized — never use string interpolation. Post AI enforces parameterized queries at the API level and rejects malformed inputs.
Tenant isolation is enforced via SET LOCAL search_path = "tenant_{id}", public as the first statement of every query — your data never leaks to other tenants.