Skip to content

Query API

Terminal window
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"]
}'
Terminal window
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.

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.