Skip to main content
Environment variables are dynamic values you define during importer initialization and then access in the sheet configuration. Use them to configure the environment of your importer. The values you pass at initialization replace the placeholders referenced in the sheet settings with double curly braces.

Defining environment variables

1

Create the environment object

Create an object named environment.
2

Add your variables

Add the variables to this object in <key>: <value> format.
3

Pass the object to the importer

Pass the environment object as a parameter to the importer initialization function.
Pass the environment object to the CSVBoxImporter function:
Environment variable names must not contain spaces or special characters other than _ (underscore).
env_name is a CSVbox reserved keyword that tags the environment. Each import is categorized by its value: pass values such as 'production', 'staging', or 'local'. If you don’t pass a value, env_name defaults to 'default'. You can filter individual imports by env_name in the CSVbox admin dashboard.
Filter via Environment on the Import page

Filter via Environment on the Import page

Accessing the variables

Environment variable values replace all the environment placeholders in the sheet settings. Define a placeholder with double curly brackets: {{ environment_variable_name }}. For example, to reference an environment variable named base_url, wrap the variable name in double curly braces: {{base_url}}/route-endpoint Using environment variables in the webhook URL lets you adjust the webhook route to the specific environment.
Defining Environment Placeholder

Defining Environment Placeholder

Beyond defining the environment, these variables can configure the importer dynamically based on end users or any other system parameters. For example, define an environment variable user_id and pass it to the webhook URL to configure the URL per end user.
user_id environment variable in the webhook URL

user_id env variable

You can also access environment variables in Validation Functions, Virtual Columns, and Data Transforms JavaScript code.

Encrypting environment variables

You can encrypt environment variables with the AES Everywhere library to protect sensitive data.

AES Everywhere library

The AES Everywhere library provides a simple, effective way to encrypt and decrypt data with the Advanced Encryption Standard (AES) algorithm. It supports many platforms and programming languages, which makes it a versatile choice for securing environment variables. CSVbox supports multiple encryption schemes for securing sensitive importer data at rest. Choose the mode that best fits your security or compliance requirements.

Supported encryption types

Steps

1

Install the library

Install the AES Everywhere library in your app.
2

Open the encryption key settings

In your app admin dashboard, go to Account Menu → API Keys page → Encryption Key section.
3

Choose the encryption settings

Select the Encryption Type and Encryption Mode.
4

Generate an encryption key

Generate a secure encryption key.
5

Encrypt the environment variables

Use your encryption key and the AES Everywhere library to encrypt the environment variables.
Encrypt all the required environment variables in one single object.
Here is an example in JavaScript:
6

Pass the encrypted value

Add the encrypted value to the environment object, under the env_encrypted key.
Javascript
The CSVbox importer decrypts the environment variables with the same AES Everywhere library.