# Manage environment variables

## About environment variables

Create sets of environment variables for your notebooks. Such variables can store passwords, API tokens, and other kinds of sensitive data for your notebooks to integrate with other services.

There are two basic cases of creating an environment variable:

* For a notebook You want to create an environment variable for a particular notebook you are working in right now. This will automatically attach the new environment variable to the notebook. > **Note:** > The new environment variable will also be added to the respective workspace. This means that you can then attach it to any notebook residing in that workspace.

* For a workspace You add an environment variable to a workspace where you want to use it in multiple notebooks. The procedure does not attach the new environment variable to the notebooks. You attach it later when working in the editor.

## Collaboration and permissions

This is how collaborators can manage environment variables:

* Environment variable owners (creators) can manage them on the workspace and notebook level

* Workspace collaborators with editor rights can attach already existing environment variables to, and detach them from, notebooks

* Workspace collaborators with viewer right can view environment variables

Find more information on managing environment variables in these articles:

* [Manage environment variables in a notebook](manage-environment-variables-in-a-notebook.html)

* [Manage environment variables in a workspace](manage-environment-variables-in-a-workspace.html)

## Example: Using an environment variable to pass a GitHub token

In the example below, information about the notebook owner's GitHub account is requested using an API token.

```PYTHON
r = requests.get('https://api.github.com/user',
                auth=('user_name', os.environ["github_token"]))
```

The token is passed in an environment variable with the github_token key. Users with edit permissions rights can use the code below to view the secured value :

```PYTHON
print(os.environ["github_token"])
```

> **Tip:**
> Datalore will suggest importing the `os` module as you start coding.

## Runtime variables

Runtime variables are environment variables available in Datalore notebooks when they are running.

You can access runtime variables in the same way as environment variables in notebook cells, `init.sh`, or [Terminal](terminal.html).

| Variable | Description |
| --- | --- |
| `OWNER_ID` | Notebook owner’s ID |
| `SOURCE_ID` | Has the `<OWNER_ID>/<NOTEBOOK_ID>` format |
| `RUN_ID` |    ID of the notebook’s scheduled run     > **Note:** > `RUN_ID` is only available during scheduled runs.    |

![Screenshot of predefined variables accessed in a Python code cell](https://resources.jetbrains.com.cn/help/img/datalore/2026.3/notebook_id.png)

