Variables

$envless->variables->listAllHistory()

Collect the full audit trail for a variable

php
/** @return list<VariableHistoryEvent> */
public function listAllHistory(
    string $project,
    string $environment,
    string $name,
    ?int $limit = null,
    ?int $offset = null,
    ?string $product = null,
    int|float|null $timeout = null,
): array

Walks every page of the audit trail for a variable and returns one array, newest event first.

The trail grows with every write, so a long lived variable in an active environment can cost many round trips and a large array. Reach for listHistory when you only need the most recent changes.

No values appear in any event, so this is safe to log or ship to an audit sink without decrypting anything.

Example

php
use Envless\Envless;

$envless = new Envless();

$events = $envless->variables->listAllHistory(
    'api',
    'production',
    'STRIPE_SECRET_KEY',
);

echo count($events), ' ', $events[0]['type'] ?? 'no history', PHP_EOL;

Parameters

ParameterTypeRequiredDescription
$projectstringYesProject slug the environment belongs to.
$environmentstringYesEnvironment slug the variable lives in.
$namestringYesName of a live variable, matched without regard to case.
$limitintNoPage size for each underlying request, clamped to 100.
$offsetintNoOffset the walk starts from, defaults to 0.
$productstringNoProduct slug, needed when the project slug is not unique in the workspace.
$timeoutint|floatNoSeconds each attempt of this call may take, the response body included, before it throws Envless\Exception\NetworkException with isTimeout() true. Overrides the client's timeout for this call, and 0 turns the limit off.

Returns

list<VariableHistoryEvent> with the complete audit trail, newest first.

Reads the events collection. list returns one page as an Envless\Result\Page with items and pagination, listAll collects every page into an array, and iterate returns a Generator that yields one item at a time, fetching the next page only when the loop gets there.

Worth knowing

  • Events keep their order across page boundaries, so events[0] is the most recent change.
  • On the Free plan only the latest event is returned (the API's historyLimited and hiddenCount flags are not surfaced on the returned array, so a one-item result 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.listAllHistory()

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