def get(
project: str,
environment: str,
name: str,
*,
product: str | None = None,
timeout: float | None = None,
) -> VariableResourceasync def get(
project: str,
environment: str,
name: str,
*,
product: str | None = None,
timeout: float | None = None,
) -> VariableResourceReads one live variable by name inside an environment. Matching ignores case, so API_KEY, api_key and Api_Key all resolve to the same variable, and the response carries the name with its stored casing. This route has no id fallback, use get_by_id when you hold an id.
The SDK URL encodes the name for you. In practice nothing needs it, since every write path enforces ^[A-Za-z_][A-Za-z0-9_]*$ and only legacy rows written before that rule can hold a character that would need escaping. value and defaultValue are returned untouched, which means ciphertext.
A missing project answers 404 project.not_found, while a missing environment and a missing variable both answer 404 with the generic request.not_found, so treat any 404 as one case through is_not_found instead of branching on a code.
Example
import os
from envless import decrypt_value, envless
passphrase = os.environ['ENVLESS_PASSPHRASE']
workspace_id = envless.me.get()['workspaceId']
variable = envless.variables.get(
'api', 'production', 'STRIPE_SECRET_KEY'
)
if variable['value'] is not None:
print(
decrypt_value(
variable['value'], passphrase, workspace_id
)
)import asyncio
import os
from envless import AsyncEnvless, decrypt_value
async def main() -> None:
async with AsyncEnvless() as envless:
passphrase = os.environ['ENVLESS_PASSPHRASE']
workspace_id = (await envless.me.get())['workspaceId']
variable = await envless.variables.get(
'api', 'production', 'STRIPE_SECRET_KEY'
)
if variable['value'] is not None:
print(
decrypt_value(
variable['value'], passphrase, workspace_id
)
)
asyncio.run(main())Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project | str | Yes | Project slug the environment belongs to. |
environment | str | Yes | Environment slug the variable lives in. |
name | str | Yes | Variable name, matched without regard to case. |
product | str | No | Product slug, needed when the project slug is not unique in the workspace. |
timeout | float | No | Seconds each attempt of this call may take, the response body included, before it raises EnvlessNetworkError with is_timeout set. Overrides the client's timeout for this call, and 0 turns the limit off. |
Returns
VariableResource with the ciphertext value and defaultValue, plus type, visibility, required and environmentId.
Worth knowing
isSecretis stored server side but never appears in the response, so you cannot read it back on any route.- Keep the
idandupdatedAtyou get here if you plan to callapplylater, both feed the baseline.
Required scopes
variables:read
Underlying endpoint
GET /projects/{slug}/environments/{environmentSlug}/variables/{name}
Request and response schema, every error code, and a live playground.
In TypeScript
envless.variables.get()
The same method in @goenvless/sdk, with the same request, retries and errors.