/**
* @param list<string> $names
* @return DeletedVariablesResource
*/
public function deleteMany(
string $project,
string $environment,
array $names,
?string $product = null,
int|float|null $timeout = null,
): arraySoft deletes up to 200 variables by name in one request. Names are matched without regard to case, so api_key removes a live API_KEY.
Unknown names are not an error. They come back under notFound while everything that matched is still deleted, which makes the call safe to retry. Even when nothing matches, the call returns 'count' => 0 and every name in notFound, so check count rather than assuming work happened.
This sends a JSON body on a DELETE request. The SDK transport does that correctly, but a proxy or gateway in front of your traffic may strip the body, which surfaces as 400 with the generic request.invalid code and only message to explain it.
Example
use Envless\Envless;
$envless = new Envless();
$result = $envless->variables->deleteMany('api', 'production', [
'LEGACY_API_URL',
'OLD_TOKEN',
]);
echo $result['count'], ' ', implode(', ', $result['notFound']), PHP_EOL;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
$project | string | Yes | Project slug the environment belongs to. |
$environment | string | Yes | Environment slug the variables live in. |
$names | list<string> | Yes | Between 1 and 200 variable names, each matched without regard to case. |
$product | string | No | Product slug, needed when the project slug is not unique in the workspace. |
$timeout | int|float | No | Seconds 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
DeletedVariablesResource with deleted, a count of rows removed and notFound for names that matched nothing.
Worth knowing
- More than 200 names, an empty array or a non-string entry is 400
request.body_invalid. - The whole batch is soft deleted, so earlier version snapshots keep every removed value.
Required scopes
variables:write
Underlying endpoint
DELETE /projects/{slug}/environments/{environmentSlug}/variables
Request and response schema, every error code, and a live playground.
In TypeScript
envless.variables.deleteMany()
The same method in @goenvless/sdk, with the same request, retries and errors.