Variables

Envless.variables.get_by_id

Read one variable by id

def get_by_id(id, timeout: nil)

Reads one live variable by id, without needing to know which project or environment it belongs to. Ids never change, so this is the stable address for sync clients and for ids arriving in webhook payloads, while get is the one to use when you know the environment and the human name.

The lookup is scoped to the workspace behind the key and joins through the environment and project, so a soft deleted variable, or one whose environment or project was deleted, is invisible and answers 404.

The response identifies its home only through environmentId. There is no project or environment slug in it, so keep your own mapping if you need to build a name addressed call afterwards.

Example

ruby
require "envless/sdk"

id = "a7f2c1e0-8b4d-4c11-9f3a-2d5e6b7c8d90"
variable = Envless.variables.get_by_id(id)

puts "#{variable[:name]} #{variable[:environmentId]}"

Parameters

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

variable_resource for that id, with ciphertext value and defaultValue.

Worth knowing

  • Existence is checked before the project restriction, so a 403 from a project restricted key confirms the variable exists.
  • No product hint is needed on the id routes, the lookup already resolves through the workspace.

Required scopes

variables:read

Underlying endpoint

GET /variables/{id}

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

In TypeScript

envless.variables.getById()

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