How do you design REST APIs for bulk operations?
Answer
Bulk operations allow clients to create, update, or delete multiple resources in a single request, reducing round trips. Common approaches: Batch create: POST /users/batch with an array of user objects in the body — return 207 Multi-Status with per-item success/failure. Bulk update: PATCH /orders with { "ids": [1,2,3], "status": "shipped" } — update a field on multiple resources. Bulk delete: DELETE /users with { "ids": [1,2,3] } in the body (non-standard but pragmatic). Return a 207 Multi-Status response that details the outcome per item: success, partial failure, or total failure. Set a reasonable limit on batch size (e.g., 100 items per request) to prevent resource exhaustion. Process items transactionally (all or nothing) or individually (return per-item errors) based on business requirements.
Previous
What are the best practices for designing API SDKs?
Next
What is sparse fieldsets and response compression in REST API performance?
More REST API Design Questions
View all →- Intermediate What is HATEOAS and how is it implemented?
- Intermediate What are the main API versioning strategies in REST and what are their tradeoffs?
- Intermediate What are the pagination strategies in REST APIs?
- Intermediate What is rate limiting and how is it communicated in REST APIs?
- Intermediate How does HTTP caching work in REST APIs with ETag and Cache-Control?