def update(id, patch = nil, timeout: nil, **fields)def update: (
String id,
?(member_patch | Hash[Symbol | String, untyped])? patch,
?timeout: seconds?,
**untyped
) -> member_resourceChanges 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 returns 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
require "envless/sdk"
page = Envless.members.list(limit: 100)
target = page.items.find do |member|
member.dig(:user, :email) == "dev@example.com"
end
roles = Envless.roles.list_all
admin = roles.find { |role| role[:systemKey] == "admin" }
if target && admin
updated = Envless.members.update(
target[:id],
roleId: admin[:id]
)
puts updated.dig(:role, :name)
endParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | String | Yes | Workspace member id from the list methods, not the user id. |
patch | member_patch | No | The fields below as one Hash, with Symbol or String keys, in place of the keywords. |
roleId: | String | Yes | Role id from the roles namespace to assign to the member. |
timeout: | Integer | Float | Rational | No | Seconds each attempt of this call may take, redirects and the response body included, before it raises Envless::NetworkError with timeout? set. Overrides the client's timeout for this call, and 0 turns the limit off. |
Returns
member_resource 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 TypeScript
envless.members.update()
The same method in @goenvless/sdk, with the same request, retries and errors.