def list_all(
*,
limit: int | None = None,
offset: int | None = None,
search: str | None = None,
order: str | None = None,
timeout: float | None = None,
) -> list[KeyResource]async def list_all(
*,
limit: int | None = None,
offset: int | None = None,
search: str | None = None,
order: str | None = None,
timeout: float | None = None,
) -> list[KeyResource]Walks the pages and returns a flat list of every live key in the workspace. A workspace is capped at 100 live keys and the walk requests 100 rows at a time, so in practice this costs a single request.
The pagination envelope is discarded, so totalCount and hasMore are gone. Use list when you need those numbers, or iterate when you want to stop as soon as you find the key you were after.
Revoked keys are absent, so the length of this list is the current live count and not a historical total. That makes it the right input for a cleanup pass over stale credentials.
Example
from envless import envless
keys = envless.keys.list_all()
idle = [
key['prefix']
for key in keys
if key['active'] and key['lastUsedAt'] is None
]
print(idle)import asyncio
from envless import AsyncEnvless
async def main() -> None:
async with AsyncEnvless() as envless:
keys = await envless.keys.list_all()
idle = [
key['prefix']
for key in keys
if key['active'] and key['lastUsedAt'] is None
]
print(idle)
asyncio.run(main())Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | int | No | Page size used while walking, capped at 100 and defaulting to 100. |
offset | int | No | Row the walk starts from, so earlier keys are left out of the result. |
search | str | No | Case insensitive substring match against name and prefix, applied to every page. |
order | str | No | Defaults to name, which sorts A to Z. Pass asc for oldest first or desc for newest first on createdAt. |
timeout | float | No | Seconds 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
list[KeyResource] holding each live key in the workspace.
Reads the keys 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 failure on any page fails the whole call and the rows already collected are lost.
- Filtering on
activestill leaves disabled keys in the list. Disabled is not the same as revoked, and only revoked keys drop out of the collection.
Required scopes
keys:read
Underlying endpoint
GET /keys
Request and response schema, every error code, and a live playground.
In TypeScript
envless.keys.listAll()
The same method in @goenvless/sdk, with the same request, retries and errors.