Batch

Get all Batches

GET /batches

Query string parameters

Response
Status code 200

{
  "data": [
    {
      "id": "11bb85bd-9bf9-4589-8ede-418b62855517",
      "created_at": "2017-03-23 09:37:35",
      "updated_at": "2017-03-23 09:37:35",
      "completed": 2,
      "completed_at": "2017-03-23 09:37:35"
    },
    {
      "id": "f9d23b7d-5f99-4ac5-b184-ae2d54dd103c",
      "created_at": "2017-03-23 10:11:55",
      "updated_at": "2017-03-23 10:11:55",
      "completed": 0,
      "completed_at": null
    }
  ],
  "pagination": {
    "total": 2,
    "page": 1,
    "per_page": 15,
    "urls": {
      "previous": null,
      "next": null
    }
  }
}

Get Specific Batch

GET /batches/:batch_id

Response
Status code 200

{
  "id": "70ae4bfb-677a-422e-9b45-fc016759eff8",
  "created_at": "2017-03-23 10:20:41",
  "updated_at": "2017-03-23 10:20:47",
  "completed": 2,
  "completed_at": "2017-03-23 10:20:47",
  "operations": [
    {
      "id": "52147066-abbc-45b6-ab73-e12385946363",
      "request_path": "accounts",
      "request_method": "POST",
      "request_body": {
        "user_id": 1,
        "fixed_fields": [
          {
            "name": "name",
            "value": "Test Account"
          }
        ]
      },
      "response_status_code": 201,
      "response_body": {
        "id": "0aef9be1-3005-404f-b14f-0daf265edb16",
        "b2c": false,
        "fixed_fields": [
          {
            "id": 1,
            "type": "text",
            "name": "name",
            "label": "Name",
            "value": "Test Account",
            "validation": null,
            "required": true,
            "hidden": false,
            "read_only": false,
            "sort_order": 0
          }
        ],
        "created_at": "2017-03-23 10:20:46",
        "updated_at": "2017-03-23 10:20:46",
        "latest_activity_at": null
      },
      "created_at": "2017-03-23 10:20:41",
      "updated_at": "2017-03-23 10:20:46",
      "completed_at": "2017-03-23 10:20:46"
    },
    {
      "id": "76461b63-4216-43e4-99f4-90c4baea6ccf",
      "request_path": "me",
      "request_method": "GET",
      "request_body": null,
      "response_status_code": 200,
      "response_body": {
        "id": 1,
        "first_name": "Jane",
        "last_name": "Doe",
        "phone_number": "+4588888888",
        "job_title": "Sales Executive",
        "email": "demo@easir.com",
        "created_at": "2014-01-01 12:45:56",
        "updated_at": "2017-03-22 09:06:41"
      },
      "created_at": "2017-03-23 10:20:41",
      "updated_at": "2017-03-23 10:20:47",
      "completed_at": "2017-03-23 10:20:47"
    }
  ]
}

Note: The response_body contents have been shortened for demonstration purposes.

Create Batch

POST /batches

After creating the batch, each operation will be processed in the background. You can use the GET /batches/:batch_id to check the status and whether there were errors.

Completed batches will be automatically removed after 24 hours.

  • Max 50 operations can be created per batch request.
  • Currently, paths starting with the following cannot be used: filemanager, batches.

Parameters

  • operations array
    • operations.*.request_path string
    • Required
    • operations.*.request_method
    • Required
    • Can be GET, POST, PUT, DELETE
    • operations.*.request_body JSON
      • Must be valid JSON

Deprecated parameters

  • operations.*.request_body string. Use JSON representation.

Payload

{
  "operations": [
    {
      "request_path": "accounts",
      "request_method": "POST",
      "request_body": {
        "user_id": 1,
        "fixed_fields": [
          {
            "name": "name",
            "value": "Test Account"
          }
        ]
      }
    },
    {
      "request_path": "me",
      "request_method": "GET"
    }
  ]
}

Response
Status code 202

{
  "id": "f91fb42f-a0cd-4da0-af3f-1befa3cc79f9",
  "created_at": "2017-03-23 10:27:02",
  "updated_at": "2017-03-23 10:27:02",
  "completed": 0,
  "completed_at": null,
  "operations": [
    {
      "id": "65fe42ef-6227-4721-85b4-678212c8f48d",
      "request_path": "accounts",
      "request_method": "POST",
      "request_body": {
        "user_id": 1,
        "fixed_fields": [
          {
            "name": "name",
            "value": "Test Account"
          }
        ]
      },
      "response_status_code": null,
      "response_body": null,
      "created_at": "2017-03-23 10:27:02",
      "updated_at": "2017-03-23 10:27:02",
      "completed_at": null
    },
    {
      "id": "e9686ed8-1424-40b0-90e6-6385360f15c0",
      "request_path": "me",
      "request_method": "GET",
      "request_body": null,
      "response_status_code": null,
      "response_body": null,
      "created_at": "2017-03-23 10:27:02",
      "updated_at": "2017-03-23 10:27:02",
      "completed_at": null
    }
  ]
}