Variables

$envless->variables->delete()

Soft delete one variable by name

php
/** @return DeletedVariableResource */
public function delete(
    string $project,
    string $environment,
    string $name,
    ?string $product = null,
    int|float|null $timeout = null,
): array

Soft deletes one live variable by name, matched without regard to case, so api_key removes a live API_KEY. It stops appearing in reads immediately, but version snapshots taken before the delete keep their copy, so a rollback can bring the variable back.

Deleting a name that is not there is a 404, not a no-op, which makes a blind retry after a successful delete fail. Use deleteMany when you want unknown names tolerated.

Example

php
use Envless\Envless;

$envless = new Envless();

$removed = $envless->variables->delete(
    'api',
    'production',
    'LEGACY_API_URL',
);

echo "{$removed['id']} {$removed['environmentId']}", PHP_EOL;

Parameters

ParameterTypeRequiredDescription
$projectstringYesProject slug the environment belongs to.
$environmentstringYesEnvironment slug the variable lives in.
$namestringYesVariable name, matched without regard to case.
$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

DeletedVariableResource with the id, name and environmentId of the removed row.

Worth knowing

  • The name is freed for reuse right away, in any casing, but a new variable of that name gets a new id and an empty history.

Required scopes

variables:write

Underlying endpoint

DELETE /projects/{slug}/environments/{environmentSlug}/variables/{name}

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

In TypeScript

envless.variables.delete()

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