Workspace variables
| Variable | Value |
|---|
SPACES_WORKSPACE_ID | the workspace's id |
SPACES_PROJECT_ID | the project's id |
SPACES_WORKSPACE_SLUG | a DNS-safe slug, for example login-fix-a3f9c2d1847b (home-1a2b3c4d5e6f for the home workspace, ~) |
SPACES_WORKSPACE_DIR | the workspace's directory |
SPACES_PROJECT_DIR | the project's directory |
Service variables
Each declared service gets three variables, named from the service with hyphens turned into underscores and uppercased, for example api-server becomes API_SERVER:
| Variable | Value |
|---|
SPACES_<SERVICE>_PORT | the assigned local port |
SPACES_<SERVICE>_HOST | <service>.<slug>.localhost, no scheme or port |
SPACES_<SERVICE>_URL | http://<service>.<slug>.localhost:7391 |
See Services and URLs for how the port and URL are assigned and routed.
Terminal variables
SPACES_TERMINAL_TRACKING_ID identifies the terminal session a command is running in. Coding agents read it to report their own lifecycle with spaces agent signal.
Where they apply
The workspace and service variables are set for every process, every terminal, and the setup and stop scripts. SPACES_TERMINAL_TRACKING_ID is set only in terminal sessions, since the setup and stop scripts do not run inside a tracked terminal. A workspace's settings dialog has a read-only Environment section that lists the values a running process or terminal actually receives, see Workspaces.