0

Update notification override

by
Published Oct 17, 2025

Update the notification override for the service with the provided ID.

Script render Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Render = {
3
	apiKey: string
4
}
5
/**
6
 * Update notification override
7
 * Update the notification override for the service with the provided ID.
8

9
 */
10
export async function main(
11
	auth: Render,
12
	serviceId: string,
13
	body: {
14
		previewNotificationsEnabled?: 'default' | 'false' | 'true'
15
		notificationsToSend?: 'default' | 'none' | 'failure' | 'all'
16
	}
17
) {
18
	const url = new URL(
19
		`https://api.render.com/v1/notification-settings/overrides/services/${serviceId}`
20
	)
21

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