# Errors

The Understory API can return errors in several cases.
These can be the result of an incorrect action from the client or a server-side incident.

In general whenever the API returns status codes between `400 - 599` a JSON body payload will be in the response containing details about the error.


```json Invalid response example
{
  "code": "INTERNAL_SERVER_ERROR",
  "message": "Internal server error occurred while handling the request"
}
```

The `code` field will contain a unique code that identifies the issue.
This is intended for machine-reading and is considered an enum value.

The `message` field will contain a human readable description of the issue and possibly guidlines for resolving it.

## Error codes

Here is a list of error codes that you can encounter when interacting with the API.

| Code | Description |
|  --- | --- |
| `INTERNAL_SERVER_ERROR` | An internal server error occurred while handling the request. |
| `UNAUTHORIZED` | Authentication was not successful or authorization for the resource was not successful. |