Batch Operations
Batch operations let you execute up to 1,000 operations in a single atomic request. All operations succeed together or fail together — there's no partial state.
How It Works
Send an array of operations to the batch endpoint. Each operation specifies a type and the data for that operation. The entire batch is executed within a single transaction.
Usage
rekor batch --database my-database --operations '[
{"type":"upsert_document","collection":"orders",
"data":{"customer":"Acme Corp","total":5000}},
{"type":"upsert_document","collection":"line_items",
"data":{"product":"Widget","qty":10,"price":500}},
{"type":"upsert_relationship",
"rel_type":"contains",
"source_collection":"orders","source_id":"ord_1",
"target_collection":"line_items","target_id":"li_1"}
]'
Supported Operation Types
| Type | What it does |
|---|---|
upsert_document | Create or update a document in a collection |
delete_document | Soft-delete a document |
upsert_relationship | Create or update a relationship between two documents |
delete_relationship | Delete a relationship |
upsert_collection | Create or update a collection schema |
delete_collection | Delete a collection |
When to Use Batch
- Related documents — create a parent document and its children together, ensuring both exist or neither does.
- Document + relationship — create a document and link it to another in one atomic step.
- Bulk imports — load many documents at once, with guaranteed consistency.
- Schema + data — create a collection and seed it with initial documents atomically (preview databases only for schema changes).
Limits
Maximum 1,000 operations per batch request. Each operation is validated individually — if any operation fails validation, the entire batch is rejected before any writes occur.
REST API
POST /v1/{database_id}/batch
Content-Type: application/json
{
"operations": [
{"type": "upsert_document", "collection": "orders", "data": {...}},
{"type": "upsert_relationship", "rel_type": "contains", ...}
]
}
MCP Tool
batch_operations(
database_id: "my-database",
operations: [
{type: "upsert_document", collection: "orders", data: {...}},
{type: "upsert_relationship", rel_type: "contains", ...}
]
)