Route API requests through a recipe function
API toolWorkatoRecipe Tools
What it does
When someone makes a request to this API endpoint, this automation calls a recipe function and checks the response for errors. It returns a 401 or 403 status code if those errors are found, otherwise it returns the result.
Who it's for
Engineering teams who need to route API requests through a recipe function with error handling.
How teams use this
Validate API access before processing
Route requests through the recipe function to check authentication and authorization status. Return specific error codes so the caller knows why the request failed.
Add custom request validation
Extend the recipe function to validate request parameters before processing. Include additional checks for required fields or data format constraints.
Log all API requests and responses
Capture request and response data from each API call for audit and debugging purposes. Add a logging step after the recipe function call to store logs in a centralized location.
Retry failed requests automatically
When the recipe function returns a temporary error, set retry logic with exponential backoff to attempt the request up to three times before returning the error to the caller.
How it works
- Receive the API request. Someone makes a request to this API endpoint with defined request and response parameters in Workato Api Platform.
- Call the recipe function. Invoke the recipe function in Workato Recipe Function to process the request and return a response body with status information.
- Check for authorization errors. If the response contains a 401 code, return a 401 Unauthorized status to the caller in Workato Api Platform.
- Check for permission errors. If the response contains a 403 code, return a 403 Forbidden status to the caller in Workato Api Platform.
- Return the result. Return the response from the recipe function to the caller when no error codes are present in Workato Api Platform.