REST API
Beginner
1 min read
Batch Operations and Custom Actions
Example
# Custom actions as sub-resources (POST)
POST /invoices/88/send # send invoice by email
POST /orders/55/cancel # cancel an order
POST /users/42/password-reset # trigger password reset
POST /notifications/mark-all-read
# Bulk operations
PATCH /products HTTP/1.1
Content-Type: application/json
{
"ids": [1, 2, 3],
"update": { "status": "archived" }
}
# Response: 200 OK
# { "updated": 3 }
# JSON Patch (RFC 6902) — fine-grained patch document
PATCH /users/42 HTTP/1.1
Content-Type: application/json-patch+json
[
{ "op": "replace", "path": "/email", "value": "new@example.com" },
{ "op": "add", "path": "/tags/-", "value": "premium" },
{ "op": "remove", "path": "/legacyField" },
{ "op": "test", "path": "/version", "value": 3 }
]
# "test" op: if /version != 3, the entire patch is rejected (optimistic locking)
# Response: 200 OK + updated user, or 409 Conflict if test fails