Test a database

SDK platic.tools.databases.test()

Test the connection using its saved settings and list the tables available to the agent. The result is saved in lastTest.

Example

await platic.tools.databases.test("db_123");

Path parameters

ParameterTypeDescriptionRequired
databaseIdstringThe id of the connection✓

It has no body.

Response

200 OK, whether it connects or not. If it connected, message is Connected:

{
  "status": "success",
  "message": "Connected",
  "data": {
    "connected": true,
    "server": { "version": "PostgreSQL 16.4", "database": "store", "user": "readonly" },
    "tables": [
      { "name": "customers", "type": "table", "approxRows": 1840 },
      { "name": "orders", "type": "table", "approxRows": 12400, "comment": "One row per order" },
      { "name": "sales.monthly_summary", "type": "view" }
    ],
    "hiddenTables": 1,
    "database": { "id": "Xb2mQe7LtR9sKd4fHw1N", "name": "store", "lastTest": { "ok": true, "at": "2026-11-14T16:01:12.000Z", "version": "PostgreSQL 16.4", "tableCount": 3 } }
  }
}

If it did not connect, message is The database did not answer: see error:

{
  "status": "success",
  "message": "The database did not answer: see error",
  "data": {
    "connected": false,
    "error": { "code": "DB_AUTH_FAILED", "message": "La base de datos rechazó el usuario o la contraseña." },
    "database": { "id": "Xb2mQe7LtR9sKd4fHw1N", "name": "store", "lastTest": { "ok": false, "at": "2026-11-14T16:01:12.000Z", "code": "DB_AUTH_FAILED" } }
  }
}

database is the full connection, with the fields in get a database; the examples trim it.

Response fields

FieldTypeDescription
connectedbooleanWhether it could connect
serverobjectversion, database, and user of the server. Only if it connected
tablesarrayThe tables the agent will see: name (table, or schema.table outside the default schema), type, and, if the server has them, approxRows and comment
hiddenTablesnumberHow many hidden tables do not appear in tables
truncatedbooleantrue if only the first tables are included
errorobjectcode and message with what to check. Only if it did not connect
databaseobjectThe connection, with its new lastTest

Why it does not connect

error.codeWhat to check
DB_AUTH_FAILEDThe user or the password
DB_UNREACHABLEThe host, the port, and that the database accepts connections from the internet. Platica does not connect from a fixed IP yet. If the message says the host only has an IPv6 address, use your provider's pooler host: on Supabase, the Session pooler one
DB_HOST_UNRESOLVEDThat the host is spelled correctly: it could not be resolved
DB_HOST_NOT_ALLOWEDThe host points to a local or private address. Use the public host of your database
DB_SSL_CERTIFICATEThe server's certificate could not be verified: use ssl: "require" or check the certificate
DB_SSL_UNSUPPORTEDThe server does not support SSL: use ssl: "disable" or enable it on the server
DB_NOT_FOUNDThe name of the database
DB_PERMISSION_DENIEDThat the user can read the database

Errors

Statusdetails.codeWhen it happens
403FORBIDDEN or INSUFFICIENT_SCOPEThe person behind the token does not have access to Integrations, or the token does not have write permission
404NOT_FOUNDThere is no connection with that id in the workspace
503TRANSPORT_UNAVAILABLEDatabase queries are not available right now. Try again

Notes

  • The test can take up to a minute if the database does not respond.
  • Testing again only replaces lastTest: it is safe to repeat.