Variables

envless.variables.list()

Read one page of variables in an environment

def list(
    project: str,
    environment: str,
    *,
    limit: int | None = None,
    offset: int | None = None,
    product: str | None = None,
    timeout: float | None = None,
) -> Page[VariableResource]

Fetches one page of the variables in an environment, sorted by name A to Z. Soft deleted variables are excluded.

Every value and defaultValue comes back as ciphertext, because the server holds no key material and cannot decrypt anything. Run each one through decrypt_value with the workspace passphrase and the workspaceId from envless.me.get(). Rows written before ciphertext was enforced can still hold plaintext, so test with is_ciphertext rather than reading a failed decrypt as corruption. Pagination is limit and offset only, and a limit above 100 is rejected with 400 request.invalid_pagination rather than clamped.

Example

from envless import envless

page = envless.variables.list('api', 'production', limit=50)

print(page['pagination']['totalCount'])
print([variable['name'] for variable in page['items']])

Parameters

ParameterTypeRequiredDescription
projectstrYesProject slug the environment belongs to.
environmentstrYesEnvironment slug to read variables from.
limitintNoPage size between 1 and 100.
offsetintNoNumber of variables to skip before the page starts.
productstrNoProduct slug, needed when the project slug is not unique in the workspace.
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[VariableResource] holding items plus a pagination envelope with totalCount and hasMore.

Reads the variables 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 project locked by the workspace plan refuses reads as well as writes, with 402 plan.upgrade_required.
  • A duplicate project slug across two products is 409 project.ambiguous_product. Retry with product=.

Required scopes

variables:read

Underlying endpoint

GET /projects/{slug}/environments/{environmentSlug}/variables

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

In TypeScript

envless.variables.list()

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