I'm designing a RESTful API and have come across a problem when it comes to designing my routes, specifically the admin routes. My application currently has 2 types of users: regular users and administrators, and as of right now I have the following routes:
Users:
GET /users/current
- gets the user object for the currently logged-in user that contains stuff like date of birth etc.GET /users/{id}
- admin route
Appointments (this is where I have ran into a problem):
GET /appointments
- gets the appointments for the currently logged in userGET /appointments/{id}
- gets the appointment by ID, fails for regular users if the appointment doesn't belong to them with 403 Forbidden, succeeds for any id for admins- What should the route to get all appointments be for admins?
GET /appointments/all
? - similarly what about POST?
POST /appointments
creates an appointment for a currently logged in user, what about the admin route that just creates an appointment for a given user?
How would you tidy up this design? I've tried to look what the go-to way for this is but was unable to find guidance.