Configuration
The SDK uses a layered configuration system that prioritizes explicit options, falls back to environment variables, and auto-detects everything it can.Configuration Hierarchy
Environment Variables
| Variable | Description |
|---|---|
ZENDFI_API_KEY | Primary API key (server-side) |
NEXT_PUBLIC_ZENDFI_API_KEY | Next.js public API key |
REACT_APP_ZENDFI_API_KEY | Create React App API key |
ZENDFI_API_URL | Custom API base URL |
ZENDFI_ENVIRONMENT | Force environment (development / staging / production) |
NEXT_PUBLIC_ZENDFI_ENVIRONMENT | Next.js environment override |
Auto-Detection
Mode Detection
Mode is determined from the API key prefix:Environment Detection
The SDK checks these signals in order:ZENDFI_ENVIRONMENTenv varNODE_ENVvalue (production/staging/development)- Browser hostname (
localhost= development,.vercel.app= staging) - Falls back to
development
Safety Warnings
The SDK prints warnings for dangerous mode/environment mismatches:CLI Credentials
If you ranzendfi init, the SDK loads your key from ~/.zendfi/credentials.json:
Full Config Reference
Default Values
| Option | Default | Source |
|---|---|---|
apiKey | - | Env var or CLI config |
baseURL | https://api.zendfi.tech | ZENDFI_API_URL or hardcoded |
environment | Auto-detected | NODE_ENV or hostname |
mode | Auto-detected | API key prefix |
timeout | 30000 | Hardcoded |
retries | 3 | Hardcoded |
idempotencyEnabled | true | Hardcoded |
debug | false | Hardcoded |