0

Updates a bucket

by
Published Oct 17, 2025

Updates a bucket, and returns the updated value.

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 bucket
7
 * Updates a bucket, and returns the updated value.
8
 */
9
export async function main(
10
	auth: Zuplo,
11
	accountName: string,
12
	bucketName: string,
13
	body: { description?: string; tags?: {} }
14
) {
15
	const url = new URL(`https://dev.zuplo.com/v1/accounts/${accountName}/key-buckets/${bucketName}`)
16

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