/** @return DeletedMemberResource */
public function remove(string $id, int|float|null $timeout = null): arraySoft deletes a membership. The user account is untouched and the same person can be invited again later, which is why this frees a seat rather than destroying anything.
It refuses to remove the caller with 409 member.self_mutation, so use leave for that, and it refuses the workspace owner with 409 member.owner_immutable. Ownership has to be transferred in the dashboard first.
The returned value is a tombstone carrying id alone. It gives you back no email, no role and no user, so read the member before removing if you need those for an audit trail.
Example
use Envless\Envless;
$envless = new Envless();
$page = $envless->members->list(limit: 100);
foreach ($page->items as $member) {
if (($member['user']['email'] ?? '') === 'contractor@example.com') {
$removed = $envless->members->remove($member['id']);
echo $removed['id'], PHP_EOL;
}
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
$id | string | Yes | Workspace member id from the list methods, not the user id. |
$timeout | int|float | No | Seconds each attempt of this call may take, the response body included, before it throws Envless\Exception\NetworkException with isTimeout() true. Overrides the client's timeout for this call, and 0 turns the limit off. |
Returns
DeletedMemberResource carrying only the removed member id.
Worth knowing
- Every API key belongs to a member, so the removed person keys stop authenticating with 401 as soon as this succeeds.
- Emits
member.removedwithoutleft, which is how a webhook consumer tells an admin removal from a voluntary departure.
Required scopes
members:write
Underlying endpoint
DELETE /members/{id}
Request and response schema, every error code, and a live playground.
In TypeScript
envless.members.remove()
The same method in @goenvless/sdk, with the same request, retries and errors.