| title |
Batch |
| description |
Batch protocol schemas |
**Source:** `packages/spec/src/api/batch.zod.ts`
import { BatchConfigSchema, BatchOperationResultSchema, BatchOperationTypeSchema, BatchOptionsSchema, BatchRecordSchema, BatchUpdateRequestSchema, BatchUpdateResponseSchema, DeleteManyRequestSchema, UpdateManyRequestSchema } from '@objectstack/spec/api';
import type { BatchConfig, BatchOperationResult, BatchOperationType, BatchOptions, BatchRecord, BatchUpdateRequest, BatchUpdateResponse, DeleteManyRequest, UpdateManyRequest } from '@objectstack/spec/api';
// Validate data
const result = BatchConfigSchema.parse(data);
| Property |
Type |
Required |
Description |
| enabled |
boolean |
optional |
Enable batch operations |
| maxRecordsPerBatch |
integer |
optional |
Maximum records per batch |
| defaultOptions |
object |
optional |
Default batch options |
| Property |
Type |
Required |
Description |
| id |
string |
optional |
Record ID if operation succeeded |
| success |
boolean |
✅ |
Whether this record was processed successfully |
| errors |
object[] |
optional |
Array of errors if operation failed |
| data |
Record<string, any> |
optional |
Full record data (if returnRecords=true) |
| index |
number |
optional |
Index of the record in the request array |
create
update
upsert
delete
| Property |
Type |
Required |
Description |
| atomic |
boolean |
optional |
If true, rollback entire batch on any failure (transaction mode) |
| returnRecords |
boolean |
optional |
If true, return full record data in response |
| continueOnError |
boolean |
optional |
If true (and atomic=false), continue processing remaining records after errors |
| validateOnly |
boolean |
optional |
If true, validate records without persisting changes (dry-run mode) |
| Property |
Type |
Required |
Description |
| id |
string |
optional |
Record ID (required for update/delete) |
| data |
Record<string, any> |
optional |
Record data (required for create/update/upsert) |
| externalId |
string |
optional |
External ID for upsert matching |
| Property |
Type |
Required |
Description |
| operation |
Enum<'create' | 'update' | 'upsert' | 'delete'> |
✅ |
Type of batch operation |
| records |
object[] |
✅ |
Array of records to process (max 200 per batch) |
| options |
object |
optional |
Batch operation options |
| Property |
Type |
Required |
Description |
| success |
boolean |
✅ |
Operation success status |
| error |
object |
optional |
Error details if success is false |
| meta |
object |
optional |
Response metadata |
| operation |
Enum<'create' | 'update' | 'upsert' | 'delete'> |
optional |
Operation type that was performed |
| total |
number |
✅ |
Total number of records in the batch |
| succeeded |
number |
✅ |
Number of records that succeeded |
| failed |
number |
✅ |
Number of records that failed |
| results |
object[] |
✅ |
Detailed results for each record |
| Property |
Type |
Required |
Description |
| ids |
string[] |
✅ |
Array of record IDs to delete (max 200) |
| options |
object |
optional |
Delete options |
| Property |
Type |
Required |
Description |
| records |
object[] |
✅ |
Array of records to update (max 200 per batch) |
| options |
object |
optional |
Update options |