/v1/databases/{uid}/data/queryRuns one read-only statement against the database and returns the result as a grid. Nothing you run here can change data.
PostgreSQL
- The statement runs in a
READ ONLYtransaction that is never committed, withdefault_transaction_read_onlyon. Writes (INSERT,UPDATE,DELETE, DDL and so on) fail with400and a message startingthe data viewer is read-only:. - Only a single statement is accepted. A string with several statements is rejected by the server.
statement_timeoutis 15 seconds andlock_timeout3 seconds.- Values are returned in PostgreSQL text format, and column
typeis the PostgreSQL type name (for exampleint4,text,timestamptz).
MySQL
- The session and transaction are read-only and multi-statement strings are not allowed.
Writes fail with
400and a message startingthe data viewer is read-only:. max_execution_timeis 15 seconds and lock waits time out after 3 seconds.- Binary columns (
BINARY,VARBINARY,BLOBtypes,BIT,GEOMETRY) are returned as0x-prefixed hex. Columntypeis the lower-case MySQL type name.
Redis (Valkey)
sqlholds one command line, split likeredis-clidoes: words separated by spaces, with"double"(supporting\n,\t,\"and\xHH) or'single'quotes.- Only read-only commands are allowed:
PING,ECHO,TIME,DBSIZE,INFO,LASTSAVE,TYPE,EXISTS,TTL,PTTL,EXPIRETIME,PEXPIRETIME,SCAN,RANDOMKEY,OBJECT ENCODING|FREQ|IDLETIME|REFCOUNT|HELP,MEMORY USAGE|STATS|HELP,GET,MGET,STRLEN,GETRANGE,SUBSTR,LCS,GETBIT,BITCOUNT,BITPOS,BITFIELD_RO, the read-only hash, list, set, sorted set and geo commands (HGET,HGETALL,HSCAN,LRANGE,LLEN,SMEMBERS,SSCAN,ZRANGE,ZSCORE,ZSCAN,GEOSEARCHand similar),XRANGE,XREVRANGE,XLEN,XPENDING,XINFO STREAM|GROUPS|CONSUMERS|HELPandSORT_RO. Anything else returns400. dbselects the logical database,0to15.- Replies are shaped into columns:
INFObecomessection,key,value;HGETALLandHSCANbecomefield,value;WITHSCORESreplies andZSCANbecomemember,score; other arrays become#,value; single values become onevaluerow. ForSCAN-family commands,commandisnext cursor <n>. Nested arrays are returned as JSON strings. Columntypeis an empty string. - The whole reply is capped at 8 MB. Larger replies fail with
400; use aSCANcommand or a narrower range.
Limits for all engines
sqlcan be at most 64 KiB.- At most 500 rows are returned. Results also stop once about 4 MiB of cell data has been
read (SQL engines). When either cap is hit,
truncatedistrue. - Each cell is cut at 8 KiB, ending with
…. nullinrowsmeans SQLNULL(or a nil Redis reply).- The database must be
ready, and data browser calls share a small platform-wide pool of connections (409when busy).
Requires the secrets read permission (owner, admin or developer role). Requests made with
an mcp-scoped API key (AI assistants) return 403 unless command access is turned on in
the workspace settings. The first 1000 characters of sql are recorded in the workspace
audit log.
Authentication
Send your API key as Authorization: Bearer <token>. The request is scoped to the workspace in X-Workspace-Slug.
Path parameters
uidstringRequiredThe database's uid.
Headers
X-Workspace-SlugstringRequiredSlug of the workspace the request acts on. You can also pass it as the workspace_slug query parameter.
Request body
sqlstringRequiredOne SQL statement (PostgreSQL, MySQL) or one command line (Redis). Leading and trailing whitespace is trimmed.
max length 65536
dbintegerRedis logical database to run the command against. Ignored for PostgreSQL and MySQL.
Default 0min 0 · max 15
Response
The statement's result.
successbooleanRequiredtrue when the request succeeded.
messagestringRequiredHuman-readable status message.
dataobjectShow attributesHide attributes
columnsarray of objectsRequiredResult columns, in order.
Show item attributesHide item attributes
namestringRequiredColumn name.
typestringRequiredType name reported by the engine (for example int4 in PostgreSQL or varchar in MySQL). Empty string for Redis and for unknown types.
rowsarray of array of string | nullssRequiredResult rows. Each row is an array of cells in column order. Every value is a string; null is SQL NULL.
row_countintegerRequiredNumber of rows in rows.
truncatedbooleanRequiredtrue when more rows exist than were returned, because of the row cap, the page size or the response size cap.
commandstringPostgreSQL's command tag (for example SELECT 2 or EXPLAIN). For MySQL, SELECT <n>
when the statement returned columns. For Redis SCAN-family commands,
next cursor <n>. Omitted when the result was truncated and otherwise when there is
none.
duration_msintegerRequiredTime taken to run the statement and read the result, in milliseconds.
Errors
| Status | Meaning |
|---|---|
400 | The query was rejected or failed. Possible messages: sql is required (also sent for malformed JSON), query is too long, the data viewer is read-only: <reason>, the query was cancelled because it took too long, the command was cancelled because it took too long, <COMMAND> isn't available in the data viewer, which only runs read-only commands, unbalanced quotes in command, closing quote must be followed by a space, command is required, db must be between 0 and 15, the reply is larger than 8 MB, use a SCAN command or a narrower range, the database rejected the connection: <reason>, or the database's own error message (PostgreSQL errors include the detail in brackets when there is one). |
401 | The API key is missing, invalid, expired or revoked. |
403 | Your role cannot read secrets, or the request used an mcp-scoped API key and command access is turned off for the workspace. |
404 | The resource does not exist or you cannot access it. |
409 | The data browser cannot run right now. Possible messages: the database must be ready to browse its data, the data viewer is busy, try again in a moment, and couldn't reach the database, check that it's running and try again. |
Errors use the standard error format.