Workspaces

envless.workspaces.list()

List the workspaces the key owner belongs to

def list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    timeout: float | None = None,
) -> Page[WorkspaceResource]

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

from envless import envless

page = envless.workspaces.list(limit=50)

current = next(
    (
        workspace
        for workspace in page['items']
        if workspace['current']
    ),
    None,
)

print(
    current['slug'] if current else None,
    page['pagination']['totalCount'],
)

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.
timeoutfloatNoSeconds each attempt of this call may take, the response body included, before it raises EnvlessNetworkError with is_timeout set. 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 a dict with items and pagination, list_all collects every page into a list, and iterate yields one item at a time, fetching the next page only when the loop reaches it. On AsyncEnvless, iterate is an async iterator for async for.

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.