0

Create a LOA configuration

by
Published Apr 8, 2025

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

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