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
Tasks
The following environment variables are automatically set when a task is executed.
| Variable Name | Description |
|---|---|
AIRPLANE_ENV_ID | ID of the environment this run was executed in. Set to studio for Studio runs. |
AIRPLANE_ENV_IS_DEFAULT | Whether the run was executed in the default environment. Set to "true" for Studio runs. |
AIRPLANE_ENV_SLUG | Slug of the environment this run was executed in. Set to studio for Studio runs. |
AIRPLANE_ENV_NAME | Name of the environment this run was executed in. Set to studio for Studio runs. |
AIRPLANE_REQUESTER_EMAIL | Email of the user who requested the run. |
AIRPLANE_REQUESTER_ID | ID of the user who requested the run. |
AIRPLANE_REQUESTER_NAME | Name of the user who requested the run. |
AIRPLANE_RUN_ID | ID of the run. |
AIRPLANE_RUN_URL | URL that links to this run's page in the Airplane app. |
AIRPLANE_RUNNER_EMAIL | Email 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_ID | ID 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_NAME | Name of the user who executed the run. If this run was requested, it is the user who executed the run, not the requester. |
AIRPLANE_RUNTIME | Runtime this run was executed in. |
AIRPLANE_PARENT_RUN_ID | ID of the run that executed this run, if any. |
AIRPLANE_SESSION_ID | ID of the runbook session that the run was executed from, if any. |
AIRPLANE_TASK_ID | ID of the task the run belongs to. |
AIRPLANE_TASK_NAME | Name of the task the run belongs to. |
AIRPLANE_TASK_SLUG | Slug of the task the run belongs to. |
AIRPLANE_TASK_URL | URL that links to the task page the run belongs to in the Airplane app. |
AIRPLANE_TASK_REVISION_ID | ID that identifies the specific version of the task the run belongs to. |
AIRPLANE_TEAM_ID | ID of the team this run belongs to. |
AIRPLANE_TRIGGER_ID | ID of the trigger that started the run. |
AIRPLANE_RESOURCES | JSON-encoded string containing a mapping of resource alias to a resource object. |
Views
Views
The following environment variables are automatically set when a view is executed.
| Variable Name | Description |
|---|---|
AIRPLANE_ENV_ID | ID of the environment this view is in. Set to studio for Studio runs. |
AIRPLANE_ENV_IS_DEFAULT | Whether the view is in the default environment. Set to "true" for Studio runs. |
AIRPLANE_ENV_SLUG | Slug of the environment this view is in. Set to studio for Studio runs. |
AIRPLANE_ENV_NAME | Name of the environment this view is in. Set to studio for Studio runs. |
AIRPLANE_USER_EMAIL | Email of the user who is using the view. |
AIRPLANE_USER_ID | ID of the user who is using the view. |
AIRPLANE_USER_NAME | Name of the user who is using the view. |
AIRPLANE_VIEW_ID | ID of the view. |
AIRPLANE_VIEW_SLUG | Slug of the view. |
AIRPLANE_VIEW_NAME | Name of the view. |
AIRPLANE_VIEW_URL | URL that links to the view page in the Airplane app. |
AIRPLANE_TEAM_ID | ID of the team this view belongs to. |
AIRPLANE_DEPLOYMENT_ID | ID of the view's deployment. |
Resources
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
BigQuery
For more information, see the BigQuery resource documentation.
javascriptCopied1{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}
| Field | Type | Description |
|---|---|---|
id | string | The ID of the resource. |
name | string | The name of the resource. |
slug | string | The slug of the resource as defined in the resource settings page. |
kind | string | The kind of the resource (bigquery). |
credentials | string | The credentials string. |
dataSet | string | The dataset for your tables and views. |
dsn | string | The DSN of the BigQuery resource. |
location | string | The geographic location of the stored data. |
projectId | string | The project ID. |
GraphQL
GraphQL
For more information, see the GraphQL resource documentation.
javascriptCopied1{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}
| Field | Type | Description |
|---|---|---|
id | string | The ID of the resource. |
name | string | The name of the resource. |
slug | string | The slug of the resource as defined in the resource settings page. |
kind | string | The kind of the resource (graphql). |
auth | object | The GraphQL auth configuration. Nullable. |
auth.headers | object | Any headers specific to the authentication method. |
auth.kind | string | The kind of auth configured for the GraphQL resource (basic). |
auth.password | string | The password to use for basic authentication. |
auth.username | string | The username to use for basic authentication. |
baseURL | string | The base URL of the GraphQL API. |
headers | object | Mapping of header name to value. |
secretHeaders | array | Array of header names that contain sensitive information. |
Mailgun
Mailgun
For more information, see the Mailgun resource documentation.
javascriptCopied1{2"id": "res20220923z4ywfnglnxs",3"name": "Mailgun",4"slug": "mailgun",5"kind": "mailgun",6"apiKey": "key-1234567890",7"domain": "example.com"8}
| Field | Type | Description |
|---|---|---|
id | string | The ID of the resource. |
name | string | The name of the resource. |
slug | string | The slug of the resource as defined in the resource settings page. |
kind | string | The kind of the resource (mailgun). |
apiKey | string | The Mailgun API key. |
domain | string | The configured Mailgun domain. |
Microsoft SQL Server
Microsoft SQL Server
For more information, see the Microsoft SQL Server resource documentation.
javascriptCopied1{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}
| Field | Type | Description |
|---|---|---|
id | string | The ID of the resource. |
name | string | The name of the resource. |
slug | string | The slug of the resource as defined in the resource settings page. |
kind | string | The kind of the resource (sqlserver). |
database | string | The name of the database. |
dsn | string | The dsn of the server. |
encryptMode | string | The encryption mode setting (disable or true). |
host | string | The host of the server. |
password | string | The login password. |
port | string | The port of the server. |
sshHost | string | Optional SSH host for tunneling. |
sshPort | string | Optional SSH port for tunneling. |
sshPrivateKey | string | Optional SSH private key for tunneling. |
sshUsername | string | Optional SSH username for tunneling. |
username | string | The login username. |
MongoDB
MongoDB
For more information, see the MongoDB resource documentation.
javascriptCopied1{2"id": "res20220923z4ywfnglnxs",3"name": "Prod database",4"slug": "prod_database",5"kind": "mongodb",6"connectionString": "mongodb://user:password@host:27017/database"7}
| Field | Type | Description |
|---|---|---|
id | string | The ID of the resource. |
name | string | The name of the resource. |
slug | string | The slug of the resource as defined in the resource settings page. |
kind | string | The kind of the resource (mongodb). |
connectionString | string | The MongoDB connection string. |
MySQL
MySQL
For more information, see the MySQL resource documentation.
javascriptCopied1{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}
| Field | Type | Description |
|---|---|---|
id | string | The ID of the resource. |
name | string | The name of the resource. |
slug | string | The slug of the resource as defined in the resource settings page. |
kind | string | The kind of the resource (mysql). |
database | string | The name of the database. |
dsn | string | The DSN of the server. |
host | string | The host of the server. |
password | string | The login password. |
port | string | The port of the server. |
sshHost | string | Optional SSH host for tunneling. |
sshPort | string | Optional SSH port for tunneling. |
sshPrivateKey | string | Optional SSH private key for tunneling. |
sshUsername | string | Optional SSH username for tunneling. |
tls | string | The TLS verification setting (false or skip-verify). |
username | string | The login username. |
PostgreSQL
PostgreSQL
For more information, see the PostgreSQL resource documentation.
javascriptCopied1{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}
| Field | Type | Description |
|---|---|---|
id | string | The ID of the resource. |
name | string | The name of the resource. |
slug | string | The slug of the resource as defined in the resource settings page. |
kind | string | The kind of the resource (postgres). |
database | string | The name of the database. |
dsn | string | The dsn of the server. |
host | string | The host of the server. |
password | string | The login password. |
port | string | The port of the server. |
sshHost | string | Optional SSH host for tunneling. |
sshPort | string | Optional SSH port for tunneling. |
sshPrivateKey | string | Optional SSH private key for tunneling. |
sshUsername | string | Optional SSH username for tunneling. |
sslMode | string | The SSL mode setting (disable or require). |
username | string | The login username. |
Redshift
Redshift
For more information, see the Redshift resource documentation.
javascriptCopied1{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}
| Field | Type | Description |
|---|---|---|
id | string | The ID of the resource. |
name | string | The name of the resource. |
slug | string | The slug of the resource as defined in the resource settings page. |
kind | string | The kind of the resource (redshift). |
database | string | The name of the database. |
dsn | string | The dsn of the server. |
host | string | The host of the server. |
password | string | The login password. |
port | string | The port of the server. |
sshHost | string | Optional SSH host for tunneling. |
sshPort | string | Optional SSH port for tunneling. |
sshPrivateKey | string | Optional SSH private key for tunneling. |
sshUsername | string | Optional SSH username for tunneling. |
sslMode | string | The SSL mode setting (disable or require). |
username | string | The login username. |
REST API
REST API
For more information, see the REST API resource documentation.
javascriptCopied1{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}
| Field | Type | Description |
|---|---|---|
id | string | The ID of the resource. |
name | string | The name of the resource. |
slug | string | The slug of the resource as defined in the resource settings page. |
kind | string | The kind of the resource (rest). |
auth | object | The REST auth configuration. Nullable. |
auth.headers | object | Any headers specific to the authentication method. |
auth.kind | string | The kind of auth configured for the REST resource (basic). |
auth.password | string | The password to use for basic authentication. |
auth.username | string | The username to use for basic authentication. |
baseURL | string | The base URL of the REST API. |
headers | object | Mapping of header name to value. |
secretHeaders | list | List of header names that contain sensitive information. |
SendGrid
SendGrid
For more information, see the SendGrid resource documentation.
javascriptCopied1{2"id": "res20220923z4ywfnglnxs",3"name": "SendGrid",4"slug": "send_grid",5"kind": "sendgrid",6"apiKey": "SG.1234567890"7}
| Field | Type | Description |
|---|---|---|
id | string | The ID of the resource. |
name | string | The name of the resource. |
slug | string | The slug of the resource as defined in the resource settings page. |
kind | string | The kind of the resource (sendgrid). |
apiKey | string | The SendGrid API key. |
SMTP
SMTP
For more information, see the SMTP resource documentation.
javascriptCopied1{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}
| Field | Type | Description |
|---|---|---|
id | string | The ID of the resource. |
name | string | The name of the resource. |
slug | string | The slug of the resource as defined in the resource settings page. |
kind | string | The kind of the resource (smtp). |
auth | object | The SMTP auth configuration. |
auth.kind | string | The kind of auth configured for the REST resource (plain or crammd5 or login). |
auth.identity | string | The login identity. (Only set for plain auth.) |
auth.password | string | The password to use for basic authentication. |
auth.username | string | The username to use for basic authentication. |
auth.secret | string | The login password digest. (Only set for crammd5 auth.) |
hostname | string | The hostname of the SMTP server. |
port | string | The port of the SMTP server. |
Snowflake
Snowflake
For more information, see the Snowflake resource documentation.
javascriptCopied1{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}
| Field | Type | Description |
|---|---|---|
id | string | The ID of the resource. |
name | string | The name of the resource. |
slug | string | The slug of the resource as defined in the resource settings page. |
kind | string | The kind of the resource (snowflake). |
account | string | The Snowflake account. |
database | string | The name of the database. |
dsn | string | The dsn of the server. |
password | string | The login password. |
role | string | The role configured for the Snowflake resource. |
schema | string | The name of the schema. |
username | string | The login username. |
warehouse | string | The virtual warehouse name. |