0

Create a Global IP health check

by
Published Apr 8, 2025

Create a Global IP health check.

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * Create a Global IP health check
7
 * Create a Global IP health check.
8
 */
9
export async function main(
10
	auth: Telnyx,
11
	body: {
12
		id?: string
13
		record_type?: string
14
		created_at?: string
15
		updated_at?: string
16
	} & {
17
		record_type?: string
18
		health_check_type?: string
19
		health_check_params?: {}
20
		global_ip_id?: string
21
	}
22
) {
23
	const url = new URL(`https://api.telnyx.com/v2/global_ip_health_checks`)
24

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