-
Notifications
You must be signed in to change notification settings - Fork 45
Environment Variables
Environments let you switch between different API configurations (development, staging, production) without changing your requests.
- Click the environment dropdown in the header bar
- Select Manage Environments
- Add variables:
-
baseUrl→http://localhost:3000 -
apiKey→dev-key-12345
-
- Use
{{baseUrl}}and{{apiKey}}in your requests - Switch environments with
Ctrl+E
Environments are stored as YAML files in your collection:
.apiark/
└── environments/
├── development.yaml
├── staging.yaml
└── production.yaml
# .apiark/environments/development.yaml
name: Development
variables:
baseUrl: http://localhost:3000
apiVersion: v2
apiKey: dev-key-12345
timeout: "5000"
secrets:
- accessToken # Value stored in .env, not here
- adminPassword# .apiark/environments/production.yaml
name: Production
variables:
baseUrl: https://api.example.com
apiVersion: v2
apiKey: prod-key-67890
timeout: "30000"
secrets:
- accessToken
- adminPasswordStored in the YAML file, visible in Git, shareable with your team.
variables:
baseUrl: https://api.example.com
apiKey: public-key-12345Values stored in .env file (gitignored), masked in the UI by default.
secrets:
- accessToken
- dbPassword# .apiark/.env
accessToken=eyJhbGciOiJIUzI1NiIs...
dbPassword=super-secret-passwordSecrets are never committed to Git, never written to history, and never logged.
Apply to ALL collections. Managed in Settings → Global Environment.
{{baseUrl}}/api/users/{{userId}}
headers:
Authorization: "Bearer {{accessToken}}"
X-API-Key: "{{apiKey}}"{
"email": "{{userEmail}}",
"token": "{{accessToken}}"
}// Read
const url = ark.env.get("baseUrl");
// Write
ark.env.set("userId", "usr_123");
// Delete
ark.env.unset("tempVar");
// Get all
const vars = ark.env.toObject();Built-in variables that generate values on each request:
| Variable | Example Output | Description |
|---|---|---|
{{$uuid}} |
550e8400-e29b-41d4-a716-446655440000 |
Random UUID v4 |
{{$timestamp}} |
1710345600 |
Unix timestamp (seconds) |
{{$timestampMs}} |
1710345600000 |
Unix timestamp (milliseconds) |
{{$isoTimestamp}} |
2026-03-13T12:00:00.000Z |
ISO 8601 timestamp |
{{$randomInt}} |
742 |
Random integer 0-1000 |
{{$randomFloat}} |
0.8234 |
Random float 0-1 |
{{$randomString}} |
aB3dE5fG7hI9jK1m |
Random 16-char alphanumeric |
{{$randomEmail}} |
user_abc123@example.com |
Random email address |
url: "{{baseUrl}}/api/users"
headers:
X-Request-ID: "{{$uuid}}"
X-Timestamp: "{{$isoTimestamp}}"
body:
type: json
content: |
{
"email": "{{$randomEmail}}",
"name": "Test User {{$randomInt}}"
}Variables are resolved in this order (later overrides earlier):
- Global variables (apply to all collections)
-
Collection defaults (from
apiark.yaml) -
Active environment (from
environments/*.yaml) -
Folder variables (from
_folder.yaml) - Request-level variables (set in scripts)
-
Dynamic variables (
{{$uuid}}, etc.)
ApiArk auto-loads .env files from the collection root:
# .apiark/.env
DATABASE_URL=postgres://localhost:5432/mydb
API_SECRET=my-secret-key
JWT_TOKEN=eyJhbGciOiJIUzI1NiIs...These values are available as {{DATABASE_URL}}, {{API_SECRET}}, etc.
The
.envfile is auto-added to.gitignorewhen you create a collection.
Click the eye icon next to any variable reference in the URL bar or editors to peek at the current resolved value without switching to the environment panel.
- Use environments for per-stage config: Base URLs, API keys, feature flags
- Use secrets for sensitive values: Tokens, passwords, private keys
- Use scripts for dynamic values: Computed values, chained request data
-
Use
.envfor machine-specific config: Local DB URLs, personal tokens -
Name clearly:
baseUrlnoturl,adminTokennottoken
ApiArk — No login. No cloud. No bloat. | Website | GitHub | MIT License
Getting Started
Core Features
Advanced Features
Tools
Resources