0

Transfer projects from your personal account to a specified destination account

by
Published Apr 8, 2025

Transfers selected projects, identified by their IDs, from your personal account to a specified organization.

Script neondb Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Neondb = {
3
	apiKey: string
4
}
5
/**
6
 * Transfer projects from your personal account to a specified destination account
7
 * Transfers selected projects, identified by their IDs, from your personal account to a specified organization.
8

9
 */
10
export async function main(auth: Neondb, body: { org_id: string; project_ids: string[] }) {
11
	const url = new URL(`https://console.neon.tech/api/v2/users/me/projects/transfer`)
12

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