REST API Notes: Status Codes

Tweet
API Programming

In this post, I'm sharing with you the criteria I follow about status codes when I design and develop REST APIs. If I'm missing some scenario, please contact me and I will include it.

200 OK

201 CREATED

202 ACCEPTED

204 NO CONTENT

400 BAD REQUEST

401 UNAUTHORIZED

403 FORBIDDEN

404 NOT FOUND

410 GONE

In many cases, this can be replaced with 404 NOT FOUND or a resource's attribute, like active: false, for isntance. It does depend on the use-case. Note that "deleted" term when designing APIs is a business term; it doesn't mean that resource doesn't exist in database, but it cannot be accessed anyway from the API.

428 PRECONDITION REQUIRED

500 SERVER ERROR