Consider a web api exposing two kind of resources: Users and Teams with many-to-many relationship, typically a REST api will expose the following trivial endpoints to read data:
GET /users
GET /users/{id}
GET /users/{id}/teams
GET /teams
GET /teams/{id}
GET /teams/{id}/users
Now I am trying to design endpoints to manage relationships between the resources (endpoints to create/edit single resource through POST/PUT are trivial). For a simple situation, we want to attach/remove a team (already existing) to a user (already existing). Are the following endpoints REST-compliant?
1- POST /users/{id}/teams (content= team ID) : to link a team to user
2- PUT /users/{id}/teams/{id-team} (no content) : to link a team to user
3- DELETE /users/{id}/teams/{id-team} (no content) : to remove team link
Is there any other Idea of endpoints which can be more convenient to use? (without using a distinct endpoint for relation management, like /relations)
/userteamrelations
.