Skip to main content
In this guide, we will talk about what happens when something goes wrong while you work with the API. Let’s look at some status codes and error types you might encounter. 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 type and error message to figure out what has gone wrong and do some rudimentary debugging.

Error Codes

Here is a list of the different categories of status codes returned by the Nightly API. Use these to understand if a request was successful.
CodeDescription
2xxA 2xx status code indicates a successful response.
4xxA 4xx status code indicates a client error. This could be a data validation error on your end.
5xxA 5xx status code indicates a server error. This is a problem on our end and an engineer has been paged to investigate.

Error Types

Any HTTP status codes greater than 399 will have an error body returned. The error body has the following shape:
{
  "error": true,
  "data": [
    {
      "code": "nly_err_1",
      "name": "NO_AUTH",
      "description": "Please provide a valid Authorization header."
    }
  ]
}
No other API responses will have a top-level property called error, so you can also look for the presence of this property to determine if an error has occurred.
Our libraries handle checking for errors automatically.