This is the documentation for 2021-02-23 but the latest version is 2022-02-01. You can switch versions in the menu.

Pooling

If a task takes longer than the request timeout limit, the request is acknowledged by a 202 Accepted and treated as a background job.

You don't get the requested data directly, instead you get the URL of the background job in the Location header, which shows you the background job status.

A far more efficient way to get the desired data are Webhooks.

Query job status

You need to check this URL periodically to check when the background job is finished.

When the background job is completed, a 200 OK is returned and the response body filled the resource_url to complete the next step. If not, a 202 Accepted will still be returned and the resource_url will remain empty.

Examples

Create a long running task

Request

POST /variant/1/design HTTP/1.1

Response

HTTP/1.1 202 Accepted
Location: https://api.smake.io/v2/jobs/1

The job is not finished.

Request

GET /jobs/1 HTTP/1.1

Response

Location: https://api.smake.io/v2/jobs/1
{
    "id": 1,
    "is_test": true,
    "resource_url": null,
    "state": "queued"
}

The job is finished.

Request

GET /jobs/1 HTTP/1.1

Response

{
    "id": 1,
    "is_test": true,
    "resource_url": "https://api.smake.io/v2/custom-variants/2",
    "state": "finished"
}