Skip to content

Commit 4b78d7e

Browse files
authored
feat(core,webapp): support isSecret on environment variable imports (#3809)
## Summary The environment variables import API now accepts an optional `isSecret` flag, so imported variables can be created as secret (redacted) environment variables instead of plaintext. When the flag is omitted, variables default to non-secret, preserving existing behavior for CLI deploys and dashboard imports. This is useful for tools that push secrets into Trigger.dev (for example, syncing from a secrets manager) and want them stored as secrets rather than plain environment variables. It's available through `envvars.import` in the SDK and the `POST /api/v1/projects/{projectRef}/envvars/{slug}/import` endpoint, and is honored for both regular and preview-branch environments. ```ts await envvars.import("proj_1234", "prod", { variables: { STRIPE_SECRET_KEY: "sk_live_..." }, isSecret: true, }); ```
1 parent 005d7e0 commit 4b78d7e

4 files changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
"@trigger.dev/core": patch
3+
---
4+
5+
`envvars.upload` now accepts an optional `isSecret` flag, letting you create the imported variables as secret (redacted) environment variables. When omitted, variables default to non-secret.
6+
7+
```ts
8+
await envvars.upload("proj_1234", "prod", {
9+
variables: { STRIPE_SECRET_KEY: "sk_live_..." },
10+
isSecret: true,
11+
});
12+
```

apps/webapp/app/routes/api.v1.projects.$projectRef.envvars.$slug.import.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export async function action({ params, request }: ActionFunctionArgs) {
4040

4141
const result = await repository.create(environment.project.id, {
4242
override: typeof body.override === "boolean" ? body.override : false,
43+
isSecret: body.isSecret,
4344
environmentIds: [environment.id],
4445
// Pass parent environment ID so new variables can inherit isSecret from parent
4546
parentEnvironmentId: environment.parentEnvironmentId ?? undefined,
@@ -54,6 +55,7 @@ export async function action({ params, request }: ActionFunctionArgs) {
5455
if (environment.parentEnvironmentId && body.parentVariables) {
5556
const parentResult = await repository.create(environment.project.id, {
5657
override: typeof body.override === "boolean" ? body.override : false,
58+
isSecret: body.isSecret,
5759
environmentIds: [environment.parentEnvironmentId],
5860
variables: Object.entries(body.parentVariables).map(([key, value]) => ({
5961
key,

packages/core/src/v3/apiClient/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export interface ImportEnvironmentVariablesParams {
1414
*/
1515
variables: Record<string, string>;
1616
override?: boolean;
17+
/**
18+
* When `true`, the imported variables are created as secret (redacted) environment variables. Defaults to `false`.
19+
*/
20+
isSecret?: boolean;
1721
}
1822

1923
export interface CreateEnvironmentVariableParams {

packages/core/src/v3/schemas/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,8 @@ export const ImportEnvironmentVariablesRequestBody = z.object({
12151215
variables: z.record(z.string()),
12161216
parentVariables: z.record(z.string()).optional(),
12171217
override: z.boolean().optional(),
1218+
// When omitted, variables default to non-secret (the DB default is false).
1219+
isSecret: z.boolean().optional(),
12181220
source: z
12191221
.discriminatedUnion("type", [
12201222
z.object({ type: z.literal("user"), userId: z.string() }),

0 commit comments

Comments
 (0)