Change a user's roles
https://lemurseye.com/api/v1/users/{id}/rolesReplaces the person's roles with exactly the list you send. An empty list leaves them able to sign in but see nothing.
Two rules keep the company from locking itself out: you cannot remove your own owner role, and the company must keep at least one active owner (one who is not suspended and has set a password).
Permission: users:write (a person only, never an API key). The token is sent as Authorization: Bearer <token>; see Authentication.
Path parameters
idstringrequiredThe user's id.
Body (JSON)
rolesstring[]requiredThe full new set:
owner,manager,viewer,installer.
Response
200 The person, with their new roles.
Response fields
idstringThe user's id.
emailstringTheir sign-in email.
namestring | nullFull name.
enabledbooleanfalsewhen suspended: they cannot sign in.pendingPasswordbooleantrueuntil they accept the invitation and choose a password.rolesstring[]Their roles in your company:
owner,manager,viewer,installer.lastSeenAttimestamp | nullTheir last activity, or null if they have never signed in.
Errors
A refusal by the rules comes back as { "error": "...", "code": "..." }: branch on code, show error. Where no message is listed, only the status code is returned.
- 404
No user with this id in your company (a user of another company answers the same, so ids cannot be probed).
- 400
A role is not one your company can assign.
- 403
selfyou cannot remove your own owner roleYou tried to drop
ownerfrom yourself. - 409
last_ownerThis is the company's only active owner. Make someone else owner first, so the company is never left without one.It would leave no active owner.
- 401
No token, or it has expired.
- 403
The token lacks the permission above.