Members

$envless->members->listAll()

Collect every workspace member into one array

php
/** @return list<MemberResource> */
public function listAll(
    ?int $limit = null,
    ?int $offset = null,
    ?string $search = null,
    ?string $roleId = null,
    int|float|null $timeout = null,
): array

Walks every page and returns the flattened member list. Membership counts are small compared with variables, so this is usually the right call for building a role table or a seat report.

limit: sets the page size used while walking, not a cap on how many members come back. Asking for a limit of 5 still returns everyone, just in more round trips. Nothing is returned until the last page lands.

Example

php
use Envless\Envless;

$envless = new Envless();

$members = $envless->members->listAll();
$admins = 0;

foreach ($members as $member) {
    $admins += ($member['role']['name'] ?? '') === 'Admin' ? 1 : 0;
}

echo count($members), ' members, ', $admins, ' admins', PHP_EOL;

Parameters

ParameterTypeRequiredDescription
$limitintNoPage size used while walking, clamped to 100.
$offsetintNoRow to start the walk from.
$searchstringNoCase insensitive substring match on the member name, email or role name.
$roleIdstringNoOnly members holding this role, by the role id from $envless->roles->list().
$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

list<MemberResource> holding every accepted member of the workspace.

Reads the members collection. list returns one page as an Envless\Result\Page with items and pagination, listAll collects every page into an array, and iterate returns a Generator that yields one item at a time, fetching the next page only when the loop gets there.

Worth knowing

  • Page size defaults to the API maximum of 100 and is clamped there, so a larger limit buys nothing.
  • Key off member['id'] rather than member['user']['id'], since user is nullable and only id is accepted by the write routes.

Required scopes

members:read

Underlying endpoint

GET /members

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

In TypeScript

envless.members.listAll()

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