0

Updates a variable

by
Published Oct 17, 2025

Update the value of a variable in a branch for a given project.

Script zuplo Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zuplo = {
3
	apiKey: string
4
}
5
/**
6
 * Updates a variable
7
 * Update the value of a variable in a branch for a given project.
8
 */
9
export async function main(
10
	auth: Zuplo,
11
	accountName: string,
12
	projectName: string,
13
	branchName: string,
14
	variableName: string,
15
	body: { value?: string }
16
) {
17
	const url = new URL(
18
		`https://dev.zuplo.com/v1/accounts/${accountName}/projects/${projectName}/branches/${branchName}/variables/${variableName}`
19
	)
20

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