Documentation menu

Run database query

POSThttps://api.instacloud.com/projects/{projectId}/database/query

Token scope: account · org · project — read-only tokens refused (not a GET).

Run one SQL statement with the service credential (full privileges — the gate and audit are a record, not a permission boundary). The audit log records a statement hash and parameter count, never SQL text or values. Gated — db.query. May wake a suspended database.

Parameters

NameInTypeRequiredDescription
branchquerystringnoBranch name (defaults to the project's default branch)
groupquerystringnopostgres service name (default: the sole postgres service)
databasequerystringnodatabase on the instance (default: the connection-string database)
projectIdpathstringyes

Request body

application/json

FieldTypeRequiredDescription
sqlstringyes
paramsany[]nopositional parameter values for $1..$n — audited as a count, never as values
maxRowsintegerno

Responses

200

Default Response

FieldTypeRequiredDescription
columnsobject[]yes
columns.namestringyes
columns.dataTypeIDintegeryes
rowsany[][]yesrows as positional cells — duplicate column names stay distinct; numeric/int8 arrive as strings
rowCountintegeryes
truncatedbooleanyestrue when maxRows clipped the result — narrow with WHERE/LIMIT
queryIdnull | nullyesreserved for future cancellation

202

Default Response

FieldTypeRequiredDescription
status"approval_required"no
approvalIdstringno
actionstringnothe gated action, or a comma-joined compound set — prefer `actions`
actionsstring[]noevery capability this approval covers
messagestringno
urlstringnothe console page where a project admin reviews this request
nextActionsobject[]no
nextActions.opstringyesNeutral logical action id, e.g. "service.add" — NOT an operationId or a CLI/MCP tool name; each client maps it to its own surface.
nextActions.reasonstringyesNatural-language, human/LLM-facing "why do this now".
nextActions.argsobjectnoSuggested, flat named arguments; "<placeholder>"s where a value is unknown.
nextActions.gatedbooleannoTrue if the action passes a governance gate.

400

Default Response

FieldTypeRequiredDescription
errorstringyes

403

Default Response

FieldTypeRequiredDescription
errorstringyes

404

Default Response

FieldTypeRequiredDescription
errorstringyes

409

code public_access_closed: the database's public access is closed and the console has no private lane on this deployment yet

FieldTypeRequiredDescription
errorstringyes
codestringnostable machine-readable reason, e.g. private_lane_disabled, private_lane_unavailable_in_region, public_access_closed, credential_change_in_progress

502

Default Response

FieldTypeRequiredDescription
errorstringyes

View as Markdown