API Reference

Compliance Workflows

A core use case for the OWB API is data validation against a published schema. This enables compliance pipelines that verify your actual data conforms to the model your team has defined and published.

The pattern

  1. Define your schema in OWB and publish it
  2. Your pipeline fetches the published schema via API
  3. Your pipeline validates data records against the fetched schema
  4. Non-conforming records are flagged for review

Because the API always serves the published snapshot, your pipeline validates against the same version your team signed off on — not a moving target.

Example: validate a JSON record

import Ajv from "ajv";
 
const BASE = `${process.env.OWB_BASE_URL}/api/v1`;
const HEADERS = { Authorization: `Bearer ${process.env.OWB_API_KEY}` };
 
// 1. Fetch the JSON Schema export
const schema = await fetch(
  `${BASE}/models/${MODEL_ID}/export/json-schema`,
  { headers: HEADERS }
).then((r) => r.json());
 
// 2. Compile with AJV
const ajv = new Ajv({ allErrors: true });
const validate = ajv.compile(schema);
 
// 3. Validate a data record
const record = {
  name: "Wireless Headphones",
  price: 79.99,
  sku: "WH-100",
};
 
const valid = validate(record);
if (!valid) {
  console.error("Validation errors:", validate.errors);
}

Example: verify Prisma schema is in sync

Use the Prisma export to diff your live schema.prisma against the OWB-published version in CI:

#!/bin/bash
# In your CI pipeline:
 
# Fetch the authoritative schema from OWB
curl -s "$OWB_BASE_URL/api/v1/models/$MODEL_ID/export/prisma" \
  -H "Authorization: Bearer $OWB_API_KEY" \
  -o /tmp/owb-schema.prisma
 
# Diff against the committed schema
diff prisma/schema.prisma /tmp/owb-schema.prisma
 
if [ $? -ne 0 ]; then
  echo "ERROR: Prisma schema diverged from OWB model. Update the schema."
  exit 1
fi

Example: build a validation report

async function buildReport(modelId: string, records: unknown[]) {
  const BASE = `${process.env.OWB_BASE_URL}/api/v1`;
  const HEADERS = { Authorization: `Bearer ${process.env.OWB_API_KEY}` };
 
  // Fetch entity types
  const { data: entityTypes } = await fetch(
    `${BASE}/models/${modelId}/entity-types`,
    { headers: HEADERS }
  ).then((r) => r.json());
 
  // Check required fields are present
  const requiredFields = entityTypes
    .flatMap((et: { properties: Array<{ name: string; required: boolean }> }) =>
      et.properties.filter((p) => p.required).map((p) => p.name)
    );
 
  const violations = records
    .map((record, idx) => {
      const missing = requiredFields.filter(
        (f: string) => !(f in (record as Record<string, unknown>))
      );
      return missing.length ? { record: idx, missing } : null;
    })
    .filter(Boolean);
 
  return { total: records.length, violations };
}

Caching recommendations

Published schemas are stable — they only change when a new version is published. Cache the export responses aggressively:

  • In CI: cache per model + publish timestamp (use the publishedAt field from GET /models/{id})
  • In long-running services: re-fetch on startup and when validation failure rates spike unexpectedly