Answer the question
In order to leave comments, you need to log in
Is it possible to have an "extra" ID in a REST API URL?
Hello! :)
Building an API.
Stores have users.
Need endpoint "update user" (change password, name, etc.). Which URL is more correct: PATCH /users/:userId
OR PATCH /shops/:shopId/users/:userId
Both urls will work. Although the second URL has an extra id (shopId).
Is it wrong to have an extra ID in the URL?
Thanks in advance!
Answer the question
In order to leave comments, you need to log in
Even if users are tied to stores, then since you allow the use of /users/:userId
, I assume that user IDs are unique not only within the store, but throughout the entire system. In this case, the level /shops/:shopId
will be redundant in the task of changing user information, even if the user has a link to the store in the business logic plane. Therefore, use /users/:userId
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question