← Public packages
@cameronpak/box
Full Box Public API v1 client: lifecycle, prompts, files, commands, snapshots, environments, webhooks, desktop, hosting, and account.
src/delete-environment-var.ts
26 lines · 890 B · TypeScriptimport { assertEnvironmentId, boxRequest, failure, type Result } from './client.ts'
import type { EnvironmentMutationOutput } from './set-environment-var.ts'
export type DeleteEnvironmentVarInput = {
environmentId: string
key: string
}
/** Remove a single environment variable. Mints a new immutable version. */
export default async function deleteEnvironmentVar(
input: DeleteEnvironmentVarInput,
): Promise<Result<EnvironmentMutationOutput>> {
const invalid = assertEnvironmentId(input?.environmentId)
if (invalid) return failure<EnvironmentMutationOutput>(invalid)
if (!input?.key) {
return failure<EnvironmentMutationOutput>({
code: 'invalid_env_key',
message: 'key is required.',
status: 400,
})
}
return boxRequest<EnvironmentMutationOutput>({
path: '/environments/' + input.environmentId + '/vars/' + encodeURIComponent(input.key),
method: 'DELETE',
})
}