Skip to content

Commit d166e0f

Browse files
committed
feat(core,webapp): support isSecret on environment variable imports
The env var import API and envvars.import now accept an optional isSecret flag to create the imported variables as secret (redacted) environment variables. When omitted, variables default to non-secret, preserving existing CLI deploy and dashboard import behavior.
1 parent 4c4ed22 commit d166e0f

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.import` 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.import("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)