Skip to main content

GET /api/v1/schemas

List all schemas with their fields. Supports cursor-based pagination.

Query Parameters

ParameterTypeDefaultDescription
limitinteger20Max results per page
cursorstringCursor for pagination

Response

{
  "data": [
    {
      "id": "schema_001",
      "name": "customers",
      "displayName": "Customers",
      "description": "Core customer entity",
      "tableName": "kd_customers",
      "entityType": "customer",
      "status": "active",
      "fields": [
        {
          "id": "field_001",
          "name": "email",
          "displayName": "Email",
          "dataType": "varchar",
          "length": 255,
          "isNullable": false,
          "isPrimaryKey": false,
          "isUnique": true,
          "ordinal": 1
        }
      ],
      "createdAt": "2026-01-10T08:00:00.000Z"
    }
  ],
  "total": 5,
  "hasMore": false
}

POST /api/v1/schemas

Create a new schema. This creates both a metadata record and a real PostgreSQL table via DDL.
Creating a schema executes CREATE TABLE against the database. If the DDL fails, the metadata record is automatically rolled back.

Request Body

FieldTypeRequiredDescription
namestringYesSchema name (auto-sanitized to lowercase alphanumeric + underscores)
displayNamestringYesHuman-readable name
descriptionstringNoDescription
entityTypestringNoEntity type: "customer", "account", "custom". Default: "custom"
fieldsarrayNoInitial field definitions (see field object below)

Field Object

FieldTypeDefaultDescription
namestringColumn name
displayNamestringnameDisplay label
dataTypestring"varchar"PostgreSQL data type
lengthintegernullLength for varchar/char types
precisionintegernullPrecision for decimal types
scaleintegernullScale for decimal types
isNullablebooleantrueWhether the column allows NULL
isPrimaryKeybooleanfalsePrimary key constraint
isUniquebooleanfalseUnique constraint
defaultValuestringnullDefault value expression
descriptionstring""Field description

Example

curl -X POST https://playground.kaireonai.com/api/v1/schemas \
  -H "Content-Type: application/json" \
  -H "X-Tenant-Id: my-tenant" \
  -d '{
    "name": "customers",
    "displayName": "Customers",
    "entityType": "customer",
    "fields": [
      { "name": "email", "dataType": "varchar", "length": 255, "isUnique": true },
      { "name": "loan_amount", "dataType": "decimal", "precision": 12, "scale": 2 },
      { "name": "tenure_months", "dataType": "integer" }
    ]
  }'
Response: 201 Created

DELETE /api/v1/schemas

Delete a schema and drop its backing PostgreSQL table.

Query Parameters

ParameterTypeRequiredDescription
idstringYesSchema ID to delete
This drops the underlying database table. All data in the table is permanently lost.
Response: 204 No Content

POST /api/v1/schemas/fields

Add a column to an existing schema. Executes ALTER TABLE ADD COLUMN.

Request Body

FieldTypeRequiredDescription
schemaIdstringYesParent schema ID
namestringYesColumn name
dataTypestringYesPostgreSQL data type
displayNamestringNoDisplay label
lengthintegerNoLength for varchar/char
precisionintegerNoPrecision for decimal
scaleintegerNoScale for decimal
isNullablebooleanNoDefault: true
isPrimaryKeybooleanNoDefault: false
isUniquebooleanNoDefault: false
defaultValuestringNoDefault value expression
descriptionstringNoField description
Response: 201 Created with the field object.

DELETE /api/v1/schemas/fields

Remove a column from a schema. Executes ALTER TABLE DROP COLUMN.

Query Parameters

ParameterTypeRequiredDescription
fieldIdstringYesField ID to delete
This drops the column from the underlying table. Data in this column is permanently lost.
Response: 204 No Content

Roles

EndpointAllowed Roles
GET /schemasadmin, editor, viewer
POST /schemasadmin, editor
DELETE /schemasadmin, editor
POST /schemas/fieldsadmin, editor
DELETE /schemas/fieldsadmin, editor
See also: Data Platform | Computed Values