Job

Introduction to long-running actions

Some operations are asynchronous because they are expected to take a long time to finish, for example draft generation, export file generation, etc. Such an operation will be assigned a job whose status can be monitored using this API.

The typical scenario that requires a job follows this pattern:

  1. The App requests a long-running action via the API. The API accepts the action and returns a 202 Accepted response along with response data, including the API URL to retrieve the action status.

  2. The action status URL is used to monitor the execution status of the action. The App can send GET requests to the action status URL periodically to check if the process has been completed.

  3. Additionally, in case the App needs the API to actively send back the result data when it completes, the App can implement a Callback URL feature. This feature is optional and does not effect the monitoring mechanism explained above.

List all jobs

Get the list of all jobs that belong to the current user's group.

API Request

GET https://api.bespokify.com/v2/jobs

Request parameters

Parameter Type Required Description
orderBy string no The field to order jobs by. Possible values: startedAt, finishedAt. Default: finishedAt
sort string no The order to sort jobs in. Possible values: asc, desc. Default: desc
status string no Used to filter jobs by status. Possible values: inProgress, completed, failed

Example response

[
  {
    "id": "c141e264-b7fe-4c12-bdcf-8bb598af9395",
    "status": "completed",
    "startedAt": "2018-10-17T10:52:05.399Z",
    "startedBy": "lorem",
    "finishedAt": "2018-10-17T11:52:05.399Z"
  }
]

Get specific job

API Request

GET https://api.bespokify.com/v2/jobs/{id}

Request parameters

Parameter Type Required Description
id string yes The ID of the job

Example response

{
  "id": "0002d774-3ae6-42a4-92f7-bd8796c4ca1f",
  "status": "completed",
  "resources": [
    {
      "id": "c141e264-b7fe-4c12-bdcf-8bb598af9395",
      "type": "predict",
      "url": "https://api.bespokify.com/v2/predict/c141e264-b7fe-4c12-bdcf-8bb598af9395"
    }
  ],
  "startedAt": "2018-10-17T10:52:05.399Z",
  "startedBy": "lorem",
  "finishedAt": "2018-10-17T11:52:05.399Z"
}