The following is guidelines prescribing what HTTP method to use for common “business functions” and what status codes to return for the happy case. If a header is to be returned, an example is given.
Function | HTTP Method | Status Code | Header | Comment |
---|---|---|---|---|
List | GET /foos/ | 200 OK | Collection in response. 200 Ok even if empty collection | |
Create | POST /foos/ | 201 Created | Location: /foos/1234 | No body in response |
Get | GET /foos/1234 | 200 OK | ||
Update | PUT /foos/1234 | 204 No Content | No body in response | |
Update (patch) | PATCH /foos/1234 | 200 OK | The updated resource in response body | |
Delete | DELETE /foos/1234 | 204 No Content | No body in response |