Background processing

Sometimes we have long API operations that takes minutes or even hours to be done. In that case CDN returns error 503 (Service unavailable) to the client. Which is not true because it’s just a long operation.


API continue processing of a request but responds instantly with request id so a user can periodically check the status of the request.


Any API request can be converted to background one by addings bgrs=yes. In that case API instantly respond with background request id but continue processing of current request. E.g. for request, we get something like:

{"request": "4ff7cc2d88b1de88e83cce3f1caa1509"}
To get general information about background request following call to be used:


  "id": 267,
  "rid": "4ff7cc2d88b1de88e83cce3f1caa1509",
  "user_id": 1,
  "name": "/v2.13/users/me?bgrs=yes",
  "created_dt": "2017-12-26 18:21:52",
  "status_id": 4,
  "status_name": "finished",
  "progress": 100.00,
  "finished_dt": "2017-12-26 18:21:52",
  "status": 200,
  "content_type": "application/json; charset=utf-8",
  "result": "media/keep1m.bgrs.4ff7cc2d88b1de88e83cce3f1caa1509.result.json"
To get details of the request (it can be a lot of records for long API calls; it’s not the case for our example call, though) following call can be used:


  "id": 5802,
  "rid": "4ff7cc2d88b1de88e83cce3f1caa1509",
  "dt": "2017-12-26 18:21:52",
  "details": "done"
Result of the background call can be taken using this call: Actual result depends on the original call – so in our case it will be json. For call like it will be csv file:

API doesn’t check rights to data provided by bgrs/BGR_ID/result. That means you can share results taken by you with anyone.