0

Create Redis instance

by
Published Oct 17, 2025

Create a new Redis instance.

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 Redis instance
7
 * Create a new Redis instance.
8

9
 */
10
export async function main(
11
	auth: Render,
12
	body: {
13
		name: string
14
		ownerId: string
15
		plan: 'free' | 'starter' | 'standard' | 'pro' | 'pro_plus' | 'custom'
16
		region?: string
17
		environmentId?: string
18
		maxmemoryPolicy?:
19
			| 'noeviction'
20
			| 'allkeys_lfu'
21
			| 'allkeys_lru'
22
			| 'allkeys_random'
23
			| 'volatile_lfu'
24
			| 'volatile_lru'
25
			| 'volatile_random'
26
			| 'volatile_ttl'
27
		ipAllowList?: { cidrBlock: string; description: string }[]
28
	}
29
) {
30
	const url = new URL(`https://api.render.com/v1/redis`)
31

32
	const response = await fetch(url, {
33
		method: 'POST',
34
		headers: {
35
			'Content-Type': 'application/json',
36
			Authorization: 'Bearer ' + auth.apiKey
37
		},
38
		body: JSON.stringify(body)
39
	})
40
	if (!response.ok) {
41
		const text = await response.text()
42
		throw new Error(`${response.status} ${text}`)
43
	}
44
	return await response.json()
45
}
46