0

Update an FQDN connection

by
Published Apr 8, 2025

Updates settings of an existing FQDN connection.

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * Update an FQDN connection
7
 * Updates settings of an existing FQDN connection.
8
 */
9
export async function main(
10
	auth: Telnyx,
11
	id: string,
12
	body: {
13
		active?: false | true
14
		anchorsite_override?:
15
			| 'Latency'
16
			| 'Chicago, IL'
17
			| 'Ashburn, VA'
18
			| 'San Jose, CA'
19
			| 'Sydney, Australia'
20
			| 'Amsterdam, Netherlands'
21
			| 'London, UK'
22
			| 'Toronto, Canada'
23
			| 'Vancouver, Canada'
24
			| 'Frankfurt, Germany'
25
		connection_name?: string
26
		transport_protocol?: 'UDP' | 'TCP' | 'TLS'
27
		default_on_hold_comfort_noise_enabled?: false | true
28
		dtmf_type?: 'RFC 2833' | 'Inband' | 'SIP INFO'
29
		encode_contact_header_enabled?: false | true
30
		encrypted_media?: 'SRTP'
31
		onnet_t38_passthrough_enabled?: false | true
32
		ios_push_credential_id?: string
33
		android_push_credential_id?: string
34
		webhook_event_url?: string
35
		webhook_event_failover_url?: string
36
		webhook_api_version?: '1' | '2'
37
		webhook_timeout_secs?: number
38
		rtcp_settings?: {
39
			port?: 'rtcp-mux' | 'rtp+1'
40
			capture_enabled?: false | true
41
			report_frequency_secs?: number
42
		}
43
		inbound?: {
44
			ani_number_format?: '+E.164' | 'E.164' | '+E.164-national' | 'E.164-national'
45
			dnis_number_format?: '+e164' | 'e164' | 'national' | 'sip_username'
46
			codecs?: string[]
47
			default_routing_method?: 'sequential' | 'round-robin'
48
			default_primary_fqdn_id?: string
49
			default_secondary_fqdn_id?: string
50
			default_tertiary_fqdn_id?: string
51
			channel_limit?: number
52
			generate_ringback_tone?: false | true
53
			isup_headers_enabled?: false | true
54
			prack_enabled?: false | true
55
			privacy_zone_enabled?: false | true
56
			sip_compact_headers_enabled?: false | true
57
			sip_region?: 'US' | 'Europe' | 'Australia'
58
			sip_subdomain?: string
59
			sip_subdomain_receive_settings?: 'only_my_connections' | 'from_anyone'
60
			timeout_1xx_secs?: number
61
			timeout_2xx_secs?: number
62
			shaken_stir_enabled?: false | true
63
		}
64
		outbound?: {
65
			ani_override?: string
66
			ani_override_type?: 'always' | 'normal' | 'emergency'
67
			call_parking_enabled?: false | true
68
			channel_limit?: number
69
			generate_ringback_tone?: false | true
70
			instant_ringback_enabled?: false | true
71
			ip_authentication_method?: 'credential-authentication' | 'ip-authentication'
72
			ip_authentication_apiKey?: string
73
			localization?: string
74
			outbound_voice_profile_id?: string
75
			t38_reinvite_source?:
76
				| 'telnyx'
77
				| 'customer'
78
				| 'disabled'
79
				| 'passthru'
80
				| 'caller-passthru'
81
				| 'callee-passthru'
82
			tech_prefix?: string
83
			encrypted_media?: 'SRTP'
84
			timeout_1xx_secs?: number
85
			timeout_2xx_secs?: number
86
		}
87
	}
88
) {
89
	const url = new URL(`https://api.telnyx.com/v2/fqdn_connections/${id}`)
90

91
	const response = await fetch(url, {
92
		method: 'PATCH',
93
		headers: {
94
			'Content-Type': 'application/json',
95
			Authorization: 'Bearer ' + auth.apiKey
96
		},
97
		body: JSON.stringify(body)
98
	})
99
	if (!response.ok) {
100
		const text = await response.text()
101
		throw new Error(`${response.status} ${text}`)
102
	}
103
	return await response.json()
104
}
105