Members

$envless->members->leave()

Leave the workspace as the key owner

php
/** @return LeftWorkspaceResource */
public function leave(int|float|null $timeout = null): array

Removes the API key owner from the current workspace. This is the self service counterpart to remove, which refuses self removal.

It revokes the calling key along with the membership, because every key in the workspace belongs to a member. The request that succeeds is the last one this key can make, so never place it in the middle of a script that still has work to do.

The workspace owner cannot leave, since a workspace with no owner is unrecoverable: that call fails with 409 member.owner_cannot_leave. Transfer ownership first, or delete the workspace outright with $envless->workspace->delete().

Example

php
use Envless\Envless;

$envless = new Envless();

$result = $envless->members->leave();

echo $result['left'] ? "left as {$result['id']}" : 'still a member', PHP_EOL;

Parameters

ParameterTypeRequiredDescription
$timeoutint|floatNoSeconds 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

LeftWorkspaceResource with the former membership id and left set to true.

Worth knowing

  • Every later call on the same client fails with 401. Build a fresh client from a different key if the process must continue.
  • Emits member.removed with 'left' => true, the marker for a voluntary departure.
  • A key whose owner is somehow not a member gets 404 member.not_found rather than a silent success.

Required scopes

members:write

Underlying endpoint

DELETE /members/me

Request and response schema, every error code, and a live playground.

In TypeScript

envless.members.leave()

The same method in @goenvless/sdk, with the same request, retries and errors.