Create Schema

POST /workspaces/{slug}/schemas

Creates a new schema family with v1, or creates a new version if the definition hash differs from the latest version.

Path Parameters

slug string required

Body Parameters

schemaKey string required
name string required
description string
definition object required
curl -X POST \
-H "x-api-key: dsk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"schemaKey": "invoice",
"name": "My Workspace",
"description": "Invoice processing workspace",
"definition": {}
}' \
https://api.tracore.io/workspaces/my-workspace/schemas
import { TracoreClient } from '@tracore/sdk';

const client = new TracoreClient({ apiKey: 'dsk_your_api_key' });

const schema = await client.schemas.create('my-workspace', {
schemaKey: 'invoice',
name: 'Invoice Schema',
definition: {
  type: 'object',
  properties: {
    invoiceNumber: { type: 'string' },
    total: { type: 'number' },
  },
},
});
console.log(schema);
200 Response
{
  "id": "ws_abc123",
  "workspaceId": "ws_abc123",
  "schemaKey": "invoice",
  "name": "My Workspace",
  "description": "Invoice processing workspace",
  "latestVersionNumber": 1,
  "createdAt": "2024-03-15T10:30:00Z",
  "updatedAt": "2024-03-15T10:30:00Z",
  "latestVersion": {
    "id": "ws_abc123",
    "familyId": "sf_abc123",
    "versionNumber": 1,
    "definitionHash": "sha256:a1b2c3d4e5f6...",
    "definition": {
      "key": "value"
    },
    "createdAt": "2024-03-15T10:30:00Z"
  }
}