0

Create an application

by
Published Oct 17, 2025
Script qovery Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Create an application
4
 *
5
 */
6
export async function main(auth: RT.Qovery, environmentId: string, body: Body) {
7
	const url = new URL(`https://api.qovery.com/environment/${environmentId}/application`)
8

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

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

31
export type Body = {
32
	storage?: {
33
		id?: string
34
		type: 'FAST_SSD'
35
		/**
36
		 * unit is GB
37
		 * Minimum size is 4 GB
38
		 *
39
		 */
40
		size: number
41
		mount_point: string
42
		[k: string]: unknown
43
	}[]
44
	[k: string]: unknown
45
} & {
46
	ports?: {
47
		id?: string
48
		name?: string
49
		/**
50
		 * The listening port of your service.
51
		 */
52
		internal_port: number
53
		/**
54
		 * The exposed port for your service. This is optional. If not set a default port will be used.
55
		 */
56
		external_port?: number
57
		/**
58
		 * Expose the port to the world
59
		 */
60
		publicly_accessible: boolean
61
		/**
62
		 * is the default port to use for domain
63
		 */
64
		is_default?: boolean
65
		protocol?: 'HTTP' | 'GRPC' | 'TCP' | 'UDP'
66
		/**
67
		 * Indicate the path or regex that must match for traffic to be accepted on your service
68
		 * i.e: /api/ will only accept http calls that start with /api/
69
		 * Only valid for publicly_accessible HTTP or GRPC ports.
70
		 */
71
		public_path?: string
72
		/**
73
		 * Indicate the new path that will be used to reach your service after replacement
74
		 * i.e: public_path -> /(.*)  public_path_rewrite -> /api/$1 will append /api/ on all externaly requested url when reaching the service
75
		 * external/use url -> example.com/foobar  -> url seen by the service -> example.com/api/foobar
76
		 * Only valid for publicly_accessible HTTP or GRPC ports.
77
		 */
78
		public_path_rewrite?: string
79
		[k: string]: unknown
80
	}[]
81
	[k: string]: unknown
82
} & {
83
	/**
84
	 * name is case insensitive
85
	 */
86
	name: string
87
	/**
88
	 * give a description to this application
89
	 */
90
	description?: string
91
	git_repository: {
92
		/**
93
		 * application git repository URL
94
		 */
95
		url: string
96
		/**
97
		 * Name of the branch to use. This is optional
98
		 * If not specified, then the branch used is the `main` or `master` one
99
		 *
100
		 */
101
		branch?: string
102
		/**
103
		 * indicates the root path of the application.
104
		 */
105
		root_path?: string
106
		/**
107
		 * The git token id on Qovery side
108
		 */
109
		git_token_id?: string
110
		provider: 'BITBUCKET' | 'GITHUB' | 'GITLAB'
111
		[k: string]: unknown
112
	}
113
	/**
114
	 * `DOCKER` requires `dockerfile_path`
115
	 *
116
	 */
117
	build_mode?: 'DOCKER'
118
	/**
119
	 * The path of the associated Dockerfile. Only if you are using build_mode = DOCKER
120
	 */
121
	dockerfile_path?: string
122
	/**
123
	 * unit is millicores (m). 1000m = 1 cpu
124
	 */
125
	cpu?: number
126
	/**
127
	 * unit is MB. 1024 MB = 1GB
128
	 */
129
	memory?: number
130
	gpu?: number
131
	/**
132
	 * Minimum number of instances running. This resource auto-scale based on the CPU and Memory consumption.
133
	 * Note: 0 means that there is no application running.
134
	 *
135
	 */
136
	min_running_instances?: number
137
	/**
138
	 * Maximum number of instances running. This resource auto-scale based on the CPU and Memory consumption.
139
	 * Note: -1 means that there is no limit.
140
	 *
141
	 */
142
	max_running_instances?: number
143
	healthchecks: {
144
		readiness_probe?: {
145
			type?: {
146
				tcp?: {
147
					port?: number
148
					host?: string
149
					[k: string]: unknown
150
				}
151
				http?: {
152
					path?: string
153
					scheme?: string
154
					port?: number
155
					[k: string]: unknown
156
				}
157
				exec?: {
158
					command?: string[]
159
					[k: string]: unknown
160
				}
161
				grpc?: {
162
					service?: string
163
					port?: number
164
					[k: string]: unknown
165
				}
166
				[k: string]: unknown
167
			}
168
			initial_delay_seconds?: number
169
			period_seconds?: number
170
			timeout_seconds?: number
171
			success_threshold?: number
172
			failure_threshold?: number
173
			[k: string]: unknown
174
		}
175
		liveness_probe?: {
176
			type?: {
177
				tcp?: {
178
					port?: number
179
					host?: string
180
					[k: string]: unknown
181
				}
182
				http?: {
183
					path?: string
184
					scheme?: string
185
					port?: number
186
					[k: string]: unknown
187
				}
188
				exec?: {
189
					command?: string[]
190
					[k: string]: unknown
191
				}
192
				grpc?: {
193
					service?: string
194
					port?: number
195
					[k: string]: unknown
196
				}
197
				[k: string]: unknown
198
			}
199
			initial_delay_seconds?: number
200
			period_seconds?: number
201
			timeout_seconds?: number
202
			success_threshold?: number
203
			failure_threshold?: number
204
			[k: string]: unknown
205
		}
206
		[k: string]: unknown
207
	}
208
	/**
209
	 * Specify if the environment preview option is activated or not for this application.
210
	 * If activated, a preview environment will be automatically cloned at each pull request.
211
	 * If not specified, it takes the value of the `auto_preview` property from the associated environment.
212
	 *
213
	 */
214
	auto_preview?: boolean
215
	arguments?: string[]
216
	/**
217
	 * optional entrypoint when launching container
218
	 */
219
	entrypoint?: string
220
	/**
221
	 * Specify if the application will be automatically updated after receiving a new commit.
222
	 */
223
	auto_deploy?: boolean
224
	annotations_groups?: {
225
		id: string
226
		[k: string]: unknown
227
	}[]
228
	labels_groups?: {
229
		id: string
230
		[k: string]: unknown
231
	}[]
232
	/**
233
	 * Icon URI representing the application.
234
	 */
235
	icon_uri?: string
236
	/**
237
	 * The target build stage in the Dockerfile to build
238
	 */
239
	docker_target_build_stage?: string
240
	[k: string]: unknown
241
}
242