Control what API consumers see when a request fails by returning a clear error response instead of internal error details. API builder returns some errors on its own before your API runs, and your Response picker and error response nodes shape the rest. This article explains how to set up a custom error response and lists the error codes the platform returns.
Return a custom error response
When a step fails at run time, the Success value changes to false, and the record follows the error path that your Response picker defines. If you haven't mapped the source record, which contains the error, to the response, the response body includes internal error details and a 500 (Internal Server Error) status code by default. Map a custom message to avoid exposing them.
- Decide which failures to handle. To choose what happens when a lookup or import fails, see Failed records.
- To return a different response for a specific error, add a branch to the Response picker that matches it. See Route requests with branching and the Response picker.
- Open the error response node. Select the HTTP status code from the available codes, and enter the HTTP response body that contains your message. See Configure an API response using API builder. The platform provides a fixed set of status codes, and you can't add your own.
- Map the error message into the response. See Map data in API builder.
-
Select Preview in the API response node to see the response.
To test the error, run your API. See Test and debug your API using API builder. To review the failed request, see View API request and execution logs in API builder.
Error codes
The platform returns the following errors automatically so that consumers understand why a request failed. The platform returns the errors in the first group before your API runs.
| Scenario | Error code | Response body sent to the consumer (also in request logs) | Pre-mapped response (developer view; requires access to request logs) |
|---|---|---|---|
| The payload JSON format is incorrect; the payload isn't a plain object; the request URI length exceeds the limit; special characters appear in the invoke URL; or validation is on and the request body doesn't match its schema, or a required query parameter is missing or empty | 400 - Bad request | A single record is supported in the payload. For a schema failure, a message that names the field and the rule it broke. | N/A |
| The API token is incorrect or missing from the request header | 401 - Unauthorized | N/A | N/A |
| The request URL doesn't match any endpoint in scope of the API token, or the API is turned off | 404 - Not found | The requested URI - {{method}} {{originalUrl}} could not be found. | N/A |
| The request size is greater than 5 MB | 413 - Payload too large | API request cannot exceed 5 MB | N/A |
| The media type isn't JSON | 415 - Unsupported media type | Unexpected token <Token> is not valid JSON | N/A |
| A lookup's output exceeds 5 MB, or an unexpected processing error occurs in any step (response node, pre-map, mapping, post-map) | 422 - Unprocessable content | The record cannot be processed. Try again or contact the API publisher. | Output from a lookup exceeds 5 MB; or unexpected processing error at [stepName] step: <errorDetails> |
| Your account exceeds its API usage limit | 422 - Unprocessable content | N/A | N/A |
| Requests to an endpoint exceed the global rate limit (about 1,080,000 requests per hour) | 429 - Too many requests | Rate limit exceeded. Please try again after <X> seconds. | N/A |
| The integrator.io services are down; the response size exceeds 5 MB; a connection the API uses is offline and Immediate error for offline connections is on; validation is on and the response doesn't match its schema; or an endpoint returns a concurrency error | 500 - Internal server error | N/A; or "Response stream exceeded limit of <X> bytes"; or "One or more connections used by this API are offline. Contact the API publisher and try again later."; or "The API response didn't match its schema. Contact the API owner." | The error source, code, and message are under Execution errors in the Pre-mapped response tab of your error logs. |
| The API request node isn't configured (relative URI, HTTP method); an API response node isn't configured or mapped (no status code); an import or lookup isn't configured; a branch is dangling; or validation is on and a schema can't be checked | 501 - Not implemented | An error occurred while processing the request. Contact the API publisher and try again later. | API request node not configured; API response node not configured; <stepName> not configured; or one or more branches aren't merged back. Review the setup to ensure all branches converge. |
| The API execution takes longer than its timeout, including a request that waits for an offline connection when Immediate error for offline connections is off | 504 - API timeout | API execution took longer than expected. Please try again. | Timeout error occurred at <stepName> step. |
The timeout is the API's Override timeout or, if none is set, the organization-wide API timeout. Whether an offline connection returns 500 or 504 depends on Immediate error for offline connections. See Configure advanced API settings. For validation behavior, see Validate API requests and responses in API builder. For causes and fixes, see Troubleshoot APIs.