Response status codes
Success
Successes differ from errors in that their body may not be a simple response object with a code and a message. The headers however are consistent across all calls:
GET
,POST
returns200 OK
on success if the information was found,POST
returns 201 on success if a new database entry was created,DELETE
returns 204, without a body, if the entry was deleted
When retrieving stuff for example:
Status: 200 OK
{
"url": "https://enke.to/abcd",
"code": 200
}
Error
Error responses are returning standard HTTP error codes along with a descriptive message:
- The error code is sent back as a status header,
- The body includes an object describing both the code and message (for debugging and/or display purposes),
For a call with an invalid API key as username in the Authorization header for example:
Status: 401 Unauthorized
{
"code": 401,
"message": "Access denied: invalid API key as username in the Authorization header.""
}
400 401 403 404 405 410