ObjectStackObjectStack

Rest Server

Rest Server protocol schemas

REST API Server Protocol

Defines the REST API server configuration for automatically generating RESTful CRUD endpoints, metadata endpoints, and batch operations.

Features:

  • Automatic CRUD endpoint generation from Object definitions
  • Standard REST conventions (GET, POST, PUT, PATCH, DELETE)
  • Metadata API endpoints
  • Batch operation endpoints
  • OpenAPI/Swagger documentation generation

Architecture alignment:

  • Salesforce: REST API with Object CRUD
  • Microsoft Dynamics: Web API with entity operations
  • Strapi: Auto-generated REST endpoints

Source: packages/spec/src/api/rest-server.zod.ts

TypeScript Usage

import { BatchEndpointsConfigSchema, CrudEndpointPatternSchema, CrudEndpointsConfigSchema, CrudOperation, EndpointRegistrySchema, GeneratedEndpointSchema, MetadataEndpointsConfigSchema, RestApiConfigSchema, RestServerConfigSchema, RouteGenerationConfigSchema } from '@objectstack/spec/api';
import type { BatchEndpointsConfig, CrudEndpointPattern, CrudEndpointsConfig, CrudOperation, EndpointRegistry, GeneratedEndpoint, MetadataEndpointsConfig, RestApiConfig, RestServerConfig, RouteGenerationConfig } from '@objectstack/spec/api';

// Validate data
const result = BatchEndpointsConfigSchema.parse(data);

BatchEndpointsConfig

Properties

PropertyTypeRequiredDescription
maxBatchSizeintegerMaximum records per batch operation
enableBatchEndpointbooleanEnable POST /data/:object/batch endpoint
operations{ createMany: boolean; updateMany: boolean; deleteMany: boolean; upsertMany: boolean }optionalEnable/disable specific batch operations
defaultAtomicbooleanDefault atomic/transaction mode for batch operations

CrudEndpointPattern

Properties

PropertyTypeRequiredDescription
methodEnum<'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'>HTTP method
pathstringURL path pattern
summarystringoptionalOperation summary
descriptionstringoptionalOperation description

CrudEndpointsConfig

Properties

PropertyTypeRequiredDescription
operations{ create: boolean; read: boolean; update: boolean; delete: boolean; … }optionalEnable/disable operations
patternsRecord<string, { method: Enum<'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'>; path: string; summary?: string; description?: string }>optionalCustom URL patterns for operations
dataPrefixstringURL prefix for data endpoints
objectParamStyleEnum<'path' | 'query'>How object name is passed (path param or query param)

CrudOperation

Allowed Values

  • create
  • read
  • update
  • delete
  • list

EndpointRegistry

Properties

PropertyTypeRequiredDescription
endpoints{ id: string; method: Enum<'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'>; path: string; object: string; … }[]All generated endpoints
totalintegerTotal number of endpoints
byObjectRecord<string, { id: string; method: Enum<'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'>; path: string; object: string; … }[]>optionalEndpoints grouped by object
byOperationRecord<string, { id: string; method: Enum<'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'>; path: string; object: string; … }[]>optionalEndpoints grouped by operation

GeneratedEndpoint

Properties

PropertyTypeRequiredDescription
idstringUnique endpoint identifier
methodEnum<'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'>HTTP method
pathstringFull URL path
objectstringObject name (snake_case)
operationEnum<'create' | 'read' | 'update' | 'delete' | 'list'> | stringOperation type
handlerstringHandler function identifier
metadata{ summary?: string; description?: string; tags?: string[]; deprecated?: boolean }optional

MetadataEndpointsConfig

Properties

PropertyTypeRequiredDescription
prefixstringURL prefix for metadata endpoints
enableCachebooleanEnable HTTP cache headers (ETag, Last-Modified)
cacheTtlintegerCache TTL in seconds
maskObjectFieldsboolean[ADR-0106 D8] Mask served object schemas to the caller's readable fields
endpoints{ types: boolean; items: boolean; item: boolean; schema: boolean }optionalEnable/disable specific endpoints

RestApiConfig

Properties

PropertyTypeRequiredDescription
versionstringAPI version (e.g., v1, v2, 2024-01)
basePathstringBase URL path for API
apiPathstringoptionalFull API path (defaults to {basePath}/{version})
enableCrudbooleanEnable automatic CRUD endpoint generation
enableMetadatabooleanEnable metadata API endpoints
enableUibooleanEnable UI API endpoints (Views, Menus, Layouts)
enableBatchbooleanEnable batch operation endpoints
enableDiscoverybooleanEnable API discovery endpoint
enableOpenApibooleanEnable OpenAPI 3.1 spec & docs viewer endpoints
enableProjectScopingbooleanEnable project-scoped routing for data/meta/AI APIs
projectResolutionEnum<'required' | 'optional' | 'auto'>Project ID resolution strategy
requireAuthneveroptional[REMOVED] api.requireAuth was removed in @objectstack/spec 17 (#3963). Anonymous access to object data is now always denied — auth is a kernel concern, not a deployment posture. Delete the key. To publish something publicly, declare it: a public form view (sharing.allowAnonymous), a share link, or book.audience: 'public' — each derives its own narrow authorization instead of opening the whole data plane. Run os migrate meta --from 16 to rewrite existing sources automatically.
documentation{ enabled: boolean; title: string; description?: string; version?: string; … }optionalOpenAPI/Swagger documentation config
responseFormat{ envelope: boolean; includeMetadata: boolean; includePagination: boolean }optionalResponse format options

RestServerConfig

Properties

PropertyTypeRequiredDescription
api{ version: string; basePath: string; apiPath?: string; enableCrud: boolean; … }optionalREST API configuration
crud{ operations?: object; patterns?: Record<string, object>; dataPrefix: string; objectParamStyle: Enum<'path' | 'query'> }optionalCRUD endpoints configuration
metadata{ prefix: string; enableCache: boolean; cacheTtl: integer; maskObjectFields: boolean; … }optionalMetadata endpoints configuration
batch{ maxBatchSize: integer; enableBatchEndpoint: boolean; operations?: object; defaultAtomic: boolean }optionalBatch endpoints configuration
routes{ includeObjects?: string[]; excludeObjects?: string[]; nameTransform: Enum<'none' | 'plural' | 'kebab-case' | 'camelCase'>; overrides?: Record<string, object> }optionalRoute generation configuration
openApi31neveroptional[REMOVED] RestServerConfig.openApi31 was removed in @objectstack/spec 17 (#4579, ADR-0049) — no runtime ever read it: the REST server forwards only api/crud/metadata/batch/routes, and the served /openapi.json is the pre-generated contract enriched with the live server URL and the registered objects, so webhook/callback definitions declared here never appeared in it. Delete the key. Config-driven OpenAPI 3.1 webhooks/callbacks documentation is a new capability and must arrive via the enforce route of ADR-0049 (a new ADR), not by re-declaring the key; for a real outbound webhook use Webhook from @objectstack/spec/automation.

RouteGenerationConfig

Properties

PropertyTypeRequiredDescription
includeObjectsstring[]optionalSpecific objects to generate routes for (empty = all)
excludeObjectsstring[]optionalObjects to exclude from route generation
nameTransformEnum<'none' | 'plural' | 'kebab-case' | 'camelCase'>Transform object names in URLs
overridesRecord<string, { enabled?: boolean; basePath?: string; operations?: Record<string, boolean> }>optionalPer-object route customization

On this page