Variables

Envless.variables.delete_many

Soft delete variables by name in bulk

def delete_many(project, environment, names, product: nil, timeout: nil)

Soft 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

ruby
require "envless/sdk"

result = Envless.variables.delete_many(
  "api",
  "production",
  ["LEGACY_API_URL", "OLD_TOKEN"]
)

puts "#{result[:count]} #{result[:notFound]}"

Parameters

ParameterTypeRequiredDescription
projectStringYesProject slug the environment belongs to.
environmentStringYesEnvironment slug the variables live in.
namesArray[String]YesBetween 1 and 200 variable names, each matched without regard to case.
product:String | SymbolNoProduct slug, needed when the project slug is not unique in the workspace.
timeout:Integer | Float | RationalNoSeconds each attempt of this call may take, redirects and the response body included, before it raises Envless::NetworkError with timeout? set. Overrides the client's timeout for this call, and 0 turns the limit off.

Returns

deleted_variables_resource 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.