def iterate_history(
project: str,
environment: str,
name: str,
*,
limit: int | None = None,
offset: int | None = None,
product: str | None = None,
timeout: float | None = None,
) -> Iterator[VariableHistoryEvent]def iterate_history(
project: str,
environment: str,
name: str,
*,
limit: int | None = None,
offset: int | None = None,
product: str | None = None,
timeout: float | None = None,
) -> AsyncIterator[VariableHistoryEvent]Returns an iterator over the audit trail for a variable, fetching the next page only when the current one runs out. Nothing is requested until you begin consuming it.
Breaking out of the loop ends the walk, which makes this the cheap way to scan back to a known point in time. Because new events land at the front of the ordering, a write during a long walk shifts the window and can repeat an event you already saw.
Example
from envless import envless
for event in envless.variables.iterate_history(
'api', 'production', 'STRIPE_SECRET_KEY'
):
actor = event['actor']
if event['type'] == 'updated' and actor:
print(event['createdAt'], actor['email'])import asyncio
from envless import AsyncEnvless
async def main() -> None:
async with AsyncEnvless() as envless:
async for event in envless.variables.iterate_history(
'api', 'production', 'STRIPE_SECRET_KEY'
):
actor = event['actor']
if event['type'] == 'updated' and actor:
print(event['createdAt'], actor['email'])
asyncio.run(main())Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project | str | Yes | Project slug the environment belongs to. |
environment | str | Yes | Environment slug the variable lives in. |
name | str | Yes | Name of a live variable, matched without regard to case. |
limit | int | No | Page size for each underlying request, clamped to 100. |
offset | int | No | Offset the walk starts from, defaults to 0. |
product | str | No | Product slug, needed when the project slug is not unique in the workspace. |
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
Iterator[VariableHistoryEvent] yielding one audit record per iteration.
Reads the events 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
- Event types are
created,updated,deletedandrestored, so filter on those rather than on dotted names. - On the Free plan only the latest event is yielded (the API's
historyLimitedandhiddenCountflags are not surfaced by the iterator, so a single event on Free is the plan, not an empty history); the full trail needs Dev or above.
Required scopes
variables:read
Underlying endpoint
GET /projects/{slug}/environments/{environmentSlug}/variables/{name}/history
Request and response schema, every error code, and a live playground.
In TypeScript
envless.variables.iterateHistory()
The same method in @goenvless/sdk, with the same request, retries and errors.