0

Update a Fax Application

by
Published Apr 8, 2025

Updates settings of an existing Fax Application based on the parameters of the request.

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 a Fax Application
7
 * Updates settings of an existing Fax Application based on the parameters of the request.
8
 */
9
export async function main(
10
	auth: Telnyx,
11
	id: string,
12
	body: {
13
		application_name: string
14
		active?: false | true
15
		anchorsite_override?:
16
			| 'Latency'
17
			| 'Chicago, IL'
18
			| 'Ashburn, VA'
19
			| 'San Jose, CA'
20
			| 'Sydney, Australia'
21
			| 'Amsterdam, Netherlands'
22
			| 'London, UK'
23
			| 'Toronto, Canada'
24
			| 'Vancouver, Canada'
25
			| 'Frankfurt, Germany'
26
		webhook_event_url: string
27
		webhook_event_failover_url?: string
28
		webhook_timeout_secs?: number
29
		fax_email_recipient?: string
30
		inbound?: {
31
			channel_limit?: number
32
			sip_subdomain?: string
33
			sip_subdomain_receive_settings?: 'only_my_connections' | 'from_anyone'
34
		}
35
		outbound?: { channel_limit?: number; outbound_voice_profile_id?: string }
36
	}
37
) {
38
	const url = new URL(`https://api.telnyx.com/v2/fax_applications/${id}`)
39

40
	const response = await fetch(url, {
41
		method: 'PATCH',
42
		headers: {
43
			'Content-Type': 'application/json',
44
			Authorization: 'Bearer ' + auth.apiKey
45
		},
46
		body: JSON.stringify(body)
47
	})
48
	if (!response.ok) {
49
		const text = await response.text()
50
		throw new Error(`${response.status} ${text}`)
51
	}
52
	return await response.json()
53
}
54