Consider animals being some REST resources. User has animals assigned to him.
The endpoint /api/animals/{animalId}/feed
is used to feed a given animal by the authenticated user.
User should not be able to feed animals he does not own. What HTTP status code should be emitted in such a scenario?
400, 401, 403, 404, something else?
Also, should the situation where passing animalId
that does not exist, e.g. 123456789 be distinguished from the situation where animalId
does not belong to the logged in user?
I personally feel like I should return 404 in all cases.
This seems like a typical REST design situation, so I am wondering how experienced devs would solve it.