Handle Errors
When interacting with our API, it's crucial to handle errors gracefully. Our API uses a consistent JSON structure to communicate errors, ensuring that your application can parse them programmatically.
When a request fails, you'll receive a JSON response body following the structure detailed below.
Error Object Structure
| Field | Type | Description |
|---|---|---|
status | number | The HTTP status code associated with the error. |
code | string | A machine-readable error code for programmatic handling. |
message | string | A human-readable message providing a summary of the error. |
errors | object | (Optional) An object where each key is a form field and the value is an array of string error messages for that field. This is typically present for validation errors (e.g., HTTP 400). |
Example Error Response
This example shows a validation error response. Note how the errors object provides specific feedback for the email and password fields.
{
"status": 400,
"code": "validation_error",
"message": "The validation fail for the given input.",
"errors": {
"email": ["Email is invalid."],
"password": ["Password must be at least 8 characters."]
}
}