Batch Operations

POST/api/batch

Execute up to 50 operations in one request, in order, with continue-on-error. Operations use the same names, arguments and per-operation permission rules as the MCP tools (e.g. customers_create, invoices_get, leads_search). Each item returns status plus result or error, with completed/failed counters in the envelope.

Headers

FieldTypeDescription
authtoken String Authentication token, generated from admin area
curl -X POST "https://yoursite.com/api/batch" \
  -H "authtoken: YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "field": "value" }'

Success-Response:

HTTP/1.1 200 OK
{
  "status": true,
  "completed": 3,
  "failed": 0,
  "results": [
    {
      "index": 0,
      "tool": "customers_create",
      "status": true,
      "result": { "status": true, "record_id": 142 }
    },
    {
      "index": 1,
      "tool": "invoices_get",
      "status": true,
      "result": {
        "id": "5",
        "clientid": "142",
        "number": "1000",
        "prefix": "INV-",
        "date": "2026-07-21",
        "duedate": "2026-08-20",
        "currency": "1",
        "subtotal": "1200.00",
        "total_tax": "0.00",
        "total": "1200.00",
        "status": "1"
      }
    },
    {
      "index": 2,
      "tool": "leads_update",
      "status": true,
      "result": { "status": true, "record_id": 88 }
    }
  ]
}

Partial-Failure-Response:

HTTP/1.1 200 OK
{
  "status": false,
  "completed": 2,
  "failed": 1,
  "results": [
    {
      "index": 0,
      "tool": "customers_create",
      "status": true,
      "result": { "status": true, "record_id": 142 }
    },
    {
      "index": 1,
      "tool": "invoices_get",
      "status": false,
      "error": "Invoice not found"
    },
    {
      "index": 2,
      "tool": "leads_update",
      "status": true,
      "result": { "status": true, "record_id": 88 }
    }
  ]
}

Validation-Error:

HTTP/1.1 422 Unprocessable Entity
{
  "status": false,
  "error": "validation_failed",
  "message": "Batch validation failed",
  "errors": {
    "operations": "Provide an operations array: [{\"tool\": \"...\", \"arguments\": {...}}]"
  }
}
MethodPOST
Path/api/batch
GroupBatch
Sincev3.0.0
Defined inmodules/api/controllers/Batch.php