0

Edit an environment variable belonging to the job

by
Published Oct 17, 2025

- You can't edit a BUILT_IN variable - For an override, you can't edit the key - For an alias, you can't edit the value - An override can only have a scope lower to the variable it is overriding (hierarchy is BUILT_IN > PROJECT > ENVIRONMENT > CONTAINER)

Script qovery Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Edit an environment variable belonging to the job
4
 * - You can't edit a BUILT_IN variable
5
- For an override, you can't edit the key
6
- For an alias, you can't edit the value
7
- An override can only have a scope lower to the variable it is overriding (hierarchy is BUILT_IN > PROJECT > ENVIRONMENT > CONTAINER)
8

9
 */
10
export async function main(
11
	auth: RT.Qovery,
12
	jobId: string,
13
	environmentVariableId: string,
14
	body: Body
15
) {
16
	const url = new URL(
17
		`https://api.qovery.com/job/${jobId}/environmentVariable/${environmentVariableId}`
18
	)
19

20
	const response = await fetch(url, {
21
		method: 'PUT',
22
		headers: {
23
			'Content-Type': 'application/json',
24
			Authorization: 'Token ' + auth.apiKey
25
		},
26
		body: JSON.stringify(body)
27
	})
28
	if (!response.ok) {
29
		const text = await response.text()
30
		throw new Error(`${response.status} ${text}`)
31
	}
32
	return await response.json()
33
}
34

35
/* eslint-disable */
36
/**
37
 * This file was automatically generated by json-schema-to-typescript.
38
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
39
 * and run json-schema-to-typescript to regenerate this file.
40
 */
41

42
export interface Body {
43
	/**
44
	 * key is case sensitive
45
	 */
46
	key: string
47
	/**
48
	 * value of the env variable.
49
	 */
50
	value?: string
51
	mount_path?: string
52
	/**
53
	 * optional variable description (255 characters maximum)
54
	 */
55
	description?: string
56
	enable_interpolation_in_file?: boolean
57
	[k: string]: unknown
58
}
59