iterate(options?: ListOptions): AsyncGenerator<WorkspaceResource, void, undefined>Returns an async generator that yields workspaces individually and fetches the next page only when the current one runs out. Breaking out of the loop stops the requests, which makes this the cheapest way to find one workspace by slug or plan.
The generator defaults to the maximum page size of 100 and caps anything larger, so limit only ever makes pages smaller. Each page is a separate request, so a membership added while you are mid walk may or may not appear.
Example
for await (const workspace of envless.workspaces.iterate()) {
if (workspace.slug === 'billing') {
console.log(workspace.id, workspace.plan)
break
}
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
options.limit | number | No | Page size per request, capped at 100 and defaulting to 100. |
options.offset | number | No | Row the walk starts at, advancing by the number of items each page returns. |
options.signal | AbortSignal | No | Cancels the request that is in flight and ends the iteration. |
Returns
AsyncGenerator<WorkspaceResource, void, undefined> yielding one workspace per step.
Reads the workspaces collection. list returns one page as { items, pagination }, listAll collects every page into an array, and iterate streams one item at a time without buffering the whole set.
Worth knowing
- The generator is lazy, so no request is sent until you start consuming it.
Required scopes
workspace:read
Underlying endpoint
GET /workspaces
Request and response schema, every error code, and a live playground.
In Python
envless.workspaces.iterate()
The same method in envless-sdk, the Python SDK, with the same request, retries and errors.
In Ruby
Envless.workspaces.iterate
The same method in envless-sdk, the Ruby gem, with the same request, retries and errors.
In PHP
$envless->workspaces->iterate()
The same method in envless/sdk, the PHP SDK, with the same request, retries and errors.