I'm designing a REST API that needs to allow me to send messages to members in the system.
Right now, I'm thinking about creating a /messages
endpoint that I make a POST request to when I want to send a message, providing a member's ID and the message content. The problem that I see with this approach is handling the case where someone provides a non-existent member ID. Would I return a 404
in this case?
Another approach would be to make the messages endpoint part of the members endpoint. So, I would do something like make a POST
request to /members/{member-id}/messages
, simply providing the message content. Then, if the member's not found, I can just return a 404
.
Which approach is more RESTful? Or, are there better approaches that I haven't considered? Any help would be greatly appreciated.