0

Suspend a compute endpoint

by
Published Apr 8, 2025

Suspend the specified compute endpoint You can obtain a `project_id` by listing the projects for your Neon account. You can obtain an `endpoint_id` by listing your project's compute endpoints. An `endpoint_id` has an `ep-` prefix. For information about compute endpoints, see [Manage computes](https://neon.tech/docs/manage/endpoints/).

Script neondb Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Neondb = {
3
	apiKey: string
4
}
5
/**
6
 * Suspend a compute endpoint
7
 * Suspend the specified compute endpoint
8
You can obtain a `project_id` by listing the projects for your Neon account.
9
You can obtain an `endpoint_id` by listing your project's compute endpoints.
10
An `endpoint_id` has an `ep-` prefix.
11
For information about compute endpoints, see [Manage computes](https://neon.tech/docs/manage/endpoints/).
12

13
 */
14
export async function main(auth: Neondb, project_id: string, endpoint_id: string) {
15
	const url = new URL(
16
		`https://console.neon.tech/api/v2/projects/${project_id}/endpoints/${endpoint_id}/suspend`
17
	)
18

19
	const response = await fetch(url, {
20
		method: 'POST',
21
		headers: {
22
			Authorization: 'Bearer ' + auth.apiKey
23
		},
24
		body: undefined
25
	})
26
	if (!response.ok) {
27
		const text = await response.text()
28
		throw new Error(`${response.status} ${text}`)
29
	}
30
	return await response.json()
31
}
32