Skip to main content

Environment variables

There are two options how you can set up environment variables for Actors.

Set up environment variables in .actor/actor.json

All keys from env will be set as environment variables into Apify platform after you push Actor to Apify. Current values on Apify will be overridden.

{
"actorSpecification": 1,
"name": "dataset-to-mysql",
"version": "0.1",
"buildTag": "latest",
"environmentVariables": {
"MYSQL_USER": "my_username",
"MYSQL_PASSWORD": "@mySecretPassword"
}
}

Set up environment variables in Apify Console

In Apify Console select your Actor, you can set up variables into Source tab. After setting up variables in the app, remove the environmentVariables from .actor/actor.json. Otherwise, variables from .actor/actor.json will override variables in the app.

{
"actorSpecification": 1,
"name": "dataset-to-mysql",
"version": "0.1",
"buildTag": "latest"
}

How to set secret environment variables in .actor/actor.json

CLI provides commands to manage secrets environment variables. Secrets are stored to the ~/.apify directory. You can add a new secret using the command:

apify secrets add mySecretPassword pwd1234

After adding a new secret you can use the secret in .actor/actor.json.

{
"actorSpecification": 1,
"name": "dataset-to-mysql",
...
"environmentVariables": {
"MYSQL_PASSWORD": "@mySecretPassword"
},
...
}

Need help?

To see all CLI commands simply run:

apify help

To get information about a specific command run:

apify help COMMAND

Still haven't found what you were looking for? Please go to Apify Help center or contact us.