You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(sdk,core): add envvars.bulkDelete() and document the endpoint
Adds `envvars.bulkDelete(projectRef, slug, { keys, onlyWrittenBy?,
onlyShadowingParent? })`, resolving projectRef and slug from the task
context like the neighbouring envvars functions, plus the matching
`bulkDeleteEnvVars` API client method and param type. Documents the
endpoint in the management API reference and caps each key at 256
characters in the request schema.
Add a bulk delete endpoint for environment variables, `POST /api/v1/projects/:projectRef/envvars/:slug/bulk-delete`, which removes up to 1000 variables from one environment in a single call and can be limited to values last written by a given source or to branch values that shadow a value on the parent environment.
6
+
Delete many environment variables in one call with `envvars.bulkDelete()`, backed by the new `POST /api/v1/projects/:projectRef/envvars/:slug/bulk-delete` endpoint. You can limit the delete to values last written by a given source, or to branch values that shadow a value on the parent environment, and the response lists the keys that were deleted and the keys that were skipped.
7
+
8
+
```ts
9
+
import { envvars } from"@trigger.dev/sdk";
10
+
11
+
const result =awaitenvvars.bulkDelete("proj_yubjwjsfkxnylobaqvqz", "dev", {
description: Delete up to 1000 environment variables from a specific project and environment in one request. Keys that have no value in the environment, or that the filters exclude, are returned as skipped.
2196
+
requestBody:
2197
+
required: true
2198
+
content:
2199
+
application/json:
2200
+
schema:
2201
+
type: object
2202
+
properties:
2203
+
keys:
2204
+
type: array
2205
+
description: The names of the variables to delete from this environment.
2206
+
minItems: 1
2207
+
maxItems: 1000
2208
+
items:
2209
+
type: string
2210
+
minLength: 1
2211
+
maxLength: 256
2212
+
onlyWrittenBy:
2213
+
description: Only delete values that were last written by this source.
2214
+
oneOf:
2215
+
- type: object
2216
+
properties:
2217
+
type:
2218
+
type: string
2219
+
enum: ["user"]
2220
+
userId:
2221
+
type: string
2222
+
required: ["type", "userId"]
2223
+
- type: object
2224
+
properties:
2225
+
type:
2226
+
type: string
2227
+
enum: ["integration"]
2228
+
integration:
2229
+
type: string
2230
+
required: ["type", "integration"]
2231
+
onlyShadowingParent:
2232
+
type: boolean
2233
+
description: On a preview branch, only delete values whose key also has a value on the parent environment, so the branch falls back to the shared value.
2234
+
default: false
2235
+
required: ["keys"]
2236
+
responses:
2237
+
"200":
2238
+
description: The request completed. Each requested key appears in either `deleted` or `skipped`.
2239
+
content:
2240
+
application/json:
2241
+
schema:
2242
+
type: object
2243
+
properties:
2244
+
deleted:
2245
+
type: array
2246
+
description: Keys whose value was removed from the environment.
2247
+
items:
2248
+
type: string
2249
+
skipped:
2250
+
type: array
2251
+
description: Keys that were left untouched, because the environment had no value for them or a filter excluded them.
2252
+
items:
2253
+
type: string
2254
+
required: ["deleted", "skipped"]
2255
+
"400":
2256
+
description: Invalid request parameters or body
2257
+
content:
2258
+
application/json:
2259
+
schema:
2260
+
"$ref": "#/components/schemas/ErrorResponse"
2261
+
"401":
2262
+
description: Unauthorized request
2263
+
content:
2264
+
application/json:
2265
+
schema:
2266
+
"$ref": "#/components/schemas/ErrorResponse"
2267
+
"404":
2268
+
description: Resource not found
2269
+
content:
2270
+
application/json:
2271
+
schema:
2272
+
"$ref": "#/components/schemas/ErrorResponse"
2273
+
tags:
2274
+
- envvars
2275
+
security:
2276
+
- secretKey: []
2277
+
- personalAccessToken: []
2278
+
x-codeSamples:
2279
+
- lang: typescript
2280
+
label: Outside of a task
2281
+
source: |-
2282
+
import { envvars } from "@trigger.dev/sdk";
2283
+
2284
+
const result = await envvars.bulkDelete("proj_yubjwjsfkxnylobaqvqz", "dev", {
2285
+
keys: ["SLACK_API_KEY", "STRIPE_SECRET_KEY"],
2286
+
});
2287
+
2288
+
console.log(result.deleted, result.skipped);
2289
+
- lang: typescript
2290
+
label: Inside a task
2291
+
source: |-
2292
+
import { envvars, task } from "@trigger.dev/sdk";
2293
+
2294
+
export const myTask = task({
2295
+
id: "my-task",
2296
+
run: async () => {
2297
+
// projectRef and env are automatically inferred from the task context
0 commit comments