Let’s say I have the following endpoints:
/accounts
(company/business unit)
/vehicles
(cars, trucks etc.)
/users
(login user)
A user can have 3 different permissions: Global Admin, Account Admin and User.
If a user accesses vehicles as:
- Global Admin: He will get all vehicles
- Account Admin: All vehicles on the same account as himself
- User: All his own vehicles
But if an Account Admin accesses /vehicles he might only want his own vehicles, and if a Global Admin only wants vehicles on his own related account. What then?
An example solution:
/accounts/{accountId}/vehicles
(for Global Admin)
/accounts/current/vehicles
(for Account Admin)
/vehicles
(for User)
Or…
/accounts/{accountId}/vehicle
s (for Global Admin)
/vehicles/byUserAccount/{accountId}
(for Account Admin)
/vehicles
(for User)
Or…
/vehicles/byEntireAccount/{accountId}
(for Global Admin)
/vehicles/byUserAccount/{accountId}
(for Account Admin)
/vehicles
(for User)
Is there any best practice or just good advice for this case?
Hope the question makes sense.