I am designing an API, which status code should each method return back to the client?
| HTTP Response Status | Example Use Case(s) |
|---|---|
| 200 OK | |
| 201 Created | Answer to a successful POST /resource/ |
| 202 Accepted | Answer to a successful POST /resource/ |
| 410 Gone | A resource accepted for creation was finally not created |
| 404 Not Found | A resource doesn't exist |
In REST there are Resources and Collections of resources.
This is requested through an POST /resource/ method.
Upon creation of a resource, an API can return 201 Created and then an URI to the newly created resource in the response body. A copy of the new resource in the answer is not needed. Not always the request for the creation of a resource results in the creation of the resource, but just in accepting (202 Accepted) the request. Later, the resource may be created (or not).
Links:
Created with http://www.tablesgenerator.com/markdown_tables
Preview with http://dillinger.io/