0

Start a compute endpoint

by
Published Apr 8, 2025

Starts a compute endpoint. The compute endpoint is ready to use after the last operation in chain finishes successfully. 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
 * Start a compute endpoint
7
 * Starts a compute endpoint. The compute endpoint is ready to use
8
after the last operation in chain finishes successfully.
9

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

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

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