0

Update a LOA configuration

by
Published Apr 8, 2025

Update a specific LOA configuration.

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 LOA configuration
7
 * Update a specific LOA configuration.
8
 */
9
export async function main(
10
	auth: Telnyx,
11
	id: string,
12
	body: {
13
		name: string
14
		logo: { document_id: string }
15
		company_name: string
16
		address: {
17
			street_address: string
18
			extended_address?: string
19
			city?: string
20
			state?: string
21
			zip_code?: string
22
			country_code: string
23
		}
24
		contact: { email: string; phone_number: string }
25
	}
26
) {
27
	const url = new URL(`https://api.telnyx.com/v2/porting/loa_configurations/${id}`)
28

29
	const response = await fetch(url, {
30
		method: 'PATCH',
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