0

Create a variable

by
Published Oct 17, 2025

- Create a variable with the scope defined in the request body.

Script qovery Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Create a variable
4
 * - Create a variable with the scope defined in the request body.
5

6
 */
7
export async function main(auth: RT.Qovery, body: Body) {
8
	const url = new URL(`https://api.qovery.com/variable`)
9

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

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

32
export interface Body {
33
	/**
34
	 * the key of the environment variable
35
	 */
36
	key: string
37
	/**
38
	 * the value of the environment variable
39
	 */
40
	value: string
41
	/**
42
	 * the path where the file will be mounted (only if type =file)
43
	 */
44
	mount_path?: string
45
	/**
46
	 * if true, the variable will be considered as a secret and will not be accessible after its creation. Only your applications will be able to access its value at build and run time.
47
	 */
48
	is_secret: boolean
49
	variable_scope:
50
		| 'APPLICATION'
51
		| 'BUILT_IN'
52
		| 'ENVIRONMENT'
53
		| 'PROJECT'
54
		| 'CONTAINER'
55
		| 'JOB'
56
		| 'HELM'
57
		| 'TERRAFORM'
58
	/**
59
	 * based on the selected scope, it contains the ID of the service, environment or project where the variable is attached
60
	 */
61
	variable_parent_id: string
62
	/**
63
	 * optional variable description (255 characters maximum)
64
	 */
65
	description?: string
66
	enable_interpolation_in_file?: boolean
67
	[k: string]: unknown
68
}
69