Errors
In this guide, we will talk about what happens when something goes wrong while you work with the API. Understanding how to handle errors is an important part of working with any API.
You can tell if your request was successful by checking the status code when receiving an API response. If a response comes back unsuccessful, you can use the error message to understand what went wrong and debug the issue.
Before reaching out to support with an error, please carefully check your code and the error message to ensure you understand the cause of the error.
Status codes
Here is a list of the different categories of status codes returned by the Utopian Labs API. Use these to understand if a request was successful.
- Name
2xx
- Description
- A 2xx status code indicates a successful response.
- Name
4xx
- Description
- A 4xx status code indicates a client error, meaning there was an issue with the request.
- Name
5xx
- Description
- A 5xx status code indicates a server error.
Error Response Format
When a request is unsuccessful, the Utopian Labs API will return an error response with an error message. The error message will help you understand what went wrong and how to fix it.
The error response will contain an error
field with a string message describing the error.
Error response
{
"error": "Invalid API key provided"
}