1. Home
  2. API
  3. Batch operations

Batch operations

Starting API v2.5 we BEAR API supports batch operations for data modification.

Batch operations are allowed for POST, PUT, and DELETE requests only

To make a batch request, you can send an array of jsons (instead of json as for single request) in request body. Content type has to be application/json.

By default, batch request performed as background one, so you will be provided with background request id (bgrs_id) to be used later to get request results. Like https://apidev.bear2b.com/v2.5/bgrs/<bgrs_id>/result. To force API perform NON background request parameter bgrs=false can be provided.

Asynchronous (background) processing

E.g. for a call POST https://apidev.bear2b.com/v2.5/campaigns server returns something like this:

[
    {
      "name":"bulk test 1"
    },
    {
      "name":"bulk test 2"
    }
]

You will get background request id back:

{
    "request": "bd53a46a6aa16bf4b51de2757bb9e162"
}

You can use this request id to get result: GET https://apidev.bear2b.com/v2.5/bgrs/bd53a46a6aa16bf4b51de2757bb9e162/result and have same json as one above:

[
    {
        "status": 200,
        "body": "{
            "id":1603,
            "type":1,
            "name":"bulk test 1",
            ...
        }"
    },
    {
        "status": 200,
        "body": "{
            "id":1604,
            "type":1,
            "name":"bulk test 2",
            ...
        }"
    }
]
Was this article helpful to you? Yes No

How can we help?