0

Update a project environment

by
Published Oct 17, 2025

Update the visibility for a project environment.

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Update a project environment
4
 * Update the visibility for a project environment.
5
 */
6
export async function main(
7
	auth: RT.Sentry,
8
	project_id_or_slug: string,
9
	environment: string,
10
	body: Body
11
) {
12
	const url = new URL(
13
		`https://${auth.region}.sentry.io/api/0/projects/${auth.organizationSlug}/${project_id_or_slug}/environments/${environment}/`
14
	)
15

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

31
/* eslint-disable */
32
/**
33
 * This file was automatically generated by json-schema-to-typescript.
34
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
35
 * and run json-schema-to-typescript to regenerate this file.
36
 */
37

38
export interface Body {
39
	/**
40
	 * Specify `true` to make the environment visible or `false` to make the environment hidden.
41
	 */
42
	isHidden: boolean
43
	[k: string]: unknown
44
}
45