Workspaces

$envless->workspaces->listAll()

Collect every workspace into one array

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

Walks the pages for you and returns a single flat array of memberships. Most owners belong to a handful of workspaces, so this is usually the right call and rarely costs more than one request.

The pagination envelope is discarded, so you lose totalCount and hasMore. Use list when you need those, or iterate when you want to stop early instead of buffering the whole set.

Example

php
use Envless\Envless;

$envless = new Envless();

$workspaces = $envless->workspaces->listAll();

foreach ($workspaces as $workspace) {
    if (!$workspace['current']) {
        echo $workspace['slug'], PHP_EOL;
    }
}

Parameters

ParameterTypeRequiredDescription
$limitintNoPage size used while walking, capped at 100 and defaulting to 100.
$offsetintNoRow to start the walk from, so earlier memberships are left out of the result.
$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<WorkspaceResource> holding each workspace the key owner belongs to.

Reads the workspaces 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

  • A failure on any page fails the whole call, and the partially collected rows are lost.

Required scopes

workspace:read

Underlying endpoint

GET /workspaces

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

In TypeScript

envless.workspaces.listAll()

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