Skip to content

Async Invocation

Use asynchronous invocation when a supported list request may take too long to complete synchronously. Start the job with POST {base_url}/async, store the returned reportKey, and poll GET {base_url}/async/{REPORT_KEY}/poll no more than once every 10 seconds until the server returns HTTP 200.

Standard, synchronous invocation of List methods may time out for larger data sets. In order to support these larger data sets, the API collections which may encounter this problem allow for asynchronous invocation. Those API collections which do support asynchronous invocation are documented below in each collection under the List method documentation.

In order to invoke the asynchronous List method, add the follow url suffix after the base method for the particular collection:

http
POST {base_url}/async?{query_parameters}

For example, to list punches, base_url would be /punches.

This POST call should return HTTP status 202, with a response body in the following format:

json
{ "success": true, "reportKey": "{REPORT_KEY}" }

Using the REPORT_KEY, you may then poll for the results at:

http
GET {base_url}/async/{REPORT_KEY}/poll

If poll returns HTTP status 202, that means the server is still processing the result, and you should try again later. When poll returns HTTP status 200, then the report is complete, and the response body will contain the result.

Large results ​

When a completed result is too large to return in the poll response (over about 30 MB), poll returns HTTP status 200 with a link to download it instead of the result:

json
{ "reportUrl": "{REPORT_URL}" }

Download the result with a plain GET of reportUrl, without your API token or any other Authorization header. The result is always JSON, even when you poll with XML. The link expires 15 minutes after the poll that returned it; poll again for a new link. Treat the link as opaque, and as a secret: anyone who has it can download the result until it expires.

Check for reportUrl whenever poll returns 200, since any report can grow past the limit as your data grows. Accept gzip (Accept-Encoding: gzip) on both requests, to download large results faster.

Completed results are deleted after 14 days. After that, poll returns HTTP status 404.

You should not poll more frequently than once every 10 seconds. Each poll call does count toward throttle.

FAQ ​

When should I use async instead of a normal GET list request? ​

Use async when a supported collection may return enough data to risk timing out during a normal synchronous list call.

What does HTTP 202 mean during async polling? ​

HTTP 202 Accepted means the report is still being generated. Continue polling later using the same reportKey.

How often should I poll for async results? ​

Do not poll more often than once every 10 seconds, and remember that each poll request still counts toward throttling limits.

Why did poll return reportUrl instead of the result? ​

The result is too large to return in the poll response. Download it from reportUrl within 15 minutes, as described in Large results.

Fareclock API Documentation