Skip to main content

Fetch Background Job

The Background job api gives you information about a background job that has been scheduled manually, as part of a bulk api request or through some other workflow. Please note that all the apis accept api key based token authentication and return data within the wrapper {_data:{}, _meta: {}, _errors:[]}

Example:

curl --request GET \
--url https://api.chakrahq.com/v1/ext/background-job/<background_job_id> \
--header 'authorization: Bearer <your_access_token>'

Fetch Background Job API

GET /v1/ext/background-job/<background_job_id>

The api takes no other input. It returns data in the following format

{
"_data": {
"id": "19632427-908f-4bf3-a6f5-69b9a0bbfc63",
"createdAt": 1617966536211,
"updatedAt": 1617966536211,
"startedAt": 1617966536210,
"team": "d3e64510-b75a-43a0-8ae5-dde78dac56c0",
"type": "bulk_api_job"
},
"_meta": {
"bjEntryCompletionStatusVsCount": {
"INVALID": 100,
"NOT_STARTED": 120,
"SUCCESS": 389,
"ERROR": 3

}
}
}

The _data field returns meta information around the job itself. The _meta field has extra information like

bjEntryCompletionStatusVsCount - count of all the backgroundjob entries grouped by their completion status.

INVALID - This completionStatus indicates that the entry was not valid. So it was not processed NOT_STARTED - This completionStatus indicates that the background job entry is yet to be processed SUCCESS - This completionStatus indicates that the background job entry has been processed successfully ERROR - This completionStatus indicates that the background job entry has been processed but resulted in an error result

Background Job Examples

If you use a bulk api like PATCH /v1/ext/procedure/lead/process the api will internally schedule a background job to process the entries provided to the bulk api. The response of the api will look something like this:

{
"_data": {
"id": "19632427-908f-4bf3-a6f5-69b9a0bbfc63",
"createdAt": 1617966536211,
"updatedAt": 1617966536211,
"completionStatus": "IN_PROGRESS",
"statusMessage": null,
"startedAt": 1617966536210,
"completedAt": 0,
"team": "d3e64510-b75a-43a0-8ae5-dde78dac56c0",
"type": "3ae1c371-9a3b-4c06-8090-42fea6c4df36"
}
}

The id - 19632427-908f-4bf3-a6f5-69b9a0bbfc63 in the response represnts the id of a background job

Fetch Background Job Entries API

If you want to get the status of the individual entries supplied to the background job you can do so with this api

GET /v1/ext/background-job/<background_job_id>/entries

Example

curl --request GET \
--url https://api.chakrahq.com/v1/ext/background-job/<background_job_id>/entries \
--header 'authorization: Bearer <your_access_token>'

Following are the optional parameters - which can be passed as query params

  • completionStatus - you can filter by completion status. accepted values - INVALID, NOT_STARTED, IN_PROGRESS, SUCCESS, ERROR, CANCELLED
  • limit - number of entries to return. default and max is 100
  • skip - number of entries to skip

The api returns data in the following format

{
"_data": [
{
"id": "e9bc853c-0af7-414c-bc7b-ccc7a40aa510",
"createdAt": 1617966536310,
"updatedAt": 1617966539528,
"data": {
"apiData": {
"processId": "1e50dd73-9ce6-405b-932a-9c4c5e7b5599",
"procedureId": "f3eb37a9-b54e-4088-bc5f-948d37f8aa62",
"processUpdate": {
"data": {
"lead_id": "100"
}
}
},
"apiType": "process:ext-update"
},
"validationStatus": "SUCCESS",
"validationMessage": "",
"validationResult": null,
"completionStatus": "SUCCESS",
"completionMessage": "",
"completionResult": null,
"team": "d3e64510-b75a-43a0-8ae5-dde78dac56c0",
"backgroundJob": "19632427-908f-4bf3-a6f5-69b9a0bbfc63",
"createdBy": "5acc9b3b-9850-422b-81ce-22b01cb74356"
},
{
"id": "8bbaa9b5-14d9-4594-b68f-053e362ff5b3",
"createdAt": 1617966536310,
"updatedAt": 1617966537260,
"data": {
"apiData": {
"processId": "1e50dd73-9ce6-405b-932a-9c4c5e7b5599",
"procedureId": "f3eb37a9-b54e-4088-bc5f-948d37f8aa62",
"processUpdate": {
"data": {
"lead_id": "100"
}
}
},
"apiType": "process:ext-update"
},
"validationStatus": "SUCCESS",
"validationMessage": "",
"validationResult": null,
"completionStatus": "ERROR",
"completionMessage": "",
"completionResult": null,
"team": "d3e64510-b75a-43a0-8ae5-dde78dac56c0",
"backgroundJob": "19632427-908f-4bf3-a6f5-69b9a0bbfc63",
"createdBy": "5acc9b3b-9850-422b-81ce-22b01cb74356"
}
],
"_meta": {
"total": 770,
"next": "/v1/ext/background-job/19632427-908f-4bf3-a6f5-69b9a0bbfc63/entries?skip=2limit=2"
}
}
  • _data field returns an array of background job entries
  • _meta returns meta information like total entries and the path for the next page of data