API keys

Envless.keys.list_all

Collect every API key into one array

def list_all(limit: nil, offset: nil, search: nil, order: nil, timeout: nil)

Walks the pages and returns a flat array 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 array is the current live count and not a historical total. That makes it the right input for a cleanup pass over stale credentials.

Example

ruby
require "envless/sdk"

keys = Envless.keys.list_all

idle = keys.select { |key| key[:active] && key[:lastUsedAt].nil? }

puts idle.map { |key| key[:prefix] }

Parameters

ParameterTypeRequiredDescription
limit:IntegerNoPage size used while walking, capped at 100 and defaulting to 100.
offset:IntegerNoRow the walk starts from, so earlier keys are left out of the result.
search:String | SymbolNoCase insensitive substring match against name and prefix, applied to every page.
order:"name" | "asc" | "desc"NoDefaults to name, which sorts A to Z. Pass asc for oldest first or desc for newest first on createdAt.
timeout:Integer | Float | RationalNoSeconds each attempt of this call may take, redirects and the response body included, before it raises Envless::NetworkError with timeout? set. Overrides the client's timeout for this call, and 0 turns the limit off.

Returns

Array[key_resource] holding each live key in the workspace.

Reads the keys collection. list returns one page as an Envless::Page with items and pagination, list_all collects every page into an array, and iterate yields one item at a time to a block, fetching the next page only when it gets there. Without a block, iterate returns an Enumerator.

Worth knowing

  • A failure on any page fails the whole call and the rows already collected are lost.
  • Filtering on active still leaves disabled keys in the array. 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.