Connect a database

SDK platic.tools.databases.create()

Create an enabled connection and add its four tools to the catalog. The connection is not tested yet: test it before assigning it to an agent.

Example

await platic.tools.databases.create({ name: "store", engine: "postgres", host: "db.example.com", database: "store", user: "readonly", password: "your-db-password" });

Request body

FieldTypeDescriptionRequired
namestringLowercase letters, digits, and _, up to 32; starts with a letter or digit. Tools are named db_<name>_<tool>✓
descriptionstringWhat is in the database, up to 500 characters. The agent reads it in its tools to know when to query it—
enginestringpostgres or mysqlWithout connectionString
hoststringThe public host of the database. On Supabase, the one from the Session poolerWithout connectionString
portnumberDefaults to 5432 on PostgreSQL and 3306 on MySQL—
databasestringThe name of the database on the serverWithout connectionString
userstringThe user. Use a read-only oneWithout connectionString
sslstringrequire (default: encrypts without checking the certificate), verify (also checks it), or disable—
connectionStringstringpostgres://… or mysql://…. Fields you send along with it win—
passwordstringUp to 4,096 characters. It is stored as a secret and never comes back out—
passwordSecretIdstringA secret that already has the password, instead of password—
hiddenTablesstring[]Tables the agent does not see, as table or schema.table. Up to 500—
hiddenColumnsstring[]Columns the agent does not see, as table.column or schema.table.column. Up to 500—
pageSizenumberRows per page, from 1 to 200. Defaults to 50—
timeoutSecondsnumberTime limit of each query, from 1 to 30. Defaults to 5—

With the connection details:

{
  "name": "store",
  "description": "Orders, customers, and inventory of the online store.",
  "engine": "postgres",
  "host": "db.example.com",
  "database": "store",
  "user": "readonly",
  "password": "<password>",
  "hiddenColumns": ["customers.phone"]
}

Or with a connection string, which fills in the engine, host, port, database, user, password, and SSL:

{
  "name": "store",
  "connectionString": "postgres://readonly:<password>@db.example.com:5432/store?sslmode=require"
}

Response

201 Created. data has the connection, with the fields in get a database.

{
  "status": "success",
  "message": "Connection created",
  "data": {
    "id": "Xb2mQe7LtR9sKd4fHw1N",
    "name": "store",
    "description": "Orders, customers, and inventory of the online store.",
    "engine": "postgres",
    "host": "db.example.com",
    "port": 5432,
    "database": "store",
    "user": "readonly",
    "ssl": "require",
    "status": "enabled",
    "hiddenTables": [],
    "hiddenColumns": ["customers.phone"],
    "pageSize": 50,
    "timeoutSeconds": 5,
    "password": { "state": "authorized", "secretId": "7e4a1c9b3d5f7a0c2e4b6d8f0a1c3e5b7d9f1a3c5e7b9d0f2a4c6e8b0d2f4a6c", "secretName": "Password of the store database" },
    "tools": [
      { "id": "Xb2mQe7LtR9sKd4fHw1N_list_tables", "name": "db_store_list_tables", "tool": "list_tables" },
      { "id": "Xb2mQe7LtR9sKd4fHw1N_describe_table", "name": "db_store_describe_table", "tool": "describe_table" },
      { "id": "Xb2mQe7LtR9sKd4fHw1N_query", "name": "db_store_query", "tool": "query" },
      { "id": "Xb2mQe7LtR9sKd4fHw1N_next_page", "name": "db_store_next_page", "tool": "next_page" }
    ],
    "lastTest": null,
    "createdAt": "2026-11-14T16:00:00.000Z",
    "updatedAt": "2026-11-14T16:00:00.000Z",
    "nextStep": "Test the connection with POST /v1/tools/databases/Xb2mQe7LtR9sKd4fHw1N/test."
  }
}

Errors

Statusdetails.codeWhen it happens
400INVALID_REQUESTThe body fails validation: a field is missing, a value is not accepted, or there is an unknown field. details.issues says which, without repeating the password
400INVALID_NAMEname does not have the format
400INVALID_CONFIGA value does not work, for example a local or private-network host. details.data.field says which
400INVALID_CONNECTION_STRINGThe connection string cannot be read or does not start with postgres:// or mysql://
403FORBIDDEN or INSUFFICIENT_SCOPEThe person behind the token does not have access to Integrations, or the token does not have write permission
409NAME_TAKENThere is already a connection or a tool with that name
409LIMIT_REACHEDThe workspace already has 20 connections

Notes

  • Creating does not connect to the database: a wrong value shows up when you test it.
  • This call is not retried on its own. If the response is lost, list the connections before creating it again: a second attempt with the same name answers NAME_TAKEN.
  • Do not log or display the password after sending it. If an AI assistant connects the database for you, the password goes through that conversation: to avoid it, type it in Platica, under Integrations → Functions → Database.