> ## Documentation Index
> Fetch the complete documentation index at: https://archie.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Environment variables

> Give a service its configuration and secrets. Variables are shared by every service in the environment and reach your code the next time you deploy.

Your service's code reads configuration, such as API URLs and sender addresses, from environment variables. Archie injects them into the service's container when it deploys.

## Open the variables

Open a service and select the **Environment variables** tab. The **Shared** badge on the tab tells you these variables aren't specific to this service.

![The Environment variables tab with six variables whose values are masked, an empty row to add a variable, and a Secrets section.](https://mintcdn.com/archie-e998dbf6/FcInvfd50seksJIy/images/37-logic-environment-variables.png?fit=max\&auto=format\&n=FcInvfd50seksJIy\&q=85\&s=a6ad8dffbccd76244b5dca3d0e80f45b)

The tab explains it in one line: "These variables are shared by every function in this environment. Per-function variables are coming later."

## Shared with Settings

The tab shows the same variables as **Backend → Settings → Environment variables**. Both editors read and write the environment's variables, so a change in one appears in the other. See [Environment variables](https://archie.com/docs/backend/settings/environment-variables.md) in Settings.

Variables belong to an [environment](https://archie.com/docs/backend/environments.md). A service in `master` receives the variables of `master`.

## Add and edit variables

The **Key** and **Value** table lists your variables. Values are masked. Use the eye icon at the end of a row to show a value, and the X icon to remove the row.

1. Type a name in the empty **Add Key** field at the bottom of the table, and its value in **Add Value**. Or click **Add Variable**.
2. Click **Save variables**.

Click **Cancel** to discard changes you haven't saved.

> [!NOTE]
>
> Saving doesn't change a running service. The new values reach the service the next time you [deploy](https://archie.com/docs/backend/logic/deployments.md). The deploy's **Load environment variables** step picks them up.

## Secrets

Scroll down below the variables table to the **Secrets** section. It holds values that must stay private. Archie describes them this way: "Encrypted and write-only: values are never shown again. Injected into the function container as secret env vars at deploy time."

The section has its own **Key** and **Value** table. Existing secrets show their keys with masked values. Click **Add Secret** to add a row, then click **Save variables**, the same button that saves the variables above.

Use secrets for API keys, tokens, and passwords.

> [!WARNING]
>
> Don't put sensitive values in plain variables or in your code. Plain values can be shown with the eye icon, and files are visible in the repository. Secrets are never shown again.

## Read variables in your code

Your code reads variables the usual way for its language. In a Go service, for example, `main.go` reads the port with `os.Getenv("PORT")`. Use the exact key you entered, such as `SENDER_EMAIL`.

## FAQ

> **Can one service have its own variables?**
>
> Not yet. The tab states that per-function variables are coming later. For now, every service in the environment receives the same set.

> **Do variables carry over to other environments?**
>
> Variables belong to one environment, and the tab shows the ones for the environment you selected. Check that each environment you deploy to has the variables your service needs. See [Environments](https://archie.com/docs/backend/environments.md).

> **Why does my service still use the old value?**
>
> Variables are read when you deploy. Save the change, then click **Deploy**.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.