Asynchronous APIs
Asynchronous APIs enable the client to send a request and continue with other tasks without waiting for an immediate response. The server processes the request in the background and responds upon completion.
This approach offers several benefits, including higher scalability, efficient resource usage, and non-blocking operations.
OS1 simplifies implementation complexity by providing clients with the option to consume API callbacks through:
TIP: Designing applications with Async APIs is different from designing with Sync APIs. In rare cases the API might fail asynchronously! Use custom validation plugins to rule out any possibility of delayed/lazy failure. Use appropriate UI design for listing to reflect the difference between tentatively added/modified data objects from definitively added/modified data objects.
Additionally you can also setup callbacks for your asynchronous requests,
Follow the steps below to receive asynchronous updates:
Define a unique callback URL in your application that will receive the updates. Then, ensure the URL is publicly available and can handle incoming HTTP requests.
To listen to updates, send an API request to OS1 specifying your callback URL where we'll send the requested information.
See the sample request below for creating a Container:
Once we receive and process the API request, our system sends an update about the requested information to the defined callback URL with the following information:
- Event type: The type of event that triggered the update.
- Service: The event’s service type (Participant, Container, or Entity).
- Data: The data associated with the event.
Lastly, configure your app to handle callbacks using the following:
Your app should parse the incoming POST request to extract the event information when receiving a callback.
See the example below of the response payload sent to the callback URL for the Container creation mentioned above:
Based on the type of event and service, your app should perform the appropriate action, such as displaying a notification or triggering a specific workflow.
Once your app processes the update, your app should send one of the following HTTP responses acknowledging that the callback was accepted:
- 200
- 202
The Callback feature is used in different services of OS1. Signature verification is implied in the Callback system to prevent unexpected and unauthenticated loads on that service. Whenever a callback is received it can be verified at OS1.
- It provides the ability to register a token/secret.
- Return an HMAC signature with every callback.