Skip to main content

Schemas

Vertical metadata schema definitions. Schemas allow you to define custom metadata structures for assets within specific verticals, providing type validation and standardization across your organization.

Methods​

Method (TypeScript)Method (Python)DescriptionHTTP
create(schema)create(schema)Create new schemaPOST /schemas
get(schemaId)get(schema_id)Retrieve schema by IDGET /schemas/{id}
list(options?)list(options=None)List schemasGET /schemas
update(schemaId, schema)update(schema_id, schema)Update schema definitionPATCH /schemas/{id}
delete(schemaId)delete(schema_id)Delete schemaDELETE /schemas/{id}
validate(schemaId, data)validate(schema_id, data)Validate data against schemaPOST /schemas/{id}/validate

Example​

import { OptropicClient } from 'optropic';

const client = new OptropicClient({ apiKey: 'optr_live_...' });

// Create a schema for electronics vertical
const schema = await client.schemas.create({
name: 'Electronics Product',
vertical: 'electronics',
fields: [
{ name: 'sku', type: 'string', required: true },
{ name: 'manufacturer', type: 'string', required: true },
{ name: 'warranty_months', type: 'number', required: false },
{ name: 'certifications', type: 'array', items: 'string' }
]
});

// Validate data against schema
const validation = await client.schemas.validate(
schema.id,
{ sku: 'SKU-123', manufacturer: 'TechCorp' }
);

console.log(`Valid: ${validation.isValid}`);