Workspaces

$envless->workspaces->list()

List the workspaces the key owner belongs to

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

Returns one page of every workspace the API key owner is a member of. This is the only read in the SDK that leaves the workspace the key is bound to, because it resolves memberships for the owner instead of rows inside one workspace.

Seeing a workspace in items does not mean you can act on it. A key is bound to a single workspace at creation and cannot be retargeted, so the entry with 'current' => true is the only one every other method will touch.

The server loads all memberships before it slices the page, so pagination['totalCount'] is the size of the complete set rather than of the page you received.

Example

php
use Envless\Envless;

$envless = new Envless();

$page = $envless->workspaces->list(limit: 50);

foreach ($page->items as $workspace) {
    if ($workspace['current']) {
        echo $workspace['slug'], PHP_EOL;
    }
}

echo $page->pagination['totalCount'], PHP_EOL;

Parameters

ParameterTypeRequiredDescription
$limitintNoRows per page, a whole number from 1 to 100, defaulting to 25.
$offsetintNoWhole number of rows to skip before the page starts.
$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

Page<WorkspaceResource> with items and a pagination envelope covering every membership.

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 401 with auth.api_key_user_missing means the key is valid but its owner row can no longer be read.

Required scopes

workspace:read

Underlying endpoint

GET /workspaces

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

In TypeScript

envless.workspaces.list()

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