Skip to content

Go to the docs contents

Variables and secrets

Your keys and passwords are kept encrypted by while, never in the code or in while.yaml. They reach your app at the next deployment.

Updated November 21, 2026.

View as Markdown

Environment variables and secrets kept encrypted, never in the code: the password line redacted and the page closed with a padlock

You, to your AI: Add the variable LOG_LEVEL=info.

What your agent writes

Your agent writes it in while.yaml, at the root of your app:

while.yaml
apiVersion: while/v1
project: my-app
services:
  - name: web
    port: 3000
    env:
      MODE: demo
      STRIPE_KEY: { secret: payment/key }
      API_KEY: { secret: api/key, file: true }

When to use it

For every key and every password: never in while.yaml, never in the code.

How it works

Your keys and passwords are set with set_env, or referenced in while.yaml, and while keeps them encrypted in its vault. They reach the app at the next deployment, as a variable or as a file in /run/secrets/<NAME>.

What to know

A secret set as a file (file: true) never arrives as a variable. The app reads it in /run/secrets/<NAME> (in Node with readFile, in Python with Path.read_text, in Go with os.ReadFile), removing the final line break if there is one. The variables that while sets itself, such as DATABASE_URL or the connections’ addresses, keep their name.

In a project linked to a federated connection whose “approve each production deployment” box is checked, a secret never arrives as an environment variable: set_env and the production deployment refuse it, and it is set as a file. In this project, the variables are all in clear text, and shown to the person who approves.

Under env:, a plain-text variable is written NAME: value (MODE: demo), and a secret is written NAME: { secret: <path> }.

A service’s env: is seen by the other services of the same environment, and by the tasks that use the image of one of them. What must stay with a single service goes in another project.

Your agent’s MCP tools

Your agent handles it with the set_env tool.

Guides

Give your AI the message, and it takes care of the rest

Give this to your AI

Read while.sh/agents and help me get started with while.

Copy the message

In 3 minutes, with no sign-up, the tool has its own address. To keep it, create your account.

For a company project, write to the while team: hello@while.sh