Skip to content

Bulk Operations

Perform batch create, update, or delete operations in a single request. Bulk endpoints process each item independently — individual failures don't prevent other items from succeeding.

Endpoints

MethodEndpointDescription
POST/{entity}/bulkCreate multiple records
PUT/{entity}/bulkUpdate multiple records
DELETE/{entity}/bulkDelete multiple records

Batch Limits

  • Maximum batch size: 100 items per request
  • Empty arrays return 400 BAD_REQUEST
  • Arrays exceeding 100 items return 400 BAD_REQUEST

Bulk Create

Create multiple records at once. Each item is validated and persisted independently.

Request:

bash
curl -X POST ".../api/v1/acme-corp/sales/customers/bulk" \
  -H "Authorization: Bearer sk_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '[
    { "name": "Alice", "email": "alice@example.com" },
    { "name": "Bob", "email": "bob@example.com" },
    { "name": "Charlie", "email": "charlie@example.com" }
  ]'

Response (200):

json
{
  "succeeded": 3,
  "failed": 0
}

Bulk Update

Update multiple records. Each item must include the primary key field (id).

Request:

bash
curl -X PUT ".../api/v1/acme-corp/sales/customers/bulk" \
  -H "Authorization: Bearer sk_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '[
    { "id": 1, "name": "Alice Updated" },
    { "id": 2, "email": "bob-new@example.com" }
  ]'

Response (200):

json
{
  "succeeded": 2,
  "failed": 0
}

Bulk Delete

Delete multiple records by ID.

Request:

bash
curl -X DELETE ".../api/v1/acme-corp/sales/customers/bulk" \
  -H "Authorization: Bearer sk_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '[1, 2, 3]'

Response (200):

json
{
  "succeeded": 3,
  "failed": 0
}

Partial Success

Bulk operations always return 200 OK, even when some items fail. The response reports how many succeeded and failed, with per-item error details.

Example — 1 of 3 items fails validation:

bash
curl -X POST ".../api/v1/acme-corp/sales/customers/bulk" \
  -H "Authorization: Bearer sk_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '[
    { "name": "Alice", "email": "alice@example.com" },
    { "email": "missing-name@example.com" },
    { "name": "Charlie" }
  ]'

Response (200):

json
{
  "succeeded": 2,
  "failed": 1,
  "errors": [
    {
      "index": 1,
      "error": {
        "code": "VALIDATION_ERROR",
        "message": "Validation failed: 1 error(s)",
        "details": [{ "field": "name", "message": "name is required" }]
      }
    }
  ]
}

Per-Item Error Codes

Each failed item includes an error with one of these codes:

CodeDescription
VALIDATION_ERRORField validation failed (with details array)
NOT_FOUNDRecord with given ID not found (update/delete)
UNIQUE_CONSTRAINT_VIOLATIONDuplicate value for a unique column
BAD_REQUESTMissing primary key or other request issue
INTERNAL_ERRORUnexpected database error

Error Responses (Non-Partial)

These errors return standard error responses (not the bulk format):

StatusWhen
400Empty array or batch size exceeds 100
401Missing or invalid API key
403Read-only API key or wrong workspace
404Entity not found

SchemaStack Documentation