Responses & errors
In general, responses follow common HTTP conventions as much as possible.
| Code | Name | Explanation |
|---|---|---|
| 200 | OK | Everything went okay |
| 201 | Created | Returned when POSTing to create a new resource was successful |
| 400 | Bad Request | The request was malformed (missing parameters throw 422) |
| 401 | Unauthorized | Invalid credentials supplied |
| 422 | Unprocessable Entity | A POST data JSON key or alike is malformed or missing |
| 500 | Internal Server Error | If you encounter this, please get in touch - this should not happen |
If non-existing fields are supplied, they are simply ignored and an error will not be returned (whitelisting approach).
##Successful calls
Successful requests that result in 200 response codes will have their data inside a key named "data":
json// 200 OK
{
"data": "Response data here"
}
##Error messages
Whenever an error occurs (e.g. validation), the API will attempt to write the error message inside a key named "error":
json// 400 Bad Request
{
"error": {
"message": "Error message here",
"status_code": 400
}
}
If more than one error occurs (e.g. multiple fields fail validation), the key will be named "errors" and the relevant messages will be contained in an array:
json// 422 Bad Request
{
"errors": {
"first_name": {
"The first name field is required."
},
"email": {
"The email field is required."
},
"timezone": {
"The timezone field is required."
}
}
}