I am working on a REST API for managing users. Each user has a name and a surname and a list of his own contacts (name, type, value). I am considering two approaches to modelling the REST API, the coarse grained approach:
- GET /user/{id}, to get the user details along with his contacts
- POST /users, to add a new user along with his contacts
- PUT /users/{id}, to update a user along with his contacts
or the fine grained approach:
- GET /user/{id}, to get the user details
- GET /user/{id}/contacts, to get the user's contacts
- POST /user, to add a new user
- PUT /user/{id}, to update a user
- POST /user/{id}/contacts, to add a new user contact
- PUT /user/{id}/contact/{id}, to update a user contact
- DELETE /user/{id}/contact/{id}, to delete a user contact
When the fine grained approach should be choosen over the coarse grained approach?