we are currently designing an internal REST api. we have the following use case:
- a user (109) wants to read a message that he has sent to another user (110)
- the reading user (109) is known to the app through his token credentials that he received after authenticating (while doing the GET request)
- we assume in this example the user 109 was the sender and 110 the receiver
to summarize from the users perspective "give me the mail that i (109) have sent to 110"
the following URIs came to our mind but we can't decide which one to take:
a) GET http://localhost:9099/api/mails/109?receiverUserId=110
b) GET http://localhost:9099/api/mails?senderUserId=109&receiverUserId=110
c) GET http://localhost:9099/api/mails?receiverUserId=110
d) GET http://localhost:9099/api/mails/me/to/110 (when logged in as 109 via token credentials we know that "me" is 109)
f) GET http://localhost:9099/api/mails/109/to/110 (explicit request, e.g. for admins … has to be guarded against illegal access)
all the links are "context sensitive" that is sending one of the links to the receiver (110) will yield different results executing the GET request.
i would like to know your opinion on what url to use.
any help highly appreciated.
cheers marcel