Environment Variables and Metadata Filesystem

Inside a workspace, information about the sandbox and workspace can be retrieved from special environment variables and the metadata filesystem.

Environment Variables

The following environment variables are made available in workspaces and containers:

Name Value Example
SANDBOX_SYSTEM_URL The URL to access the WebUI, APIs, etc. https://sandboxes.cloud
SANDBOX_SYSTEM_DNS_SUFFIX The suffix used for constructing a full subdomain after the system URL .sandboxes.cloud
SANDBOX_SYSTEM_DOMAIN The base domain (aka hostname) of the system URL sandboxes.cloud
SANDBOX_ORG_ID The id of the org
SANDBOX_ORG The org name example
SANDBOX_TEMPLATE The name of the template which the sandbox is created from example1
SANDBOX_TEMPLATE_FULL_NAME The full name of the template including folders (if folder support is enabled), otherwise the same value as SANDBOX_TEMPLATE demo/example1
SANDBOX_TEMPLATE_FOLDER The folder name of the template (if folder support is enabled) demo
SANDBOX_ID The id of the sandbox
SANDBOX_NAME The name of the sandbox example1-dev
SANDBOX_FULL_NAME The full name of the sandbox including folders (if folder support is enabled), otherwise the same value as SANDBOX_NAME work/example1-dev
SANDBOX_FOLDER The folder name of the sandbox (if folder support is enabled) work
SANDBOX_REGION The region name if the sandbox is in a remote region. Unset if in the main region
SANDBOX_WORKLOAD The name of the current workload, regardless of type dev
SANDBOX_WORKSPACE If the current workload is a workspace, this is set to the name dev
SANDBOX_CONTAINER If the current workload is a container, this is set to the name sqlpad
SANDBOX_OWNER_ID The user ID of the sandbox owner
SANDBOX_OWNER The name (effectively the email) of the sandbox owner jack@example.com
SANDBOX_OWNER_EMAIL The email of the sandbox owner jack@example.com
SANDBOX_OWNER_NAME The display name of the sandbox owner Jack Smith
SANDBOX_POOL_ID Only set to the id of the sandbox pool where the current sandbox is running. Unset once the sandbox is claimed
SANDBOX_APP_DOMAIN The base domain for endpoints example1-dev-example.sandboxes.run
SANDBOX_ENDPOINT_DNS_SUFFIX The suffix used for constructing a full endpoint DNS name --example1-dev-example.sandboxes.run

These environment variables are available to all daemons and jobs. As a side effect, changing any of these environment variables will restart daemons, jobs, and all container workloads.

Some *_DNS_SUFFIX environment variables are useful for constructing full DNS names. For example, if the sandbox contains an endpoint named web, its full DNS name can be constructed as: web${SANDBOX_ENDPOINT_DNS_SUFFIX}.

Metadata Filesystem

Part of the above information is also available in the metadata filesystem of workspaces. It can be accessed as files under /run/sandbox/fs/metadata.

File Content
sandbox.json The basic information about the sandbox
template.json The basic information about the template used to create the sandbox
owner.json The basic information about the sandbox owner
app-domain Contains the value of env SANDBOX_APP_DOMAIN
endpoint-dns-suffix Contains the value of env SANDBOX_ENDPOINT_DNS_SUFFIX

See Also