Contract Contract protocol schemas
Standard Create Request
Source: packages/spec/src/api/contract.zod.ts
import { ApiError, BaseResponse, BatchLoadingStrategy, BulkRequest, BulkResponse, CreateRequest, DataLoaderConfig, DeleteResponse, ExportRequest, IdRequest, ListRecordResponse, ModificationResult, QueryOptimizationConfig, RecordData, SingleRecordResponse, UpdateRequest } from '@objectstack/spec/api' ;
import type { ApiError, BaseResponse, BatchLoadingStrategy, BulkRequest, BulkResponse, CreateRequest, DataLoaderConfig, DeleteResponse, ExportRequest, IdRequest, ListRecordResponse, ModificationResult, QueryOptimizationConfig, RecordData, SingleRecordResponse, UpdateRequest } from '@objectstack/spec/api' ;
// Validate data
const result = ApiError. parse (data);
Property Type Required Description code string✅ Error code (e.g. validation_error) message string✅ Readable error message category stringoptional Error category (e.g. validation, authorization) details anyoptional Additional error context (e.g. field validation errors) requestId stringoptional Request ID for tracking
Property Type Required Description success boolean✅ Operation success status error Objectoptional Error details if success is false meta Objectoptional Response metadata
Property Type Required Description strategy Enum<'dataloader' | 'windowed' | 'prefetch'>✅ Batch loading strategy type windowMs numberoptional Collection window duration in milliseconds (for windowed strategy) prefetchDepth integeroptional Depth of relation prefetching (for prefetch strategy) associationLoading Enum<'lazy' | 'eager' | 'batch'>✅ How to load related associations
Property Type Required Description records Record<string, any>[]✅ Array of records to process allOrNone boolean✅ If true, rollback entire transaction on any failure
Property Type Required Description success boolean✅ Operation success status error Objectoptional Error details if success is false meta Objectoptional Response metadata data Object[]✅ Results for each item in the batch
Property Type Required Description data Record<string, any>✅ Record data to insert
Property Type Required Description maxBatchSize integer✅ Maximum number of keys per batch load batchScheduleFn Enum<'microtask' | 'timeout' | 'manual'>✅ Scheduling strategy for collecting batch keys cacheEnabled boolean✅ Enable per-request result caching cacheKeyFn stringoptional Name or identifier of the cache key function cacheTtl numberoptional Cache time-to-live in seconds (0 = no expiration) coalesceRequests boolean✅ Deduplicate identical requests within a batch window maxConcurrency integeroptional Maximum parallel batch requests
Property Type Required Description success boolean✅ Operation success status error Objectoptional Error details if success is false meta Objectoptional Response metadata id string✅ ID of the deleted record
Property Type Required Description object string✅ Object name (e.g. account) fields [__schema1](./__schema1)[]optional Fields to retrieve where [__schema2](./__schema2)optional Filtering criteria (WHERE) search Objectoptional Full-text search configuration ($search parameter) orderBy Object[]optional Sorting instructions (ORDER BY) limit numberoptional Max records to return (LIMIT) offset numberoptional Records to skip (OFFSET) top numberoptional Alias for limit (OData compatibility) cursor Record<string, any>optional Cursor for keyset pagination joins Object[]optional Explicit Table Joins aggregations Object[]optional Aggregation functions groupBy string[]optional GROUP BY fields having [__schema2](./__schema2)optional HAVING clause for aggregation filtering windowFunctions Object[]optional Window functions with OVER clause distinct booleanoptional SELECT DISTINCT flag expand Record<string, [__schema0](./__schema0)>optional Recursive relation loading map. Keys are lookup/master_detail field names; values are nested QueryAST objects that control select, filter, sort, and further expansion on the related object. The engine resolves expand via batch $in queries (driver-agnostic) with a default max depth of 3.
Property Type Required Description id string✅ Record ID
Property Type Required Description success boolean✅ Operation success status error Objectoptional Error details if success is false meta Objectoptional Response metadata data Record<string, any>[]✅ Array of matching records pagination Object✅ Pagination info
Property Type Required Description id stringoptional Record ID if processed success boolean✅ errors Object[]optional index numberoptional Index in original request data anyoptional Result data (e.g. created record)
Property Type Required Description preventNPlusOne boolean✅ Enable N+1 query detection and prevention dataLoader Objectoptional DataLoader batch loading configuration batchStrategy Objectoptional Batch loading strategy configuration maxQueryDepth integer✅ Maximum depth for nested relation queries queryComplexityLimit numberoptional Maximum allowed query complexity score enableQueryPlan boolean✅ Log query execution plans for debugging
Property Type Required Description success boolean✅ Operation success status error Objectoptional Error details if success is false meta Objectoptional Response metadata data Record<string, any>✅ The requested or modified record
Property Type Required Description data Record<string, any>✅ Partial record data to update