Verb | REST Example | Usage |
---|---|---|
GET |
https://api.com/users | Read all users as a collection. Should return 200 OK or 404 Not Found. |
GET |
https://api.com/users/{id} | Read single user by id. Should return 200 OK or 404 Not Found. If your read needs to use a complex object ie: you are sending back JSON then rather use a POST to read (or send JUST the {id} in the route to keep using a GET ) |
POST |
https://api.com/users | Create new user. Should return 200 OK when the resource was updated, 201 if it was created, 202 is its still busy async, 204 if the actual resource was not returned. |
PUT |
https://api.com/users/{id} | Update user by id with complete representation. In rare cases you can also create like a POST . Should return 200 OK, 201 Created or 204 No Content |
PATCH |
https://api.com/users/{id} | Partial update |
DELETE |
https://api.com/users/{id} | Delete user by id. Return 200 OK, 204 or 404 |