Variables

$envless->variables->deleteById()

Soft delete one variable by id

php
/** @return DeletedVariableResource */
public function deleteById(
    string $id,
    int|float|null $timeout = null,
): array

Soft deletes one variable by id. Version snapshots taken earlier keep their copy of the value, so a rollback can restore it.

An id that never existed and an id that was already deleted both answer 404 rather than succeeding quietly, so a retry after a delete that actually landed will throw. Treat that 404 as success if your caller is meant to be idempotent.

Example

php
use Envless\Envless;

$envless = new Envless();

$id = 'a7f2c1e0-8b4d-4c11-9f3a-2d5e6b7c8d90';
$removed = $envless->variables->deleteById($id);

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

Parameters

ParameterTypeRequiredDescription
$idstringYesVariable id from a list response or a webhook payload.
$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

  • This is the only delete route that tells you the name of a variable you addressed purely by id.

Required scopes

variables:write

Underlying endpoint

DELETE /variables/{id}

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

In TypeScript

envless.variables.deleteById()

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