Skip to content

HTTP response status codes

We use a limited number of status codes to make communication between back-end and front-end easier.

422

This is a special case to display validation errors, so we need a consistent way to structure data. We used Laravel’s convention. For JSON responses, it looks like:

json
{
    "message": "The given data was invalid.",
    "errors": {
        "email": ["The email must be a valid email address."],
        "name": ["The name must be at least 2 characters.", "The name may only contain letters."]
    }
}

Where "email" and "name" are input names that have not passed validation.

Materials

How many HTTP status codes should your API use?