Environment variables
Every variable the platform sets for your app, which ones are secret, and exactly when each one appears.
You never write the platform's variables. The platform sets them when it creates the sandbox your app runs in, so code in any language reads them the usual way: process.env, os.environ, os.Getenv.
Think of the environment as the name tag and the keys the platform hands your app at the door. The tag says where things are (addresses). One key, the token, opens the platform's services for your app, so it must stay in your pocket.
Only two variables hold the token (PLATFORM_TOKEN and AI_API_KEY), and the values you add as secrets. Everything else is an address or a setting, and is not secret.
Always set
These are in every sandbox the platform creates, whatever your settings file says.
PLATFORM_TOKENX-Platform-Binding-Token. Never print it, log it or send it to a browser.PLATFORM_CONTEXT{ "preset": "...", "expose": [...] }. cohostly types reads it. You rarely need it yourself.PLATFORM_LOGS_URLSet when you declare a binding
PLATFORM_BINDINGSai also lists its models. connections lists each connection's address, permissions and provider. The token is not in it.AI_BASE_URLbindings.ai. The AI gateway's address, ending in /ai.AI_API_KEYbindings.ai. The binding token itself, so stock AI libraries can send it as their key. It is not a provider key.APPROVALS_URLbindings.approvals. The approvals address, ending in /approvals.DATA_URLbindings.data. The database address.CRON_URLbindings.cron. The clock address.CONNECTION_<NAME>_URL<NAME> is the connection's name in upper case. The address of that connection's gateway.Good to know
cohostly manifest checkshows a placeholder whereAI_API_KEYwould be. At run time, the value is the real token.
Set only when the platform starts your app for a visitor
PLATFORM_LOGIN_URL/__platform/login. Send an anonymous visitor there to sign in.PLATFORM_AUTH_URL<it>/.well-known/jwks.json to verify the signed request context. It is also the issuer of that token.These two are added when the platform creates a sandbox to serve visitors. They are absent in sandboxes made for something else: a command-job sandbox for a scheduled run, and the throwaway sandbox used at deploy. PLATFORM_AUTH_URL is also set only when the platform has an auth address configured. A script that never serves visitors does not need either one.
Set only for scheduled command runs
These appear in a sandbox that runs a command for the clock binding. They are not set while your app serves visitors. More in what your app receives.
PLATFORM_RUN_IDPLATFORM_SCHEDULE_NAMEPLATFORM_SCHEDULED_FORPLATFORM_RUN_ATTEMPTPLATFORM_RUNPLATFORM_RUN_PAYLOAD_FILEPLATFORM_RUN.Your own values
Names in env.varscohostly.json.Names in env.secretscohostly secrets. Present once a value has been set.NODE_EXTRA_CA_CERTSenv.inject. The path to the platform's certificates, /etc/ssl/certs/ca-certificates.crt.How to declare them, the name rules, and how to set a secret without it passing through a chat are on your own values.
Not set by the platform
PORT. The platform does not set it. Listen on the port you declared inhealth.port.Number(process.env.PORT) || 3000is a safe habit, as long as 3000 matcheshealth.port.PLATFORM_APP_URL,PLATFORM_PROJECT_IDandPLATFORM_VERSION. These are not set either. If your app needs its own address to build a link, use the request's host header.
What is not a variable
Facts about each visit (who is calling, from where) change with every request. They arrive as headers and a signed token, not as environment variables. See request context.
Reserved names
You cannot use these for your own variables or secrets:
- Anything starting with
PLATFORM_orCONNECTION_. AI_API_KEY,AI_BASE_URL,APPROVALS_URL,DATA_URL,CRON_URLandPORT.
For a secret the platform refuses the name. For env.vars it is worse: a reserved name may pass the check and then be silently dropped when the app starts. Pick another name. See your own values.
Never
- Commit a
.envfile with real values. Add it to.gitignore. (If you leave it in the folder,cohostly deployalso reads it. See your own values.) - Print
PLATFORM_TOKEN,AI_API_KEYor a secret in a log line, an error message or a response. Printing a name is fine. Printing a value is not. - Send a secret to the browser. Keep it in server code.