update(id: string, patch: MemberPatch, options?: RequestScope): Promise<MemberResource>Changes a member role. roleId is the only mutable field, and id is the workspace member id from the list methods, not the user id. Sending the role the member already holds is a no op that still resolves with the unchanged member.
The guards are strict: you cannot change your own role (member.self_mutation), you cannot touch the workspace owner (member.owner_immutable), and you cannot promote anyone into the owner role (role.owner_not_assignable).
The side effect to plan for is key re-clamping. Every API key owned by that member is re-checked against the new role permissions on success, so keys holding scopes the new role does not grant lose them immediately and start failing with 403.
Example
const page = await envless.members.list({ limit: 100 })
const target = page.items.find((member) => member.user?.email === 'dev@example.com')
const roles = await envless.roles.listAll()
const admin = roles.find((role) => role.systemKey === 'admin')
if (target && admin) {
const updated = await envless.members.update(target.id, { roleId: admin.id })
console.log(updated.role?.name)
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Workspace member id from the list methods, not the user id. |
patch.roleId | string | Yes | Role id from the roles namespace to assign to the member. |
options.signal | AbortSignal | No | Cancels the request. |
Returns
MemberResource reflecting the stored membership after the patch.
Worth knowing
- No slug form is accepted for
id. A user id here fails withmember.not_found. - The no op check runs before the owner guard, so re-sending the owner current role succeeds while any real change is refused.
- A member whose keys were narrowed by this call has to be issued new keys. There is no unclamp.
Required scopes
members:write
Underlying endpoint
PATCH /members/{id}
Request and response schema, every error code, and a live playground.
In Python
envless.members.update()
The same method in envless-sdk, the Python SDK, with the same request, retries and errors.
In Ruby
Envless.members.update
The same method in envless-sdk, the Ruby gem, with the same request, retries and errors.
In PHP
$envless->members->update()
The same method in envless/sdk, the PHP SDK, with the same request, retries and errors.