mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
* fix(env-var-resolution): new executor env var resolution changes * add sessionuser id" * cleanup code * add doc update * fix build * fix client session pass through" * add type change * fix env var with hitl * fix types
96 lines
3.5 KiB
Plaintext
96 lines
3.5 KiB
Plaintext
---
|
|
title: Environment Variables
|
|
---
|
|
|
|
import { Callout } from 'fumadocs-ui/components/callout'
|
|
import { Image } from '@/components/ui/image'
|
|
|
|
Environment variables provide a secure way to manage configuration values and secrets across your workflows, including API keys and other sensitive data that your workflows need to access. They keep secrets out of your workflow definitions while making them available during execution.
|
|
|
|
## Variable Types
|
|
|
|
Environment variables in Sim work at two levels:
|
|
|
|
- **Personal Environment Variables**: Private to your account, only you can see and use them
|
|
- **Workspace Environment Variables**: Shared across the entire workspace, available to all team members
|
|
|
|
<Callout type="info">
|
|
Workspace environment variables take precedence over personal ones when there's a naming conflict.
|
|
</Callout>
|
|
|
|
## Setting up Environment Variables
|
|
|
|
Navigate to Settings to configure your environment variables:
|
|
|
|
<Image
|
|
src="/static/environment/environment-1.png"
|
|
alt="Environment variables modal for creating new variables"
|
|
width={500}
|
|
height={350}
|
|
/>
|
|
|
|
From your workspace settings, you can create and manage both personal and workspace-level environment variables. Personal variables are private to your account, while workspace variables are shared with all team members.
|
|
|
|
### Making Variables Workspace-Scoped
|
|
|
|
Use the workspace scope toggle to make variables available to your entire team:
|
|
|
|
<Image
|
|
src="/static/environment/environment-2.png"
|
|
alt="Toggle workspace scope for environment variables"
|
|
width={500}
|
|
height={350}
|
|
/>
|
|
|
|
When you enable workspace scope, the variable becomes available to all workspace members and can be used in any workflow within that workspace.
|
|
|
|
### Workspace Variables View
|
|
|
|
Once you have workspace-scoped variables, they appear in your environment variables list:
|
|
|
|
<Image
|
|
src="/static/environment/environment-3.png"
|
|
alt="Workspace-scoped variables in the environment variables list"
|
|
width={500}
|
|
height={350}
|
|
/>
|
|
|
|
## Using Variables in Workflows
|
|
|
|
To reference environment variables in your workflows, use the `{{}}` notation. When you type `{{` in any input field, a dropdown will appear showing both your personal and workspace-level environment variables. Simply select the variable you want to use.
|
|
|
|
<Image
|
|
src="/static/environment/environment-4.png"
|
|
alt="Using environment variables with double brace notation"
|
|
width={500}
|
|
height={350}
|
|
/>
|
|
|
|
## How Variables are Resolved
|
|
|
|
**Workspace variables always take precedence** over personal variables, regardless of who runs the workflow.
|
|
|
|
When no workspace variable exists for a key, personal variables are used:
|
|
- **Manual runs (UI)**: Your personal variables
|
|
- **Automated runs (API, webhook, schedule, deployed chat)**: Workflow owner's personal variables
|
|
|
|
<Callout type="info">
|
|
Personal variables are best for testing. Use workspace variables for production workflows.
|
|
</Callout>
|
|
|
|
## Security Best Practices
|
|
|
|
### For Sensitive Data
|
|
- Store API keys, tokens, and passwords as environment variables instead of hardcoding them
|
|
- Use workspace variables for shared resources that multiple team members need
|
|
- Keep personal credentials in personal variables
|
|
|
|
### Variable Naming
|
|
- Use descriptive names: `DATABASE_URL` instead of `DB`
|
|
- Follow consistent naming conventions across your team
|
|
- Consider prefixes to avoid conflicts: `PROD_API_KEY`, `DEV_API_KEY`
|
|
|
|
### Access Control
|
|
- Workspace environment variables respect workspace permissions
|
|
- Only users with write access or higher can create/modify workspace variables
|
|
- Personal variables are always private to the individual user |