Skip to main content

Overview

Returns all environment variables for a specific project and environment. When called from inside a task, the projectRef and env arguments can be omitted and are inferred automatically from the task’s runtime context. Supports both secret key and Personal Access Token authentication.

Endpoint

GET https://api.trigger.dev/api/v1/projects/{projectRef}/envvars/{env}

Path parameters

projectRef
string
required
The project reference (e.g. proj_yubjwjsfkxnylobaqvqz). Find it in your dashboard URL or project settings.
env
string
required
The target environment: dev, staging, prod, or preview.

Response

Returns an array of environment variable objects.
name
string
The name of the environment variable (e.g. SLACK_API_KEY).
value
string
The value of the environment variable.

Examples

import { envvars } from "@trigger.dev/sdk";

const variables = await envvars.list("proj_yubjwjsfkxnylobaqvqz", "prod");

for (const variable of variables) {
  console.log(`${variable.name} = ${variable.value}`);
}

Response example

[
  {
    "name": "SLACK_API_KEY",
    "value": "slack_123456"
  },
  {
    "name": "DATABASE_URL",
    "value": "postgres://user:pass@host:5432/db"
  }
]

Preview branches

When listing env vars for the preview environment and you want to target a specific branch, include the x-trigger-branch header (HTTP) or the previewBranch SDK option.
import { configure, envvars } from "@trigger.dev/sdk";

configure({
  secretKey: process.env["TRIGGER_ACCESS_TOKEN"],
  previewBranch: "feature-xyz",
});

const variables = await envvars.list("proj_yubjwjsfkxnylobaqvqz", "preview");

Build docs developers (and LLMs) love