I'm starting with the design of a Rest API for a bookings app. I've developed some Rest API's in the past but this is the first time I design it alone. I'm using user authentication trough JWT.
So, imagine that I want to retrieve the preferences for an authenticated user. What is the most 'Rest' option?
/users/:userId/preferencesand send the JWT in theAuthorizationheader to check if the userId is the same as the authenticated user./me/preferencesand only send the JWT to get the preferences of the authenticated user.
The first option seems the most 'Rest' one because of the resource oriented endpoint, but you need to store the userId in the client and then send it to the API with the JWT. Looks like a bit repetitive right?
I have seen that big API's like PayPal uses the second option and others like AirBnB uses the first one hashing the userId.
Which option is better and why? I'm very doubtful with this... Thanks.