0

Create environment group

by
Published Oct 17, 2025

Create a new environment group.

Script render Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Render = {
3
	apiKey: string
4
}
5
/**
6
 * Create environment group
7
 * Create a new environment group.
8

9
 */
10
export async function main(
11
	auth: Render,
12
	body: {
13
		name: string
14
		ownerId: string
15
		envVars: { key: string; value: string } | { key: string; generateValue: false | true }[]
16
		secretFiles?: { name: string; content: string }[]
17
		serviceIds?: string[]
18
		environmentId?: string
19
	}
20
) {
21
	const url = new URL(`https://api.render.com/v1/env-groups`)
22

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