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 { BatchEndpointsConfig, Callback, CrudEndpointPattern, CrudEndpointsConfig, CrudOperation, EndpointRegistry, GeneratedEndpoint, MetadataEndpointsConfig, OpenApi31Extensions, RestApiConfig, RestServerConfig, RouteGenerationConfig } from '@objectstack/spec/api';
import type { BatchEndpointsConfig, Callback, CrudEndpointPattern, CrudEndpointsConfig, CrudOperation, EndpointRegistry, GeneratedEndpoint, MetadataEndpointsConfig, OpenApi31Extensions, RestApiConfig, RestServerConfig, RouteGenerationConfig } from '@objectstack/spec/api';

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

BatchEndpointsConfig

Properties

PropertyTypeRequiredDescription
maxBatchSizeintegerMaximum records per batch operation
enableBatchEndpointbooleanEnable POST /data/:object/batch endpoint
operationsObjectoptionalEnable/disable specific batch operations
defaultAtomicbooleanDefault atomic/transaction mode for batch operations

Callback

Properties

PropertyTypeRequiredDescription
namestringCallback identifier (snake_case)
expressionstringRuntime expression (e.g., {$request.body#/callbackUrl})
methodEnum<'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'>HTTP method for callback request
urlstringCallback URL template with runtime expressions

CrudEndpointPattern

Properties

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

CrudEndpointsConfig

Properties

PropertyTypeRequiredDescription
operationsObjectoptionalEnable/disable operations
patternsRecord<string, Object>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
endpointsObject[]All generated endpoints
totalintegerTotal number of endpoints
byObjectRecord<string, Object[]>optionalEndpoints grouped by object
byOperationRecord<string, Object[]>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
metadataObjectoptional

MetadataEndpointsConfig

Properties

PropertyTypeRequiredDescription
prefixstringURL prefix for metadata endpoints
enableCachebooleanEnable HTTP cache headers (ETag, Last-Modified)
cacheTtlintegerCache TTL in seconds
endpointsObjectoptionalEnable/disable specific endpoints

OpenApi31Extensions

Properties

PropertyTypeRequiredDescription
webhooksRecord<string, Object>optionalOpenAPI 3.1 webhooks (top-level webhook definitions)
callbacksRecord<string, Object[]>optionalOpenAPI 3.1 callbacks (async response definitions)
jsonSchemaDialectstringJSON Schema dialect for schema definitions
pathItemReferencesbooleanAllow $ref in path items (OpenAPI 3.1 feature)

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
documentationObjectoptionalOpenAPI/Swagger documentation config
responseFormatObjectoptionalResponse format options

RestServerConfig

Properties

PropertyTypeRequiredDescription
apiObjectoptionalREST API configuration
crudObjectoptionalCRUD endpoints configuration
metadataObjectoptionalMetadata endpoints configuration
batchObjectoptionalBatch endpoints configuration
routesObjectoptionalRoute generation configuration
openApi31ObjectoptionalOpenAPI 3.1 extensions configuration

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, Object>optionalPer-object route customization

On this page