Environment Variables

Environment variables give you a way to separate secrets and other data from your code.

For example, you wouldn't want to include an API key in a code cell of a workflow. On the free tier, all workflow code is public, so anyone would be able to see your API key in plain sight. By referencing the value of an environment variable, instead, your public workflow includes a reference to that variable — process.env.API_KEY — instead of the API key itself.

Environment variables are defined at the account-level, and can be referenced in code cells in any workflow.

Creating, updating environment variables

Environment variables are managed at the account-level. You can access your environment variables by clicking on the Settings link in the header of the app or by visiting https://pipedream.com/environment

If this is your first time adding an environment variable, you'll see a menu prompting you to add a new Key and associated Value:

Add a new env var

You can add another environment variable by clicking on the + button to the right of the text boxes, or remove it by clicking on the - button:

Add or remove env var

Any changes you make to environment variables — adding, removing, or updating one — must be saved for them to take effect. You'll see the green Save button appear in the footer of the page when you've made changes that need to be saved.

Updates to environment variables will be made available to your workflows as soon as the save operation is complete — typically a few seconds after you click Save. So if you update the value of an environment variable in the UI, your workflow should automatically use that new value where it's referenced.

There are some restrictions on the names and values of environment variables — see the limits section below. If you encounter these constraints, you'll typically see a helpful error message noting what the issue is:

Error message

Referencing environment variables in code

In Node.js code cells, you can reference the value of any environment variable using the Node-provided object process.env. This object contains environment variables as key-value pairs.

For example, let's say you have an environment variable named API_KEY. You can reference its value using process.env.API_KEY:

const url = `http://yourapi.com/endpoint/?api_key=${process.env.API_KEY}`;

Variable names are case-sensitive. Use the name you defined in your Environment settings in the app when referencing your variable in process.env.

Referencing an environment variable that doesn't exist returns the value undefined in Node.js. For example, if you try to reference process.env.API_KEY without first defining the API_KEY variable in your environment settings, it will return the value undefined.

Logging the value of any environment variables — for example, using console.log — will include that value in the logs associated with the cell. Please keep this in mind and take care not to print the values of sensitive secrets.

Forking workflows that use environment variables

Your environment variables are made available to any running workflow. If you fork a public workflow that uses an environment variable, make sure you review the code to see what environment variables it's using.

Reviewing the code ensures you have the necessary variables defined for the workflow to run correctly, and makes sure the original workflow author isn't reading variables that you don't need for the workflow to function. You can always modify the code for the workflow after forking to remove these variables, or change their names.

Limits

The value of any environment variable may be no longer than 256 characters.

The names of environment variables must start with a letter. Following characters can use any alpha-numeric character or an underscore (_).

Pipedream reserves environment variables that start with PIPEDREAM_ for internal use. You cannot create an environment variable that begins with that prefix.

The total size of both the names and values of your environment variables cannot exceed 4KB in length (that is, roughly 4096 characters).

Still have questions?

Please reach out if this doc didn't answer your question. We're happy to help!