Datalore 2025.6 Help

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.

  • 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:

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.

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 :

print(os.environ["github_token"])

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.

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

Screenshot of predefined variables accessed in a Python code cell
21 October 2025