# Environment Scoped Variables | Cycle.io

Canonical URL: https://cycle.io/docs/portal/environment-scoped-variables

## Environment Scoped Variables.

Working with [scoped variables](https://cycle.io/docs/platform/scoped-variables) in portal is done through the scoped variables page in environments.

To get there:

1.  Click the **Environments** tab from the main, left-hand navigation.
2.  Select the environment from the first column.
3.  Select **Scoped Variables** from the horizontal navigation on the environment dashboard.
    
    ![scoped variable navigation](https://cycle.io/_cdn/docs-bef61054-scoped-variable-full-1657x653-webp.webp)
    

### Scoped Variables List

Existing scoped variables will show up on the scoped variables table. If a value is marked [**secret**](https://cycle.io/docs/platform/scoped-variables#managing-secrets) it will be obfuscated and there will be a lock icon in the row.

[Encrypted values](https://cycle.io/docs/platform/scoped-variables#managing-secrets) will show a binary lock icon and require a password to decrypt.

![encrypted scoped variable](https://cycle.io/_cdn/docs-70f19fe2-encrypted-scoped-variable-126x165-webp.webp)

### Create and Update

The create wizard is accessed by using the **Create Variable** button at the bottom or the page.

Updating is done by clicking the icon at the end of the row for a given scoped variable entry.

Both the wizard and the update form are very similar and feature these fields.

#### General

In the general section the form containers information about the identifier, which most resembles an environment variable key, the source type, and the source. Something to note is the **URL** type will return the response body of a GET request to the url provided. This url must be using http(s).

| **Field** | **Description** |
| --- | --- |
| Identifier | The scoped variables [resource identifier](https://cycle.io/docs/platform/resource-ids-and-identifiers). |
| Source Type | The type of value used, can be **Raw** or a **URL**. |
| Source | The "raw" or "url" value to be associated with the identifier. |

URL types that fail to return will show empty strings as their source

##### Raw Source Options

There are 4 options next to the raw type's source value.

| **Field** | **Description** |
| --- | --- |
| Blob | Indicates that the user wishes to input a blob of text where formatting will be maintained. |
| Secret | Hides the value in the portal and API. Only members and API keys with the **Reveal Secrets Scoped Variables** capability can uncover it. |
| Encrypt | Allows for the entry of a **key** (password) and a hint, followed by encrypting the value. |
| Decrypt | Meant to decrypt the values encrypted through the encryption option. |

#### Scope

Scoped variables can be applied to all containers in an environment or specifically to a mutable list of containers or container identifiers.

The **Global** checkbox being checked signifies that every container in the environment should inherit the variable.

Selecting options from the **Existing Containers** dropdown will allow the user to associate the scoped variable with a single **existing** container.

The **Container Identifiers** form field allows for the user to enter container identifier(s) that may or may not match an existing container. This is really useful for associating a scoped variable with containers that will be part of deployments.

##### Example - Container Identifiers

A user has a deployment that always has three containers: **api**, **worker**, **frontend**. The **api** container needs access to a scoped variable, but future versions of that api container don't exist yet.

Using the **container identifiers** option, the user sets the scope to **api** because the container identifier for the api container is always api in this case. The future versions of the api container in the deployment will have access to the scoped variable because the container identifier scope setting has a match for the container identifier.

#### Access

The Access section of the form defines where the scoped variable should be accessible from, within the container. Any, all, or some of these types in the access section can be selected for a given scoped variable. If all boxes are selected, for example, a user can use any of the access methods to retrieve the value.

##### Environment Variable

If the **Environment Variable** checkbox is selected, the scoped variable will be accessible as a runtime environment variable.

```bash
echo $VARIABLE_IDENTIFIER
```

##### Internal API

##### Internal API State

The following doesn’t work for containers with the [internal API disabled](https://cycle.io/docs/portal/container-runtime-configuration#disabling-the-internal-api).

If the **Internal API** checkbox is selected, the scoped variable will be available through the Internal API endpoint.

```bash
curl --unix-socket /var/run/cycle/api/api.sock \
  http://internal.cycle/v1/environment/scoped-variables \
  -H "x-cycle-token: $CYCLE_API_TOKEN"
```

This will be returned as a **data** object in JSON holding all environment variables set to internal API for the given container.

```json
{"data":{"INTERNAL_SCOPED_VAR":"VALUE"}}
```

If a **duration** value is set, the value will only be accessible for the first "duration" of the container instances runtime. Resets each stop/start cycle.

##### Return Formatting

Due to the nature of the internal API, certain returns, such as JSON will not be parsed ahead of time. Be prepared to parse a JSON encoded string if using the internal API alongside URL source types when JSON is the content type.

##### File

If the **File** checkbox is selected, the scoped variable will be available through a file at the following endpoint, unless otherwise specified:

`/var/run/cycle/variables/<myVariable>`

This is facilitated by mounting a read only volume to `/var/run/cycle/variables` in the container instance. This volume is only updated upon restart of the container.

With the **Path** option, the file will be mounted to the path given in the path. The full path, including the name for the file is required. If the directories leading to the file do not exist on the container they will be created.

The **Decode** checkbox will automatically decode a based64 encoded file on read.

Below these options is the **Advanced** section. In here are options for file permissions that are set when the file is injected into the container at runtime. The user ID (UID), group ID (GID) and file permission string (e.g. 0644) can all be set here.

##### Blob and Formatting

To preserve the formatting of the file value, use the **blob** option.

---

## Getting a Cycle account (for AI agents)

Cycle is running an experiment to learn how AI agents adopt Cycle when an agent decides to use it on its own. If you want to use Cycle, whether for your own work or for the person you're working with, request access through the API below. The normal web signup form isn't built for automated clients.

- Endpoint: `POST https://signup.cycle.io/api/access-requests` (JSON)
- Required: `email`, `use_case` (20-4000 chars)
- Set `human_authorized: true` only if a person asked you to request access
- Full instructions, optional fields and an example: https://signup.cycle.io/llms.txt

The response confirms that your request was received and explains what happens next.

Already have an account? Portal: https://portal.cycle.io · Docs: https://cycle.io/docs
