Errors
Abillify API errors use conventional HTTP status codes to indicate the success or failure of a request. The API will return a JSON response containing an error object with details about the error.
HTTP Status Codes
| Status Code | Error Type | Description |
|---|---|---|
| 200 | Success | The request was successful, and the response contains the requested data. |
| 400 | ClientError | The request was invalid or cannot be served. This can include validation errors, missing parameters, or unsupported operations. |
| 401 | Unauthorized | Authentication failed or user does not have permissions to access the requested resource. |
| 403 | Forbidden | The user is authenticated but does not have permission to access the requested resource. |
| 404 | NotFound | The requested resource could not be found. This can occur if the resource does not exist or the user does not have access to it. |
| 409 | ERR_UNIQUE_VIOLATION | The request could not be completed due to a unique constraint violation, such as attempting to create a resource with an existing reference. |
| 429 | TooManyRequests | The user has exceeded the allowed number of requests in a given time period. This can occur if the user is making too many requests too quickly. |
| 500 | ServerError | An error occurred on the server while processing the request. This can include database errors, internal server errors, or unexpected conditions. |
Error Response
export interface Response {
/**
* Error code, e.g. 400, 404, 500, detailing the type of error.
*/
code: number;
/**
* Additional details about the error, e.g. affected fields and hints to resolve the error.
*/
details?: {
/**
* Text describing the error.
*/
error?: string;
/**
* Fields affected by the error.
*/
fields?: string[];
/**
* Hint to resolve the error.
*/
hint?: string;
}[];
/**
* Text describing the error.
*/
message: string;
/**
* Name of the error, e.g. ClientError, ServerError, detailing who caused the error.
*/
name: string;
/**
* Type of the error, e.g. ERR_NOT_FOUND, ERR_INVALID_VALUE, detailing the error type.
*/
type: string;
}Example
If a request is sent to create an invoice with an already existing invoice number, the API will return a 409 Conflict status code with a detailed error message:
{
"code": 409,
"message": "UniqueConstraintViolation, see error details",
"type": "ERR_UNIQUE_VIOLATION",
"name": "ClientError",
"details": [
{
"fields": [
"client",
"number"
],
"error": "Value for combination of fields 'client' and 'number' of the entity 'invoices' must be unique."
}
]
}