Environment variables

When a task or view runs—both locally in Studio and remotely in Airplane—a handful of environment variables are automatically set.
Tasks and views can be configured with additional user-defined environment variables. For more information, see the documentation on Task environment variables and View environment variables.

Tasks

The following environment variables are automatically set when a task is executed.
Variable NameDescription
AIRPLANE_ENV_IDID of the environment this run was executed in. Set to studio for Studio runs.
AIRPLANE_ENV_IS_DEFAULTWhether the run was executed in the default environment. Set to "true" for Studio runs.
AIRPLANE_ENV_SLUGSlug of the environment this run was executed in. Set to studio for Studio runs.
AIRPLANE_ENV_NAMEName of the environment this run was executed in. Set to studio for Studio runs.
AIRPLANE_REQUESTER_EMAILEmail of the user who requested the run.
AIRPLANE_REQUESTER_IDID of the user who requested the run.
AIRPLANE_REQUESTER_NAMEName of the user who requested the run.
AIRPLANE_RUN_IDID of the run.
AIRPLANE_RUN_URLURL that links to this run's page in the Airplane app.
AIRPLANE_RUNNER_EMAILEmail of the user who executed the run. If this run was requested, it is the user who executed the run, not the requester.
AIRPLANE_RUNNER_IDID of the user who executed the run. If this run was requested, it is the user who executed the run, not the requester.
AIRPLANE_RUNNER_NAMEName of the user who executed the run. If this run was requested, it is the user who executed the run, not the requester.
AIRPLANE_RUNTIMERuntime this run was executed in.
AIRPLANE_PARENT_RUN_IDID of the run that executed this run, if any.
AIRPLANE_SESSION_IDID of the runbook session that the run was executed from, if any.
AIRPLANE_TASK_IDID of the task the run belongs to.
AIRPLANE_TASK_NAMEName of the task the run belongs to.
AIRPLANE_TASK_SLUGSlug of the task the run belongs to.
AIRPLANE_TASK_URLURL that links to the task page the run belongs to in the Airplane app.
AIRPLANE_TASK_REVISION_IDID that identifies the specific version of the task the run belongs to.
AIRPLANE_TEAM_IDID of the team this run belongs to.
AIRPLANE_TRIGGER_IDID of the trigger that started the run.
AIRPLANE_RESOURCESJSON-encoded string containing a mapping of resource alias to a resource object.

Views

The following environment variables are automatically set when a view is executed.
Variable NameDescription
AIRPLANE_ENV_IDID of the environment this view is in. Set to studio for Studio runs.
AIRPLANE_ENV_IS_DEFAULTWhether the view is in the default environment. Set to "true" for Studio runs.
AIRPLANE_ENV_SLUGSlug of the environment this view is in. Set to studio for Studio runs.
AIRPLANE_ENV_NAMEName of the environment this view is in. Set to studio for Studio runs.
AIRPLANE_USER_EMAILEmail of the user who is using the view.
AIRPLANE_USER_IDID of the user who is using the view.
AIRPLANE_USER_NAMEName of the user who is using the view.
AIRPLANE_VIEW_IDID of the view.
AIRPLANE_VIEW_SLUGSlug of the view.
AIRPLANE_VIEW_NAMEName of the view.
AIRPLANE_VIEW_URLURL that links to the view page in the Airplane app.
AIRPLANE_TEAM_IDID of the team this view belongs to.
AIRPLANE_DEPLOYMENT_IDID of the view's deployment.

Resources

Resources in Airplane allow you to easily configure connections to external systems like databases and APIs and use them in your tasks. In most cases, resources are used to execute built-ins, which make it easy to perform common operations such as SQL queries.
When a resource is attached to a task, their fields are available through the AIRPLANE_RESOURCES environment variable. This is useful if you want to directly access that resource from your task without using a built-in. This environment variable is a JSON-serialized dictionary that maps resource slugs to a resource object. Each resource object will have different fields depending on its kind and are documented below.

BigQuery

For more information, see the BigQuery resource documentation.
javascript
Copied
1
{
2
"id": "res20220928z2hetnij0sn",
3
"name": "Prod database",
4
"slug": "prod_database",
5
"kind": "bigquery",
6
"credentials": "eyJjcmVkZW50aWFscyI6ICJmb29iYXIifQ==",
7
"dataSet": "dataset",
8
"dsn": "bigquery://my-project/us/dataset?credentials=eyJjcmVkZW50aWFscyI6ICJmb29iYXIifQ==",
9
"location": "us",
10
"projectId": "my-project"
11
}
FieldTypeDescription
idstringThe ID of the resource.
namestringThe name of the resource.
slugstringThe slug of the resource as defined in the resource settings page.
kindstringThe kind of the resource (bigquery).
credentialsstringThe credentials string.
dataSetstringThe dataset for your tables and views.
dsnstringThe DSN of the BigQuery resource.
locationstringThe geographic location of the stored data.
projectIdstringThe project ID.

GraphQL

For more information, see the GraphQL resource documentation.
javascript
Copied
1
{
2
"id": "res20220923z4ywfnglnxs",
3
"name": "GraphQL API",
4
"slug": "graphql_api",
5
"kind": "graphql",
6
"auth": {
7
"headers": {
8
"X-Auth-Token": "token_here"
9
},
10
"kind": "basic",
11
"password": "password_here",
12
"username": "user_here"
13
},
14
"baseURL": "https://example.com/graphql",
15
"headers": {
16
"Authorization": "Bearer token_here"
17
},
18
"secretHeaders": ["Authorization"]
19
}
FieldTypeDescription
idstringThe ID of the resource.
namestringThe name of the resource.
slugstringThe slug of the resource as defined in the resource settings page.
kindstringThe kind of the resource (graphql).
authobjectThe GraphQL auth configuration. Nullable.
auth.headersobjectAny headers specific to the authentication method.
auth.kindstringThe kind of auth configured for the GraphQL resource (basic).
auth.passwordstringThe password to use for basic authentication.
auth.usernamestringThe username to use for basic authentication.
baseURLstringThe base URL of the GraphQL API.
headersobjectMapping of header name to value.
secretHeadersarrayArray of header names that contain sensitive information.

Mailgun

For more information, see the Mailgun resource documentation.
javascript
Copied
1
{
2
"id": "res20220923z4ywfnglnxs",
3
"name": "Mailgun",
4
"slug": "mailgun",
5
"kind": "mailgun",
6
"apiKey": "key-1234567890",
7
"domain": "example.com"
8
}
FieldTypeDescription
idstringThe ID of the resource.
namestringThe name of the resource.
slugstringThe slug of the resource as defined in the resource settings page.
kindstringThe kind of the resource (mailgun).
apiKeystringThe Mailgun API key.
domainstringThe configured Mailgun domain.

Microsoft SQL Server

For more information, see the Microsoft SQL Server resource documentation.
javascript
Copied
1
{
2
"id": "res20220923z4ywfnglnxs",
3
"name": "Prod database",
4
"slug": "prod_database",
5
"kind": "sqlserver",
6
"database": "database",
7
"dsn": "sqlserver://user:password@mysqldbhost:1433/database",
8
"encryptMode": "disable",
9
"host": "mysqldbhost",
10
"password": "password",
11
"port": "1433",
12
"username": "user"
13
}
FieldTypeDescription
idstringThe ID of the resource.
namestringThe name of the resource.
slugstringThe slug of the resource as defined in the resource settings page.
kindstringThe kind of the resource (sqlserver).
databasestringThe name of the database.
dsnstringThe dsn of the server.
encryptModestringThe encryption mode setting (disable or true).
hoststringThe host of the server.
passwordstringThe login password.
portstringThe port of the server.
sshHoststringOptional SSH host for tunneling.
sshPortstringOptional SSH port for tunneling.
sshPrivateKeystringOptional SSH private key for tunneling.
sshUsernamestringOptional SSH username for tunneling.
usernamestringThe login username.

MongoDB

For more information, see the MongoDB resource documentation.
javascript
Copied
1
{
2
"id": "res20220923z4ywfnglnxs",
3
"name": "Prod database",
4
"slug": "prod_database",
5
"kind": "mongodb",
6
"connectionString": "mongodb://user:password@host:27017/database"
7
}
FieldTypeDescription
idstringThe ID of the resource.
namestringThe name of the resource.
slugstringThe slug of the resource as defined in the resource settings page.
kindstringThe kind of the resource (mongodb).
connectionStringstringThe MongoDB connection string.

MySQL

For more information, see the MySQL resource documentation.
javascript
Copied
1
{
2
"id": "res20220923z4ywfnglnxs",
3
"name": "Prod database",
4
"slug": "prod_database",
5
"kind": "mysql",
6
"database": "database",
7
"dsn": "mysql://user:password@mysqldbhost:3306/database?tls=skip-verify",
8
"host": "mysqldbhost",
9
"password": "password",
10
"port": "3306",
11
"tls": "skip-verify",
12
"username": "user"
13
}
FieldTypeDescription
idstringThe ID of the resource.
namestringThe name of the resource.
slugstringThe slug of the resource as defined in the resource settings page.
kindstringThe kind of the resource (mysql).
databasestringThe name of the database.
dsnstringThe DSN of the server.
hoststringThe host of the server.
passwordstringThe login password.
portstringThe port of the server.
sshHoststringOptional SSH host for tunneling.
sshPortstringOptional SSH port for tunneling.
sshPrivateKeystringOptional SSH private key for tunneling.
sshUsernamestringOptional SSH username for tunneling.
tlsstringThe TLS verification setting (false or skip-verify).
usernamestringThe login username.

PostgreSQL

For more information, see the PostgreSQL resource documentation.
javascript
Copied
1
{
2
"id": "res20220923z4ywfnglnxs",
3
"name": "Prod database",
4
"slug": "prod_database",
5
"kind": "postgres",
6
"database": "database",
7
"dsn": "postgres://user:password@postgresdbhost:5432/database",
8
"host": "postgresdbhost",
9
"password": "password",
10
"port": "5432",
11
"sslMode": "disable",
12
"username": "user"
13
}
FieldTypeDescription
idstringThe ID of the resource.
namestringThe name of the resource.
slugstringThe slug of the resource as defined in the resource settings page.
kindstringThe kind of the resource (postgres).
databasestringThe name of the database.
dsnstringThe dsn of the server.
hoststringThe host of the server.
passwordstringThe login password.
portstringThe port of the server.
sshHoststringOptional SSH host for tunneling.
sshPortstringOptional SSH port for tunneling.
sshPrivateKeystringOptional SSH private key for tunneling.
sshUsernamestringOptional SSH username for tunneling.
sslModestringThe SSL mode setting (disable or require).
usernamestringThe login username.

Redshift

For more information, see the Redshift resource documentation.
javascript
Copied
1
{
2
"id": "res20220923z4ywfnglnxs",
3
"name": "Prod database",
4
"slug": "prod_database",
5
"kind": "redshift",
6
"database": "database",
7
"dsn": "redshift://user:password@redshiftdbhost:5439/database",
8
"host": "redshiftdbhost",
9
"password": "password",
10
"port": "5439",
11
"sslMode": "disable",
12
"username": "user"
13
}
FieldTypeDescription
idstringThe ID of the resource.
namestringThe name of the resource.
slugstringThe slug of the resource as defined in the resource settings page.
kindstringThe kind of the resource (redshift).
databasestringThe name of the database.
dsnstringThe dsn of the server.
hoststringThe host of the server.
passwordstringThe login password.
portstringThe port of the server.
sshHoststringOptional SSH host for tunneling.
sshPortstringOptional SSH port for tunneling.
sshPrivateKeystringOptional SSH private key for tunneling.
sshUsernamestringOptional SSH username for tunneling.
sslModestringThe SSL mode setting (disable or require).
usernamestringThe login username.

REST API

For more information, see the REST API resource documentation.
javascript
Copied
1
{
2
"id": "res20220923z4ywfnglnxs",
3
"name": "Rest API",
4
"slug": "rest_api",
5
"kind": "rest",
6
"auth": {
7
"kind": "basic",
8
"username": "user",
9
"password": "password"
10
},
11
"baseURL": "https://api.example.com",
12
"headers": {
13
"Content-Type": "application/json"
14
}
15
}
FieldTypeDescription
idstringThe ID of the resource.
namestringThe name of the resource.
slugstringThe slug of the resource as defined in the resource settings page.
kindstringThe kind of the resource (rest).
authobjectThe REST auth configuration. Nullable.
auth.headersobjectAny headers specific to the authentication method.
auth.kindstringThe kind of auth configured for the REST resource (basic).
auth.passwordstringThe password to use for basic authentication.
auth.usernamestringThe username to use for basic authentication.
baseURLstringThe base URL of the REST API.
headersobjectMapping of header name to value.
secretHeaderslistList of header names that contain sensitive information.

SendGrid

For more information, see the SendGrid resource documentation.
javascript
Copied
1
{
2
"id": "res20220923z4ywfnglnxs",
3
"name": "SendGrid",
4
"slug": "send_grid",
5
"kind": "sendgrid",
6
"apiKey": "SG.1234567890"
7
}
FieldTypeDescription
idstringThe ID of the resource.
namestringThe name of the resource.
slugstringThe slug of the resource as defined in the resource settings page.
kindstringThe kind of the resource (sendgrid).
apiKeystringThe SendGrid API key.

SMTP

For more information, see the SMTP resource documentation.
javascript
Copied
1
{
2
"id": "res20220923z4ywfnglnxs",
3
"name": "SMTP",
4
"slug": "smtp",
5
"kind": "smtp",
6
"auth": {
7
"kind": "login",
8
"username": "user",
9
"password": "password"
10
},
11
"hostname": "smtp.example.com",
12
"port": "3000"
13
}
FieldTypeDescription
idstringThe ID of the resource.
namestringThe name of the resource.
slugstringThe slug of the resource as defined in the resource settings page.
kindstringThe kind of the resource (smtp).
authobjectThe SMTP auth configuration.
auth.kindstringThe kind of auth configured for the REST resource (plain or crammd5 or login).
auth.identitystringThe login identity. (Only set for plain auth.)
auth.passwordstringThe password to use for basic authentication.
auth.usernamestringThe username to use for basic authentication.
auth.secretstringThe login password digest. (Only set for crammd5 auth.)
hostnamestringThe hostname of the SMTP server.
portstringThe port of the SMTP server.

Snowflake

For more information, see the Snowflake resource documentation.
javascript
Copied
1
{
2
"id": "res20220923z4ywfnglnxs",
3
"name": "Prod database",
4
"slug": "prod_database",
5
"kind": "snowflake",
6
"account": "my-account",
7
"database": "my-database",
8
"dsn": "snowflake://user:password@my-account/my-database/my-schema?warehouse=my-warehouse&role=my-role",
9
"password": "password",
10
"role": "my-role",
11
"schema": "my-schema",
12
"username": "user",
13
"warehouse": "my-warehouse"
14
}
FieldTypeDescription
idstringThe ID of the resource.
namestringThe name of the resource.
slugstringThe slug of the resource as defined in the resource settings page.
kindstringThe kind of the resource (snowflake).
accountstringThe Snowflake account.
databasestringThe name of the database.
dsnstringThe dsn of the server.
passwordstringThe login password.
rolestringThe role configured for the Snowflake resource.
schemastringThe name of the schema.
usernamestringThe login username.
warehousestringThe virtual warehouse name.