Skip to content
On this page

Handling Errors

Sometimes sending invalid data to the API can result in errors. In this document you will find information on how to handle these errors.

Every request that does not return a 2xx or 3xx status code will be considered an error request.

The response body will contain a message property with a friendly error message.

Example

json
{
    "message": "Invalid data provided."
}

When it is a registration and the error is validation, the response body will contain an errors property with the validation errors.

json
{
    "message": "Invalid data provided.",
    "errors": {
        "to_person_type": [
            "The field to person type is required."
        ]
    }
}

Other tips

For default our API returns errors in the format, { field: [error message] }.

json
{
    "message": "Invalid data provided.",
    "errors": {
        "to_person_type": [
            "The field to person type is required."
        ]
    }
}

Using the 'Friendly-Errors' header with the value 'true' you will receive friendlier error messages.

json
{
    "message": "Invalid data provided.",
    "errors": {
        "to_person_type": [
            "The field to person type is required."
        ]
    },
    "error-messages": [
        "The field to person type is required."
    ]
}