0

Edit application

by
Published Oct 17, 2025

- To edit the application you must have the admin permission. - For port edition, if you provide a port id, we will update the corresponding port. If you don't we will create a new one. If you remove a port from the payload, we will delete it. - For storage edition, if you provide a storage id, we will update the corresponding storage. If you don't we will create a new one. If you remove a storage from the payload, we will delete it.

Script qovery Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Edit application
4
 * - To edit the application you must have the admin permission.
5
- For port edition, if you provide a port id, we will update the corresponding port. If you don't we will create a new one. If you remove a port from the payload, we will delete it.
6
- For storage edition, if you provide a storage id, we will update the corresponding storage. If you don't we will create a new one. If you remove a storage from the payload, we will delete it.
7

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

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