0

Add an environment variable to the project

by
Published Oct 17, 2025

- Add an environment variable to the project. - If the environment variable key already exists, then it will be replaced by the new one. - If the environment variable value points toward an existing environment variable key, it will be considered as an alias.

Script qovery Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Add an environment variable to the project
4
 * - Add an environment variable to the project.
5
  - If the environment variable key already exists, then it will be replaced by the new one.
6
  - If the environment variable value points toward an existing environment variable key, it will be considered as an alias.
7

8
 */
9
export async function main(auth: RT.Qovery, projectId: string, body: Body) {
10
	const url = new URL(`https://api.qovery.com/project/${projectId}/environmentVariable`)
11

12
	const response = await fetch(url, {
13
		method: 'POST',
14
		headers: {
15
			'Content-Type': 'application/json',
16
			Authorization: 'Token ' + auth.apiKey
17
		},
18
		body: JSON.stringify(body)
19
	})
20
	if (!response.ok) {
21
		const text = await response.text()
22
		throw new Error(`${response.status} ${text}`)
23
	}
24
	return await response.json()
25
}
26

27
/* eslint-disable */
28
/**
29
 * This file was automatically generated by json-schema-to-typescript.
30
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
31
 * and run json-schema-to-typescript to regenerate this file.
32
 */
33

34
export interface Body {
35
	/**
36
	 * key is case sensitive.
37
	 */
38
	key: string
39
	/**
40
	 * value of the env variable.
41
	 */
42
	value?: string
43
	/**
44
	 * should be set for file only. variable mount path makes variable a file (where file should be mounted).
45
	 */
46
	mount_path?: string
47
	/**
48
	 * optional variable description (255 characters maximum)
49
	 */
50
	description?: string
51
	enable_interpolation_in_file?: boolean
52
	[k: string]: unknown
53
}
54