See the schema

SDK platic.tools.databases.schema()

Read the current database schema. Without table, it returns all tables; with table, it returns that table's columns. Items hidden from agents are included with hidden: true, so you can review what to hide.

Example

await platic.tools.databases.schema("db_123", { table: "orders" });

Path parameters

ParameterTypeDescriptionRequired
databaseIdstringThe id of the connection✓

Query parameters

ParameterTypeDescriptionRequired
tablestringOne table, as table or schema.table, as it comes in the list. Without it, all the tables—

Response

200 OK. Without table, the list of tables:

{
  "status": "success",
  "data": {
    "tables": [
      { "name": "customers", "type": "table", "approxRows": 1840, "schema": "public", "table": "customers", "hidden": false },
      { "name": "payments", "type": "table", "approxRows": 9100, "schema": "public", "table": "payments", "hidden": true },
      { "name": "orders", "type": "table", "approxRows": 12400, "schema": "public", "table": "orders", "hidden": false }
    ]
  }
}

With table=customers, its columns:

{
  "status": "success",
  "data": {
    "table": "customers",
    "schema": "public",
    "columns": [
      { "name": "id", "type": "integer", "nullable": false, "primaryKey": true, "hidden": false },
      { "name": "name", "type": "text", "nullable": false, "hidden": false },
      { "name": "phone", "type": "text", "nullable": true, "hidden": true },
      { "name": "order_id", "type": "integer", "nullable": true, "references": "orders.id", "hidden": false }
    ]
  }
}

Response fields

FieldTypeDescription
tables[].namestringtable, or schema.table outside the default schema. It is what goes in table
tables[].typestringFor example table or view
tables[].schema, tables[].tablestringThe schema and the name of the table separately
tables[].approxRows, tables[].commentnumber, stringThe row estimate and the comment, if the server has them
tables[].hiddenbooleanWhether it is in hiddenTables
truncatedbooleantrue if only the first tables are included
columns[].name, columns[].typestringThe name and the type, as the server names them
columns[].nullablebooleanWhether it allows empty values
columns[].primaryKeybooleanOnly if it is part of the primary key
columns[].referencesstringThe column it points to, as table.column
columns[].default, columns[].commentstringThe default value and the comment, if it has them
columns[].hiddenbooleanWhether it is in hiddenColumns

Errors

Statusdetails.codeWhen it happens
400INVALID_REQUESTtable is empty or too long
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
404TABLE_NOT_AVAILABLEThat table does not exist
409DB_AUTH_FAILED, DB_UNREACHABLE, and the other DB_*The database did not respond. See why it does not connect
503TRANSPORT_UNAVAILABLEDatabase queries are not available right now. Try again