Databases
Trong trang này
- List database engines and versions
- Create a database
- Reveal the connection string (admin)
- Update database ports and limits
- Delete a database (optionally its volume)
- List database sessions with state, duration, current query and blocking sessions (pg_stat_activity, processlist, or CLIENT LIST)
- Cancel the running statement of a session; terminate=true closes the whole session. The session id comes from …/db/activity. Needs write access and, for agent grants, agent_access=read_write
- Run SQL that changes data or schema (INSERT, UPDATE, DELETE, CREATE INDEX [CONCURRENTLY], ALTER, VACUUM, ANALYZE, …). Several statements separated by ';' run in one transaction when the engine allows it (transactional=true: all or nothing). Needs write access and, for agent grants, agent_access=read_write. DROP, TRUNCATE, ALTER … DROP and DELETE/UPDATE without WHERE return 409 confirmation_required until confirm_destructive=true. Client commands (\d, \!, SOURCE, …), COPY, LOAD DATA and server file access are refused
- Show the query plan of one statement. Body: sql (without EXPLAIN); analyze=true runs it and reports real timings (read statements only). Use it to check that a new index is used
- Run health checks and get findings, each with a suggested SQL statement or Redis command: missing, unused, duplicate or invalid indexes, foreign keys without index, tables without primary key, dead rows, long-running or blocked sessions, cache hit ratio, connection and memory limits, failed persistence, slow queries. Review a suggestion, then run it with …/db/execute or …/db/redis/execute
- Read one Redis key: type, TTL, memory, length and value (first 64 KiB of a string, or the first `limit` elements). Query: key (required), db (0-15), limit (1-1000, default 200)
- Scan Redis keys with type, TTL and memory, without blocking the server. Query: pattern (glob, default *), cursor (start with 0, then pass the returned cursor until it is 0), count (1-1000 per step, default 200), type (string, list, set, zset, hash, stream), db (0-15)
- Database health numbers for Postgres, MySQL, MariaDB or Redis: connections, size, cache hit ratio, throughput counters, memory, uptime. Allowed whatever agent_access is. History for charts: GET /api/v1/metrics?service_id=<id>&metrics=db_connections,db_tps,db_ops_per_sec,db_cache_hit_ratio,db_size_bytes,db_memory_bytes
- Run one read-only SQL statement (SELECT, WITH, SHOW, EXPLAIN, VALUES, TABLE, DESCRIBE) in a read-only session and get columns and rows (values are text or null). Body: sql; optional max_rows and timeout_secs, capped by the settings. Statements that change anything are refused with write_statement: use …/db/execute
- Run a Redis command that changes data or settings (SET, DEL, EXPIRE, HSET, LPUSH, ZADD, CONFIG SET maxmemory, SLOWLOG RESET, EVAL, …). Needs write access and, for agent grants, agent_access=read_write. FLUSHDB, FLUSHALL, SCRIPT FLUSH and FUNCTION FLUSH/DELETE need confirm_destructive=true
- Run one read-only Redis command (GET, MGET, HGETALL, LRANGE, SMEMBERS, ZRANGE, SCAN, TTL, TYPE, INFO, SLOWLOG GET, MEMORY USAGE, CONFIG GET, …). Body: args array (preferred), or a command line; db 0-15. KEYS, MONITOR, SUBSCRIBE, blocking pops, SELECT and MULTI are refused with the alternative to use
- Browse rows of one table. Query: name (required), schema, limit (default 100, at most max_rows), offset, order_by (column name), order (asc|desc). result.truncated=true means more rows follow; raise offset
- Read the database console settings of a database service: agent_access (off, read, read_write) is what agent grants (AI agents, the iOS app) may do with its data; max_rows and timeout_secs are the per-query defaults and ceilings
- Change the database console settings (admin): agent_access off|read|read_write, max_rows 1-5000, timeout_secs 1-300. Agent grants may lower agent_access but never raise it
- Describe one table: columns (type, nullable, default) and indexes (definition, size, scans). Query: name (required), schema (default public on Postgres; the service database on MySQL/MariaDB)
- List tables and views of a SQL database with row estimates and sizes
- Restart a service
- Start a service
- Stop a service
Managed databases and their lifecycle
List database engines and versions
/api/v1/database-enginesPhản hồi
200 List database engines and versions
DatabaseEngineView[]default_portinteger (int32)bắt buộcenginestringbắt buộcversionsstring[]bắt buộc
Create a database
/api/v1/environments/{id}/databasesNội dung gửi lênapplication/json
CreateDatabase
databasestring | nullenginestringbắt buộcpostgres, mysql, mariadb, mongo, or redis.
memory_bytesinteger | null (int64)namestringbắt buộcnano_cpusinteger | null (int64)public_portinteger | null (int32)Publish the database port on the host. Omit to keep it internal.
server_idstring (uuid)bắt buộcstartboolean | nullStart the container right away. Defaults to true.
usernamestring | nullversionstringbắt buộc
Phản hồi
201 Create a database
ServiceViewcreated_atstring (date-time)bắt buộcenvironment_idstring (uuid)bắt buộcidstring (uuid)bắt buộckindstringbắt buộcnamestringbắt buộcserver_idstring (uuid)bắt buộcspecanybắt buộcstatusstringbắt buộc
Reveal the connection string (admin)
/api/v1/services/{id}/connectionPhản hồi
200 Reveal the connection string (admin)
ConnectionViewdatabasestringbắt buộcenginestringbắt buộchoststringbắt buộcinternal_urlstringbắt buộcpasswordstringbắt buộcportinteger (int32)bắt buộcpublic_urlstring | nullusernamestringbắt buộc
Update database ports and limits
/api/v1/services/{id}/databaseNội dung gửi lênapplication/json
UpdateDatabase
clear_public_portboolean | nullmemory_bytesinteger | null (int64)nano_cpusinteger | null (int64)public_portinteger | null (int32)
Phản hồi
200 Update database ports and limits
ServiceViewcreated_atstring (date-time)bắt buộcenvironment_idstring (uuid)bắt buộcidstring (uuid)bắt buộckindstringbắt buộcnamestringbắt buộcserver_idstring (uuid)bắt buộcspecanybắt buộcstatusstringbắt buộc
Delete a database (optionally its volume)
/api/v1/services/{id}/databasePhản hồi
- 204 Delete a database (optionally its volume)
List database sessions with state, duration, current query and blocking sessions (pg_stat_activity, processlist, or CLIENT LIST)
/api/v1/services/{id}/db/activityPhản hồi
200 List database sessions with state, duration, current query and blocking sessions (pg_stat_activity, processlist, or CLIENT LIST)
DbSession[]blocked_bystring | nullclientstring | nulldatabasestring | nullduration_secsinteger | null (int64)idstringbắt buộcquerystring | nullstatestring | nulluser_namestring | nullwaiting_onstring | null
Cancel the running statement of a session; terminate=true closes the whole session. The session id comes from …/db/activity. Needs write access and, for agent grants, agent_access=read_write
/api/v1/services/{id}/db/activity/{session}/cancelNội dung gửi lênapplication/json
DbCancelRequest
terminateboolean | nullClose the whole session instead of cancelling its current statement.
Phản hồi
200 Cancel the running statement of a session; terminate=true closes the whole session. The session id comes from …/db/activity. Needs write access and, for agent grants, agent_access=read_write
DbCancelResultokbooleanbắt buộcThe server accepted the request.
sessionstringbắt buộcterminatedbooleanbắt buộc
Run SQL that changes data or schema (INSERT, UPDATE, DELETE, CREATE INDEX [CONCURRENTLY], ALTER, VACUUM, ANALYZE, …). Several statements separated by ';' run in one transaction when the engine allows it (transactional=true: all or nothing). Needs write access and, for agent grants, agent_access=read_write. DROP, TRUNCATE, ALTER … DROP and DELETE/UPDATE without WHERE return 409 confirmation_required until confirm_destructive=true. Client commands (\d, \!, SOURCE, …), COPY, LOAD DATA and server file access are refused
/api/v1/services/{id}/db/executeNội dung gửi lênapplication/json
DbExecuteRequest
confirm_destructiveboolean | nullRequired when a statement drops, truncates, or changes every row.
max_rowsinteger | null (int64)sqlstringbắt buộcOne or more statements separated by
;.timeout_secsinteger | null (int64)
Phản hồi
200 Run SQL that changes data or schema (INSERT, UPDATE, DELETE, CREATE INDEX [CONCURRENTLY], ALTER, VACUUM, ANALYZE, …). Several statements separated by ';' run in one transaction when the engine allows it (transactional=true: all or nothing). Needs write access and, for agent grants, agent_access=read_write. DROP, TRUNCATE, ALTER … DROP and DELETE/UPDATE without WHERE return 409 confirmation_required until confirm_destructive=true. Client commands (\d, \!, SOURCE, …), COPY, LOAD DATA and server file access are refused
DbExecuteResponseelapsed_msinteger (int64)bắt buộcstatementsDbStatementResult[]bắt buộcDbStatementResult[]
affected_rowsinteger | null (int64)indexintegerbắt buộckindstringbắt buộcreadorwrite.resultQueryResult | nullQueryResult | null
Một trong:
QueryResultcolumnsstring[]bắt buộcrowsstring | null[][]bắt buộctruncatedbooleanbắt buộcMore rows existed than were returned.
null
statementstringbắt buộctagstring | nullCommand tag such as
UPDATE 3.
transactionalbooleanbắt buộcAll statements ran in one transaction (all applied or none).
Show the query plan of one statement. Body: sql (without EXPLAIN); analyze=true runs it and reports real timings (read statements only). Use it to check that a new index is used
/api/v1/services/{id}/db/explainNội dung gửi lênapplication/json
DbExplainRequest
analyzeboolean | nullRun it and report real timings. Only allowed for read statements.
sqlstringbắt buộcThe statement to explain.
Phản hồi
200 Show the query plan of one statement. Body: sql (without EXPLAIN); analyze=true runs it and reports real timings (read statements only). Use it to check that a new index is used
DbQueryResponseelapsed_msinteger (int64)bắt buộcresultQueryResultbắt buộcRows returned by a statement. Every value is text or
null.QueryResult
columnsstring[]bắt buộcrowsstring | null[][]bắt buộctruncatedbooleanbắt buộcMore rows existed than were returned.
statementstringbắt buộcThe statement with string literals hidden.
Run health checks and get findings, each with a suggested SQL statement or Redis command: missing, unused, duplicate or invalid indexes, foreign keys without index, tables without primary key, dead rows, long-running or blocked sessions, cache hit ratio, connection and memory limits, failed persistence, slow queries. Review a suggestion, then run it with …/db/execute or …/db/redis/execute
/api/v1/services/{id}/db/insightsPhản hồi
200 Run health checks and get findings, each with a suggested SQL statement or Redis command: missing, unused, duplicate or invalid indexes, foreign keys without index, tables without primary key, dead rows, long-running or blocked sessions, cache hit ratio, connection and memory limits, failed persistence, slow queries. Review a suggestion, then run it with …/db/execute or …/db/redis/execute
DbInsightschecked_atstring (date-time)bắt buộcenginestringbắt buộcfindingsDbFinding[]bắt buộcCritical first, then warnings, then information.
DbFinding[]
categorystringbắt buộcperformance,indexes,maintenance,capacity,reliability, orschema.checkstringbắt buộcStable machine name of the check, e.g.
unused_index.detailstringbắt buộcobjectstring | nullTable, index, session or setting the finding is about.
severitystringbắt buộccritical,warning, orinfo.suggestionstring | nullSQL or Redis command that addresses it. Review before running it with the execute endpoint.
titlestringbắt buộc
skippedstring[]bắt buộcChecks that could not run, with the reason.
slow_queriesQueryResult | nullQueryResult | null
Một trong:
QueryResultcolumnsstring[]bắt buộcrowsstring | null[][]bắt buộctruncatedbooleanbắt buộcMore rows existed than were returned.
null
Read one Redis key: type, TTL, memory, length and value (first 64 KiB of a string, or the first `limit` elements). Query: key (required), db (0-15), limit (1-1000, default 200)
/api/v1/services/{id}/db/keyPhản hồi
200 Read one Redis key: type, TTL, memory, length and value (first 64 KiB of a string, or the first `limit` elements). Query: key (required), db (0-15), limit (1-1000, default 200)
DbKeyDetailkeystringbắt buộclengthinteger | null (int64)Elements (or bytes for strings) in the key.
memory_bytesinteger | null (int64)truncatedbooleanbắt buộcttl_msinteger (int64)bắt buộctypestringbắt buộcvalueobjectbắt buộcString value (first 64 KiB), list/set items,
[field, value]/[member, score]pairs, or[id, [[field, value]]]stream entries.
Scan Redis keys with type, TTL and memory, without blocking the server. Query: pattern (glob, default *), cursor (start with 0, then pass the returned cursor until it is 0), count (1-1000 per step, default 200), type (string, list, set, zset, hash, stream), db (0-15)
/api/v1/services/{id}/db/keysPhản hồi
200 Scan Redis keys with type, TTL and memory, without blocking the server. Query: pattern (glob, default *), cursor (start with 0, then pass the returned cursor until it is 0), count (1-1000 per step, default 200), type (string, list, set, zset, hash, stream), db (0-15)
DbKeyPagecursorstringbắt buộcPass back as
cursorfor the next page;0means the scan is complete.keysDbKey[]bắt buộcDbKey[]
keystringbắt buộcmemory_bytesinteger (int64)bắt buộcttl_msinteger (int64)bắt buộcMilliseconds to expiry; -1 without expiry.
typestringbắt buộc
Database health numbers for Postgres, MySQL, MariaDB or Redis: connections, size, cache hit ratio, throughput counters, memory, uptime. Allowed whatever agent_access is. History for charts: GET /api/v1/metrics?service_id=<id>&metrics=db_connections,db_tps,db_ops_per_sec,db_cache_hit_ratio,db_size_bytes,db_memory_bytes
/api/v1/services/{id}/db/overviewPhản hồi
200 Database health numbers for Postgres, MySQL, MariaDB or Redis: connections, size, cache hit ratio, throughput counters, memory, uptime. Allowed whatever agent_access is. History for charts: GET /api/v1/metrics?service_id=<id>&metrics=db_connections,db_tps,db_ops_per_sec,db_cache_hit_ratio,db_size_bytes,db_memory_bytes
DbOverviewagent_accessstringbắt buộcchart_metricsstring[]bắt buộcMetric names with history for this engine: pass them to
GET /api/v1/metrics?service_id=…&metrics=…(at most 8 per call).checked_atstring (date-time)bắt buộcenginestringbắt buộcserver_versionstring | nullVersion reported by the running server.
statsDbStat[]bắt buộcDbStat[]
keystringbắt buộcStable machine name, e.g.
cache_hit_ratio.labelstringbắt buộcunitstringbắt buộccount,bytes,percent,seconds,ms, orratio.valuenumber (double)bắt buộc
versionstringbắt buộc
Run one read-only SQL statement (SELECT, WITH, SHOW, EXPLAIN, VALUES, TABLE, DESCRIBE) in a read-only session and get columns and rows (values are text or null). Body: sql; optional max_rows and timeout_secs, capped by the settings. Statements that change anything are refused with write_statement: use …/db/execute
/api/v1/services/{id}/db/queryNội dung gửi lênapplication/json
DbQueryRequest
max_rowsinteger | null (int64)sqlstringbắt buộcOne read-only statement (SELECT, WITH, SHOW, EXPLAIN, VALUES, TABLE, DESCRIBE).
timeout_secsinteger | null (int64)
Phản hồi
200 Run one read-only SQL statement (SELECT, WITH, SHOW, EXPLAIN, VALUES, TABLE, DESCRIBE) in a read-only session and get columns and rows (values are text or null). Body: sql; optional max_rows and timeout_secs, capped by the settings. Statements that change anything are refused with write_statement: use …/db/execute
DbQueryResponseelapsed_msinteger (int64)bắt buộcresultQueryResultbắt buộcRows returned by a statement. Every value is text or
null.QueryResult
columnsstring[]bắt buộcrowsstring | null[][]bắt buộctruncatedbooleanbắt buộcMore rows existed than were returned.
statementstringbắt buộcThe statement with string literals hidden.
Run a Redis command that changes data or settings (SET, DEL, EXPIRE, HSET, LPUSH, ZADD, CONFIG SET maxmemory, SLOWLOG RESET, EVAL, …). Needs write access and, for agent grants, agent_access=read_write. FLUSHDB, FLUSHALL, SCRIPT FLUSH and FUNCTION FLUSH/DELETE need confirm_destructive=true
/api/v1/services/{id}/db/redis/executeNội dung gửi lênapplication/json
DbRedisRequest
argsstring[]Arguments, e.g.
["HGETALL", "user:1"]. Preferred overcommand.commandstring | nullA command line as typed in redis-cli, e.g.
SET "a key" value EX 60.confirm_destructiveboolean | nullRequired for FLUSHDB, FLUSHALL, SCRIPT FLUSH and FUNCTION FLUSH/DELETE.
dbinteger | null (int32)Logical database, 0 to 15. Defaults to 0.
Phản hồi
200 Run a Redis command that changes data or settings (SET, DEL, EXPIRE, HSET, LPUSH, ZADD, CONFIG SET maxmemory, SLOWLOG RESET, EVAL, …). Needs write access and, for agent grants, agent_access=read_write. FLUSHDB, FLUSHALL, SCRIPT FLUSH and FUNCTION FLUSH/DELETE need confirm_destructive=true
DbRedisResponsecommandstringbắt buộcelapsed_msinteger (int64)bắt buộckindstringbắt buộcreadorwrite.replyobjectbắt buộcThe reply as JSON (strings, numbers, arrays, maps, or null).
Run one read-only Redis command (GET, MGET, HGETALL, LRANGE, SMEMBERS, ZRANGE, SCAN, TTL, TYPE, INFO, SLOWLOG GET, MEMORY USAGE, CONFIG GET, …). Body: args array (preferred), or a command line; db 0-15. KEYS, MONITOR, SUBSCRIBE, blocking pops, SELECT and MULTI are refused with the alternative to use
/api/v1/services/{id}/db/redis/queryNội dung gửi lênapplication/json
DbRedisRequest
argsstring[]Arguments, e.g.
["HGETALL", "user:1"]. Preferred overcommand.commandstring | nullA command line as typed in redis-cli, e.g.
SET "a key" value EX 60.confirm_destructiveboolean | nullRequired for FLUSHDB, FLUSHALL, SCRIPT FLUSH and FUNCTION FLUSH/DELETE.
dbinteger | null (int32)Logical database, 0 to 15. Defaults to 0.
Phản hồi
200 Run one read-only Redis command (GET, MGET, HGETALL, LRANGE, SMEMBERS, ZRANGE, SCAN, TTL, TYPE, INFO, SLOWLOG GET, MEMORY USAGE, CONFIG GET, …). Body: args array (preferred), or a command line; db 0-15. KEYS, MONITOR, SUBSCRIBE, blocking pops, SELECT and MULTI are refused with the alternative to use
DbRedisResponsecommandstringbắt buộcelapsed_msinteger (int64)bắt buộckindstringbắt buộcreadorwrite.replyobjectbắt buộcThe reply as JSON (strings, numbers, arrays, maps, or null).
Browse rows of one table. Query: name (required), schema, limit (default 100, at most max_rows), offset, order_by (column name), order (asc|desc). result.truncated=true means more rows follow; raise offset
/api/v1/services/{id}/db/rowsPhản hồi
200 Browse rows of one table. Query: name (required), schema, limit (default 100, at most max_rows), offset, order_by (column name), order (asc|desc). result.truncated=true means more rows follow; raise offset
DbQueryResponseelapsed_msinteger (int64)bắt buộcresultQueryResultbắt buộcRows returned by a statement. Every value is text or
null.QueryResult
columnsstring[]bắt buộcrowsstring | null[][]bắt buộctruncatedbooleanbắt buộcMore rows existed than were returned.
statementstringbắt buộcThe statement with string literals hidden.
Read the database console settings of a database service: agent_access (off, read, read_write) is what agent grants (AI agents, the iOS app) may do with its data; max_rows and timeout_secs are the per-query defaults and ceilings
/api/v1/services/{id}/db/settingsPhản hồi
200 Read the database console settings of a database service: agent_access (off, read, read_write) is what agent grants (AI agents, the iOS app) may do with its data; max_rows and timeout_secs are the per-query defaults and ceilings
DbConsoleSettingsagent_accessstringbắt buộcoff,read, orread_write: what AI agents and apps signed in with an agent grant may do with this database's data.max_rowsinteger (int32)bắt buộcDefault and maximum rows one query returns (1 to 5000).
timeout_secsinteger (int32)bắt buộcDefault and maximum seconds one statement may run (1 to 300).
updated_atstring | null (date-time)
Change the database console settings (admin): agent_access off|read|read_write, max_rows 1-5000, timeout_secs 1-300. Agent grants may lower agent_access but never raise it
/api/v1/services/{id}/db/settingsNội dung gửi lênapplication/json
SaveDbConsoleSettings
agent_accessstring | nulloff,read, orread_write. Agents may only lower it.max_rowsinteger | null (int32)timeout_secsinteger | null (int32)
Phản hồi
200 Change the database console settings (admin): agent_access off|read|read_write, max_rows 1-5000, timeout_secs 1-300. Agent grants may lower agent_access but never raise it
DbConsoleSettingsagent_accessstringbắt buộcoff,read, orread_write: what AI agents and apps signed in with an agent grant may do with this database's data.max_rowsinteger (int32)bắt buộcDefault and maximum rows one query returns (1 to 5000).
timeout_secsinteger (int32)bắt buộcDefault and maximum seconds one statement may run (1 to 300).
updated_atstring | null (date-time)
Describe one table: columns (type, nullable, default) and indexes (definition, size, scans). Query: name (required), schema (default public on Postgres; the service database on MySQL/MariaDB)
/api/v1/services/{id}/db/tablePhản hồi
200 Describe one table: columns (type, nullable, default) and indexes (definition, size, scans). Query: name (required), schema (default public on Postgres; the service database on MySQL/MariaDB)
DbTableDetailcolumnsDbColumn[]bắt buộcDbColumn[]
commentstring | nulldata_typestringbắt buộcdefault_valuestring | nullnamestringbắt buộcnullablebooleanbắt buộc
indexesDbIndex[]bắt buộcDbIndex[]
definitionstringbắt buộcis_primarybooleanbắt buộcis_uniquebooleanbắt buộcis_validbooleanbắt buộcnamestringbắt buộcscansinteger | null (int64)Index scans since statistics were reset (Postgres).
size_bytesinteger | null (int64)
namestringbắt buộcschemastringbắt buộc
List tables and views of a SQL database with row estimates and sizes
/api/v1/services/{id}/db/tablesPhản hồi
200 List tables and views of a SQL database with row estimates and sizes
DbTable[]index_bytesinteger | null (int64)kindstringbắt buộctable,view,materialized view,base table, …namestringbắt buộcrows_estimateinteger | null (int64)schemastringbắt buộctotal_bytesinteger | null (int64)
Restart a service
/api/v1/services/{id}/restartPhản hồi
200 Restart a service
LifecycleViewcontainer_idstring | nullstatusstringbắt buộc
Start a service
/api/v1/services/{id}/startPhản hồi
200 Start a service
LifecycleViewcontainer_idstring | nullstatusstringbắt buộc
Stop a service
/api/v1/services/{id}/stopPhản hồi
200 Stop a service
LifecycleViewcontainer_idstring | nullstatusstringbắt buộc