Scrivito is proudly made by JustRelate Group in Berlin, Germany, and Wrocław, Poland.
Scrivito is proudly made by JustRelate Group

Get task status

Fetches the status and result of a job executed in the background.

GET /tenants/:tenant_id/tasks/:task_id

Any of Scrivito’s API requests may be executed in the background. The response to such a request is a task response delivering a task ID. Use the task API for polling the task status. Once the background job is done, the task status contains the result of the initial action.

Params

  • tenant_id – The ID of the tenant.
  • task_id – The ID of the task.

Response

The task status. If the task succeeded, the response also includes a result, i.e. what the initial action would have returned had it been synchronous, e.g. the representation of the working copy that was created. If the task failed, the response includes error details.

Example

Example of the initial response for an API call being performed in the background, e.g. a working copy creation request:

{
  "task": {
    "id": "67e782f3dc4ec1d0156f0fa8f841c9fb",
    "status": "open"
  }
}

Get the task status:

curl \
  -X GET \
  -H 'Content-Type: application/json' \
  -u 'api_token:MYTOKEN' \
  https://api.scrivito.com/tenants/:tenant_id/tasks/:task_id

Response for a running task:

{
  "id": "67e782f3dc4ec1d0156f0fa8f841c9fb",
  "status": "open"
}

Response for a finished task – the result includes data about the created working copy:

{
  "id": "67e782f3dc4ec1d0156f0fa8f841c9fb",
  "status": "success",
  "result": {
    "created_at": "20190322170625",
    "id": "kd64c3d1ae2b25b0",
    "title": "the working copy title"
  }
}

Response for a failed task:

{
  "id": "67e782f3dc4ec1d0156f0fa8f841c9fb",
  "status": "error",
  "error": "an error message",
  "code": "the.error.code"
}