Handling asynchronous requests
When dealing with large amounts of data resulting in a timeout, or when a request is asked for specifically to be asynchronous - Lean will fallback to an asynchronous workflow.
When this happens instead of returning a payload, our response to your request will have a status of PENDING
and a results_id
.
{
"status": "PENDING",
"results_id": "6dd9c7d2-1c8c-4862-bb1f-fcf52f5033d4",
"message": "Results not yet returned. Please try again later",
"timestamp": "2020-07-31T07:11:39.862804Z"
}
When the requirements of this request have been satisfied, a webhook will be sent to your system with a type of results.ready
{
"type": "results.ready",
"payload": {
"id": "6dd9c7d2-1c8c-4862-bb1f-fcf52f5033d4", // results_id
}
"message": "Your results are ready.",
"timestamp": "2021-01-08T18:05:19.244672Z"
}
You can now fetch your results with a GET
request:
curl -X GET 'https://sandbox.leantech.me/v1/results/6dd9c7d2-1c8c-4862-bb1f-fcf52f5033d4' \
--header 'Content-Type: application/json' \
--header 'lean-app-token: YOUR_APP_TOKEN' \
Updated 4 months ago