0

Get operation details

by
Published Apr 8, 2025

Retrieves details for the specified operation. An operation is an action performed on a Neon project resource. You can obtain a `project_id` by listing the projects for your Neon account. You can obtain a `operation_id` by listing operations for the project.

Script neondb Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Neondb = {
3
	apiKey: string
4
}
5
/**
6
 * Get operation details
7
 * Retrieves details for the specified operation.
8
An operation is an action performed on a Neon project resource.
9
You can obtain a `project_id` by listing the projects for your Neon account.
10
You can obtain a `operation_id` by listing operations for the project.
11

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

18
	const response = await fetch(url, {
19
		method: 'GET',
20
		headers: {
21
			Authorization: 'Bearer ' + auth.apiKey
22
		},
23
		body: undefined
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