GET /api/v1/schemas
List all schemas with their fields. Supports cursor-based pagination.Query Parameters
Response
POST /api/v1/schemas
Create a new schema. This creates both a metadata record and a real PostgreSQL table via DDL.Request Body
To bring a related entity (accounts, orders, addresses) into decisions, don’t flag it on the schema — create a Schema Join (Data → Schema Joins) with the customer schema as primary, the related schema as foreign, and
aggregations (sum/count/avg/min/max/any/all/first) to roll up one-to-many rows.Field Object
Example
Example with customPrimaryKey sugar
fields: [{ "name": "account_id", "dataType": "varchar", "isPrimaryKey": true, "isNullable": false, "isUnique": true }] directly — pick whichever is more ergonomic for your use case. When set, the table is not given the default id BIGSERIAL auto-key.
Response: 201 Created
Error Codes
PUT /api/v1/schemas
Update an existing schema’s metadata. Only provided fields are changed. This does not modify the underlying PostgreSQL table structure — use the field endpoints for DDL changes.Request Body
Response:
200 OK with the updated schema object including fields.
Error Codes
DELETE /api/v1/schemas
Delete a schema and drop its backing PostgreSQL table.Query Parameters
Response:
204 No Content
GET /api/v1/schemas/fields
List the fields (columns) for a single schema. Used by the Schema Joins editor and any other UI surface that needs a column list without pulling the full schema object.Query Parameters
Response:
200 OK with an array of field objects, sorted by ordinal.
400 Bad Request—schemaIdquery parameter missing404 Not Found— schema does not exist in caller’s tenant
POST /api/v1/schemas/fields
Add a column to an existing schema. ExecutesALTER TABLE ADD COLUMN.
Request Body
Response:
201 Created with the field object on success, 200 OK when upsert: true matched an existing row.
Duplicate-name handling
Withoutupsert: true, the endpoint returns 409 Conflict if a field with the
same name already exists on this schema:
PUT /api/v1/schemas/fields
Alter an existing column. ExecutesALTER TABLE RENAME COLUMN and/or
ALTER COLUMN TYPE / SET NOT NULL / DROP NOT NULL against the live table.
Request Body
Response:
200 OK with the updated field object.
Error Codes
DELETE /api/v1/schemas/fields
Remove a column from a schema. ExecutesALTER TABLE DROP COLUMN.
Query Parameters
Response:
204 No Content
POST /api/v1/schemas//primary-key
Replace the live PostgreSQLPRIMARY KEY constraint on a schema’s ds_* table and
sync each field’s isPrimaryKey flag to match. Supports composite keys (multiple
columns). PK columns are forced NOT NULL (PostgreSQL requires it).
Path Parameters
Request Body
Response — 200 OK
primaryKey echoes the columns that now form the key (["id"] when reset), and
isComposite is true when more than one column was supplied.
Error Codes
Roles
admin, editorPOST /api/v1/schemas//sync-table
Reconcile the liveds_* table with the schema’s field metadata. Use it to recover
from drift — e.g. the table was dropped, a prisma db push ran, or a backup predates
the schema’s fields. Never drops columns or tables: columns present in PostgreSQL
but absent from metadata are reported in extraColumnsInPg, not removed.
Path Parameters
No request body.
Response
Returns201 Created when the table was missing and had to be created, otherwise
200 OK. The status field distinguishes the three outcomes: "created",
"patched", or "already-in-sync".
Error Codes
Roles
admin, editorGET /api/v1/schemas//incoming-fks
List tables whose foreign-key constraints reference this schema’sds_* table.
Used by the blue_green target form to warn that a swap-table rebuild would fail
while inbound FKs still point at the old table.
Path Parameters
Response — 200 OK
Error Codes
Roles
admin, editor, viewerRoles
See also: Data Platform | Computed Values