Versions

$envless->versions->list()

Read one page of environment versions

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

Returns one page of the snapshots taken for an environment, newest first, as items plus the raw pagination envelope. Rows are metadata only: label, note, variableCount, environmentId and createdAt, with no variables and no ciphertext. Pass a row id to $envless->versions->get() for the contents.

Nothing is fetched past the page you asked for, so read pagination['hasMore'] before assuming you hold the whole history. label is assigned server side as v1, v2 and so on from a count of existing versions, which means it is not unique forever. Treat id as the identity and never look a version up by label.

Example

php
use Envless\Envless;

$envless = new Envless();

$page = $envless->versions->list('api', 'production', limit: 50);

foreach ($page->items as $version) {
    echo "{$version['label']} {$version['variableCount']}", PHP_EOL;
}

Parameters

ParameterTypeRequiredDescription
$projectstringYesProject slug or project uniqueId.
$environmentstringYesEnvironment slug, since an environment uniqueId will not resolve here.
$productstringNoProduct slug used to disambiguate a project slug shared across products.
$limitintNoRows per page, a whole number from 1 to 100.
$offsetintNoRows to skip before the page starts.
$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

Page<VersionResource> with items and the pagination envelope.

Reads the versions 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

  • Versions always come back newest first.
  • An environment holds at most 1000 versions on every plan, so the history is bounded no matter how old the project is.
  • On the Free plan only the latest version is listed; the older ones are stored but need Dev or above to be read, and reading one there is 402 plan.upgrade_required.

Required scopes

versions:read

Underlying endpoint

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

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

In TypeScript

envless.versions.list()

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