Batch Update
Batch Operations
Batch Update
Update multiple documents matching IDs or filter criteria
PUT
Batch Update
Overview
The batch update endpoint allows you to update multiple documents in a single request using either an array of document IDs or a filter query. All matched documents are updated with the same field values.Request
The name of the collection containing the documents to update
Array of document IDs to update. Either
ids or filter must be provided.Maximum: 1000 IDs (configurable)MongoDB-style filter query to match documents. Either
ids or filter must be provided.Object containing the fields to update and their new values
Update by IDs Example
Update by Filter Example
Response
Number of documents that matched the filter criteria
Number of documents that were actually modified (may be less than matched if documents already had the update values)
Array of failures (currently unused for batch updates, reserved for future use)
Response Example
Update Behavior
Automatic Fields
All updates automatically set:updated_at: Current UTC timestampupdated_by: Authenticated user’s ID
handlers_batch.go:427-428
Field-Level Permissions
Users cannot update fields in their role’sdeny_write list. The operation is rejected if any denied field is included in the update.
From handlers_batch.go:363-373
Version Snapshots
For collections with versioning enabled, a snapshot of each document is saved before the update. Fromhandlers_batch.go:414-424
RBAC Filter Combination
The provided filter/IDs are combined with RBAC query filters to ensure users can only update documents they have permission to access. Fromhandlers_batch.go:408-411
Filter Query Syntax
Thefilter parameter supports MongoDB query operators:
$eq,$ne: Equal, not equal$gt,$gte,$lt,$lte: Comparison operators$in,$nin: Array membership$and,$or,$not: Logical operators$exists: Field existence check
Validation
- Permission Check: User must have
updatepermission for the collection - Schema Validation: Update data is validated against the schema (partial validation)
- Deny Write Fields: Update is rejected if it includes fields the user cannot modify
- Batch Size: Maximum 1000 IDs if using
idsparameter
Error Responses
Error code:
collection_not_found: Collection does not existforbidden: User lacks update permission or attempts to modify denied fieldsbad_request: Invalid request (missing ids/filter, empty update, invalid IDs)internal_error: Database operation failed
Human-readable error message
Additional error context
Error Example
Code Reference
Implementation:pkg/api/handlers_batch.go:302-459
Related Endpoints
- Batch Create - Create multiple documents
- Batch Delete - Delete multiple documents
- Update Document - Update a single document