![]() |
VOOZH | about |
We use cookies to improve your experience on our site. By using our site, you are agreeing to the collection and use of data as described in our Privacy Policy.
Cookie Settings×Table of contents
API integrations can fail for a number of reasons.
Maybe you didn’t add the endpoint’s URL correctly; or you used an invalid or expired token; or you sent data in a format the API doesn’t support.
Whatever the cause, your team needs to be able to diagnose the issue swiftly, identify the appropriate steps to remediate the issue on time, and execute those steps quickly and successfully.
In short, you need to build robust error handling processes across your API integrations.
We’ll help you build these processes by breaking down an example and by highlighting several best practices worth implementing. But to get us started, let’s align on the definition of API error handling.
It’s the process of identifying and responding to a specific error from an API response with the goal of resolving the issue as quickly as possible.
API responses typically provide specific error codes and messages (e.g. “404 Not Found”), which can help your team diagnose the issue. Your team is, however, on the hook for pinpointing the solution and implementing it.
Related: What is an API response code? Here's what you need to know
To help clarify our definition, let’s break down a specific example: Say you make a GET request to an API endpoint to retrieve details on a specific employee in an HRIS solution. However, the employee doesn’t exist in the HRIS solution—leading you to receive a “Not Found” error message.
The log from this request is added to your monitoring tool. The tool then parses the log, extracts key information (e.g. the error code), and—if configured—alerts the relevant stakeholders of the error. From there, your developers can review the request to make sure it was formatted properly, analyze the error in conjunction with others to determine if it’s part of a trend, and more.
Here are just a few ways to implement error handling effectively.
API responses often include details that extend beyond the status code and error message. For example, there can be a longer message that describes the error; a timestamp that shows when the error occurred; a suggestion for addressing the error; and even a link to documentation that can help your engineers troubleshoot it.
You should configure your monitoring system so that it can capture this additional information whenever it’s available. And while it’s not always helpful, it can potentially help your engineers understand integration errors more easily, which better positions them to troubleshoot and resolve issues faster.
Related: API logging tips
In many cases, the error is on the API provider’s end. When it is, you’ll receive a 5xx error that can specify why, exactly, the server-side error occurred.
Whenever you find yourself in this situation, you can use exponential backoffs—which allow you to retry a specific API call at increasing intervals when they lead to failed requests. This gives the server time to recover, minimizes your number of failed requests, and likely saves you money, as you don’t have to make as many API calls.
Note: You should also use exponential backoffs when you receive a 429 error; this type of error indicates that you’ve sent too many requests in a certain period of time and may be violating the API provider’s rate limiting policy.
Your engineers may not see issues crop up in your monitoring tool quickly, leading the issues to persist. Moreover, there can be so many logs to sift through that your engineers may have a hard time finding the issues that they’re equipped to solve.
To address both of these issues, you can integrate your monitoring system with your business communications platform (e.g. Slack) and/or email service provider. You can then build an automation where once a log with a certain status code comes in, a notification goes out automatically to the appropriate individual or team through Slack or email.
As the engineers who manage your integrations leave, you don’t want them to take their knowledge of your error handling workflows with them. This can leave your remaining engineers poorly-positioned to manage issues when they crop up, leading the issues to go unresolved for a longer duration.
In addition, as new engineers join your team, the process of introducing them to your error handling workflows can be time-intensive for your longer-tenured engineers.
You can tackle both of these issues by tasking your engineers with documenting each error handling process. The documentation can cover specific status codes in more depth, offer concrete steps for investigating and tackling each type of error, provide previous examples, and more.
Related: API polling best practices
Your API error handling processes may not work as well as expected. Moreover, they may break or become less effective for a variety of reasons over time (e.g. the 3rd-party APIs you've built to change or undergo version updates that lead them to use new error codes or different error response formats).
To help your team spot any error handling workflows that don't perform up to par, you can review each error handling process' performance with the relevant stakeholders consistently, such as every month.
Merge, which is a single API that lets you add hundreds of integrations to your product, can automatically detect issues and provide steps for remediating them. Your customer-facing team can then pass along these steps to the affected client quickly, enabling the client to resolve the issue with little delay.
In addition, Merge offers fully-searchable logs to help you find and diagnose 5xx issues. And we provide integration maintenance—through our partner engineering team—to solve for countless edge cases across your integrations.
You can learn more about Merge’s integration management features, maintenance support, and Unified API by scheduling a demo with one of our integration experts.
In case you have more questions on API error handling, we’ve addressed a few more below:
The error codes are bucketed into 5 categories: 1xx, 2xx, 3xx, 4xx, and 5xx. Each category has a high level meaning, while the error code within a category lets you determine what, exactly, happened.
Here are some common error codes per category:
You should write tests that cover every potential issue. That way, you can evaluate each process and confirm that it works as expected. If, however, you have limited resources and can only test for a certain length of time, it’s worth prioritizing common HTTP status code errors, like 404 Not Found, 401 Unauthorized, and 503 Service Unavailable.
In addition, you should use an automated API testing tool, like Postman or SoapUI, to save your engineers’ time and perform more tests quickly.
It’s the set of steps an organization takes to monitor and address response errors. This involves deciding on the employees who need to participate and how they’re involved. And it includes alignment on the tools that are used and the capacity in which they’re leveraged.