Reading10 min
API Keys: eat_test_ vs eat_live_ and RBAC Roles
📦 Module 9: Ship to Production
API Keys: eat_test_ vs eat_live_ and RBAC Roles
Two prefixes. Two completely different worlds.
Test vs Live Keys
| Prefix | Environment | What It Hits | Safe to Experiment? |
|---|---|---|---|
eat_test_ | Sandbox | Simulated devices, fake data | Yes. Break things. |
eat_live_ | Production | Real meters, real batteries, real money | No. Be careful. |
The platform is designed so your code stays identical. Only the key changes.
# Development — sandbox
export EAT_API_KEY="eat_test_abc123def456"
# Production — real devices at Khazna
export EAT_API_KEY="eat_live_xyz789ghi012"
# Same script, both environments
python3 battery_optimizer.pyThe 5 RBAC Roles
Every API key is tied to a role. Each role has different permissions.
| Role | Read Data | Dispatch | Settle / Attest | Manage Users | Manage Billing |
|---|---|---|---|---|---|
| admin | Yes | Yes | Yes | Yes | Yes |
| operator | Yes | Yes | Yes | No | No |
| viewer | Yes | No | No | No | No |
| developer | Yes | Sandbox only | Sandbox only | No | No |
| agent | Yes | No | No | No | No |
Which Role for Which App?
- Monitoring dashboard that only reads data? Use
viewer. - Battery dispatch automation? Use
operator. - MCP agent that only answers questions? Use
agent. - Your development sandbox? Use
developer. - Never use `admin` unless you are managing users or billing.
The Golden Rule
Never commit a live key to git. Not once. Not even "temporarily."
# .env file (git-ignored)
EAT_API_KEY=eat_live_abc123
# .gitignore
.env# In your code
import os
api_key = os.environ["EAT_API_KEY"] # Never hardcodedIf you push eat_live_ to GitHub, rotate the key immediately from the API Keys page. DEWA does not care that it was an accident.
Log in to track your progress and earn certifications.