0

Configures tunnel services

by
Published Oct 17, 2025

This endpoint reads the request body and creates/updates/delete the services that the tunnel connects to.

Script zuplo Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zuplo = {
3
	apiKey: string
4
}
5
/**
6
 * Configures tunnel services
7
 * This endpoint reads the request body and creates/updates/delete the services that the tunnel connects to.
8
 */
9
export async function main(
10
	auth: Zuplo,
11
	accountName: string,
12
	tunnelId: string,
13
	body: {
14
		version: number
15
		services: {
16
			name: string
17
			endpoint: string
18
			configurations: {
19
				project: string
20
				accessibleBy: 'working-copy' | 'preview' | 'production'[]
21
			}[]
22
		}[]
23
	}
24
) {
25
	const url = new URL(
26
		`https://dev.zuplo.com/v1/accounts/${accountName}/tunnels/${tunnelId}/services-configuration`
27
	)
28

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