Responses & errors

In general, responses follow common HTTP conventions as much as possible.

CodeNameExplanation
200OKEverything went okay
201CreatedReturned when POSTing to create a new resource was successful
400Bad RequestThe request was malformed (missing parameters throw 422)
401UnauthorizedInvalid credentials supplied
422Unprocessable EntityA POST data JSON key or alike is malformed or missing
500Internal Server ErrorIf you encounter this, please get in touch - this should not happen

Successful calls:

Successful requests that result in 200 response codes will have their data inside a key named "data":

// 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":

// 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:

// 422 Bad Request
{
  "errors": {
    "first_name": [
      "The first name field is required."
    ],
    "email": [
      "The email field is required."
    ],
    "timezone": [
      "The timezone field is required."
    ]
  }
}