
Environment variables are configuration values you keep in Nortly Console for one app, such as a base address or a feature switch. Nortly Console doesn't use them itself: your app reads them through the Identify API, Nortly's API for your app's own code. The [Identify API documentation](https://docs.nortly.app/docs/read-data-in-the-browser) explains how your app reads them.

## Before you start

- Your role needs the **Edit app settings** permission, and the app must be within your app access. **View app settings** alone isn't enough: without **Edit app settings**, **Dev** isn't in the app's menu and the page opens as "not found". See [Create roles and choose permissions](https://chatwoot.devit.group/hc/nortly/articles/roles-and-permissions).
- Your app needs an API key to call the Identify API. See [Create API keys for the Identify API](https://chatwoot.devit.group/hc/nortly/articles/api-keys-for-the-identify-api).

> **Note:** Values are shown in full, as plain text, to everyone who can open this page. Keep passwords and secret keys elsewhere.

## Open the environment variables

1. In Nortly Console, go to **Apps** and click the app.
2. In the app's menu in the sidebar, click **Dev**. **Environments** opens.

The list shows each variable's **Name**, **Type** and **Value**. A checkbox value reads **Yes** or **No**, and an empty value reads as a dash.

## Add a variable

1. On **Environments**, click **Add variable**.
2. In **Name**, enter the variable's name, for example "API_BASE_URL". Use letters, digits and underscores, and don't start with a digit. Nortly changes the name to capital letters.
3. In **Type**, choose the kind of value:
   - **text**: any text.
   - **number**: a number.
   - **checkbox**: on or off, shown as **Yes** or **No**.
   - **json**: structured data in JSON format.
   - **url**: a web address.
   - **date**: a date.
4. In **Value**, enter or pick the value. The field changes to match the type you chose.
5. Click **Save**.

Nortly confirms with "Saved" and the variable appears in the list. Each variable is saved on its own, as soon as you click **Save** in its dialog. Your app gets the new value the next time it reads its variables.

## Edit or delete a variable

1. On **Environments**, find the variable and click **Edit** or **Delete**.
2. To edit, change the **Value** and click **Save**. To delete, confirm in "Delete this variable?".

A variable's name and type can't be changed after you create it. To rename a variable or change its type, delete it and add a new one, then update your app if it reads the old name.

> **Note:** Your app stops getting a deleted variable at once. Check that your app no longer needs it before you delete it.

## If a variable isn't saved

| Message | What to do |
|---|---|
| "Name is required." | Enter a name. |
| "Use letters, digits and underscores; must not start with a digit." | Remove spaces, dashes and other symbols, and don't begin with a digit. "1API" is refused; "API_1" works. |
| "Name is too long." | Shorten the name. |
| "A variable with this name already exists for this app." | Choose another name. Names are compared in capital letters, so "api_key" and "API_KEY" are the same name. |
| "Value does not match the selected type." | Enter a value of the chosen type, for example a number for **number**. |

## What environment variables don't do

- They aren't shared between apps. Each app has its own list.
- They can't be used in custom action URLs. Custom actions take only the customer variables described in [Change app settings and add custom actions](https://chatwoot.devit.group/hc/nortly/articles/app-settings-and-custom-actions).
