We are now working on exposing our production Rest API to the outer world in order to allow the integration of different 3rd parties to our system. One of the issues we have, is that due to high scale and performance reasons, many of the API commands are handled async, so the result can't be returned directly to the caller.
For example - a deliver order
command might take some time to complete, meaning that:
- In the response body, we can't return the delivery files as they were not processed yet, but only 202
accepted
status. - We can't guarantee that on the next call to
get deliveries API
these will be ready.
We have few ideas on how to address this async problem, but we were wondering if there are some best practices for async systems exposing API. Most of them are 202 status codes or maybe a command ID
they can poll on / register to webhook, which seems tideous.
Is it acceptable for clients using these APIs to understand it takes time for the actions they perform to take place? and that a sync response will not always be available?