Notes on RESTful API Design
This is a list of return codes in relation to a RESTful API design.
Some of the operations has more that one outcome, so you need to decide on what you find the most appropriate one.
Operation | HTTP Method | STATUS CODE ON SUCCESS | Notes |
---|---|---|---|
Create | POST | 201 Created | When the object is created immediately |
202 Accepted | When the object is accepted but not created immediately</td</tr> | ||
Read | GET | </td>200 OK | When the object requested in included in the response |
Update | PUT | 200 OK | When the updated object is returned as part of the response |
204 No Content | When the updated object is not returned as part of the response | ||
PATCH | 200 OK | When the updated object is returned as part of the response | |
204 No Content | When the updated object is not returned as part of the response | ||
Delete | DELETE | 200 OK | When an object changes status to deleted or similar |
202 Accepted | When an object changes status to deleted or similar and is deleted a part of a garbage collection process or similar | ||
204 No Content | When an object is deleted immediately |
Operation | HTTP Method | STATUS CODE ON ERROR |
---|---|---|
Create | POST | 409 Conflict |
422 Unprocessable Content | ||
Read | GET | </td>404 Not Found |
Update | PUT | 404 Not Found |
409 Conflict | ||
PATCH | 404 Not Found | |
Delete | DELETE | 404 Not Found |