Batch Operations
Batch Operations Guide
The Batch API lets you send multiple /do calls in a single request. Operations run in parallel, reduce rate limit consumption, and optionally execute as an all-or-nothing transaction.
Batch Request Format
Send an array of operations to the /do/batch endpoint. Each operation has the same face, action, payload shape as a regular /do call.
POST https://api.evileye.dev/do/batch
Content-Type: application/json
Authorization: Bearer sk_live_...
{
"operations": [
{
"face": "auth",
"action": "create-user",
"payload": { "email": "alice@acme.com", "role": "admin" }
},
{
"face": "auth",
"action": "create-user",
"payload": { "email": "bob@acme.com", "role": "member" }
},
{
"face": "auth",
"action": "assign-role",
"payload": { "email": "alice@acme.com", "role": "billing-admin" }
}
],
"options": {
"transaction": false
}
}Batch Response
The response contains a results array with per-operation status, data, and timing. Results are returned in the same order as the operations.
{
"results": [
{
"status": "success",
"data": { "userId": "usr_abc", "email": "alice@acme.com" },
"meta": { "timing": 45 }
},
{
"status": "success",
"data": { "userId": "usr_def", "email": "bob@acme.com" },
"meta": { "timing": 38 }
},
{
"status": "success",
"data": { "assigned": true },
"meta": { "timing": 22 }
}
],
"meta": {
"totalTiming": 105,
"requestId": "req_batch_xyz789"
}
}SDK Batch Usage
The SDK provides a typed ee.batch() method. Each result in the destructured array is typed to its corresponding operation.
const results = await ee.batch([
ee.auth.createUser({ email: 'alice@acme.com', role: 'admin' }),
ee.auth.createUser({ email: 'bob@acme.com', role: 'member' }),
ee.auth.assignRole({ email: 'alice@acme.com', role: 'billing-admin' }),
])
// Each result is typed to its operation
const [alice, bob, roleAssignment] = results
console.log(alice.data.userId) // usr_abcTransaction Support
Pass transaction: true to enable all-or-nothing mode. If any operation fails, all previously successful operations are rolled back.
// All-or-nothing: if any operation fails, all are rolled back
const results = await ee.batch(
[
ee.billing.createSubscription({ plan: 'business', entity: 'acme' }),
ee.auth.createUser({ email: 'admin@acme.com', role: 'owner' }),
ee.storage.createBucket({ name: 'acme-uploads' }),
],
{ transaction: true },
)Limits
| Limit | Value |
|---|---|
| Max operations per batch | 100 |
| Max request body size | 10 MB |
| Timeout per operation | 30s |
| Total batch timeout | 120s |
Related
- API Reference— single /do endpoint documentation
- Rate Limits— batch calls count as a single rate limit hit