Back to Cheatsheets

RESTful API

API2019-07-07

Status codes

CodeDescription
200 OKSuccessful get, patch (return a JSON object)
201 CreatedSuccessful post (return a JSON object)
202 AcceptedSuccessful post, delete, path - async
204 No contentSuccessful delete
206 Partial contentSuccessful get - async

Error status

CodeDescription
401 UnauthorizedNot authenticated
403 ForbiddenAuthenticated, but no permissions
422 Unprocessable entityValidation

Errors

HTTP/1.1 401 Unauthorized
Content-Type: application/json
{
  'id': 'auth_failed',
  'message': "You're not logged in."
}

Here's an example of a possible error reply.

Versioning

GET /api/foo
Accept: application/json; version=1

You can pass a version=x to the Accept request header. Info here

Authentication

curl -is https://$TOKEN@api.example.com/

Methods

RequestDescription
GET /articles/1read, returns 200
PUT /articles/1edit (or path), returns 200
DELETE /articles/1delete, returns 200
POST /articlescreate, returns 201
GET /articleslist, returns 200

References