0

List deploys

by
Published Oct 17, 2025

List deploys matching the provided filters. If no filters are provided, all deploys for the service are returned.

Script render Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Render = {
3
	apiKey: string
4
}
5
/**
6
 * List deploys
7
 * List deploys matching the provided filters. If no filters are provided, all deploys for the service are returned.
8

9
 */
10
export async function main(
11
	auth: Render,
12
	serviceId: string,
13
	status: string | undefined,
14
	createdBefore: string | undefined,
15
	createdAfter: string | undefined,
16
	updatedBefore: string | undefined,
17
	updatedAfter: string | undefined,
18
	finishedBefore: string | undefined,
19
	finishedAfter: string | undefined,
20
	cursor: string | undefined,
21
	limit: string | undefined
22
) {
23
	const url = new URL(`https://api.render.com/v1/services/${serviceId}/deploys`)
24
	for (const [k, v] of [
25
		['status', status],
26
		['createdBefore', createdBefore],
27
		['createdAfter', createdAfter],
28
		['updatedBefore', updatedBefore],
29
		['updatedAfter', updatedAfter],
30
		['finishedBefore', finishedBefore],
31
		['finishedAfter', finishedAfter],
32
		['cursor', cursor],
33
		['limit', limit]
34
	]) {
35
		if (v !== undefined && v !== '' && k !== undefined) {
36
			url.searchParams.append(k, v)
37
		}
38
	}
39
	const response = await fetch(url, {
40
		method: 'GET',
41
		headers: {
42
			Authorization: 'Bearer ' + auth.apiKey
43
		},
44
		body: undefined
45
	})
46
	if (!response.ok) {
47
		const text = await response.text()
48
		throw new Error(`${response.status} ${text}`)
49
	}
50
	return await response.json()
51
}
52