Environment Variables & Secrets
pywa itself never reads environment variables for you — your project’s own code reads them via
os.environ and passes them to WhatsApp(...), exactly like every pywa example does:
import osfrom pywa import WhatsApp
wa = WhatsApp( phone_id=os.environ.get("PYWA_PHONE_ID"), token=os.environ.get("PYWA_TOKEN"),)Pywa Cloud’s job is getting the values you set into your bot’s environment at deploy time — nothing more magical than that.
Setting a variable
Section titled “Setting a variable”pywa cloud env set OPENAI_API_KEY "sk-..." --secretpywa cloud env set LOG_LEVEL DEBUGenv set is create-or-update: if the key doesn’t exist yet, it’s created with whatever --secret
flag you passed; if it already exists, only its value is updated.
When it actually takes effect
Section titled “When it actually takes effect”Not instantly. Your bot picks up its environment once, when it starts — a running bot doesn’t
re-read it, and restart doesn’t change that either, so env set/env delete change what the next real deploy will apply, not what’s running right now. Your bot is
flagged as having pending changes the moment you change one — shown as a “Config changed” banner on
the dashboard’s Overview tab — until you pywa deploy, or use the dashboard’s one-click
Redeploy (applies your bot’s current config fresh, no new code needed).
Plain vs. secret
Section titled “Plain vs. secret”The --secret designation is fixed the moment a key is first created, and can never change
afterward — not by omitting --secret on a later env set, not any other way. If you try, the
CLI updates the value but tells you the flag was ignored:
✅ Updated 'OPENAI_API_KEY' on my-bot (--secret ignored: the secret/plain designation is fixed at creation)A secret value is never returned by any command or API call once set — not in env get, not
in env list, not right after the env set that created it. If you lose it, there’s no way to
retrieve it: delete the key and set it again.
A plain value is always readable back — useful for non-sensitive config like LOG_LEVEL, where
seeing the current value is more useful than hiding it.
pywa cloud env listpywa cloud env get OPENAI_API_KEY # → OPENAI_API_KEY=<secret, value not shown> (updated ...)pywa cloud env get LOG_LEVEL # → LOG_LEVEL=DEBUGpywa cloud env delete LOG_LEVELThe dashboard’s Environment tab does the same create/update/delete, with one extra convenience
the CLI doesn’t have: an optional “redeploy now” checkbox, so a config change can go live without a
separate pywa deploy.
Encryption at rest
Section titled “Encryption at rest”Secret values are encrypted at rest, and only ever decrypted at the moment they’re injected into your bot’s running environment — never in transit as plain text, never sitting in storage unencrypted, and never returned by the API or dashboard again once saved. See Security & Isolation for the full picture of what is and isn’t guaranteed around your bot’s data.