0

Updates an existing outbound voice profile.

by
Published Apr 8, 2025

Updates an existing outbound voice profile.

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * Updates an existing outbound voice profile.
7
 * Updates an existing outbound voice profile.
8
 */
9
export async function main(
10
	auth: Telnyx,
11
	id: string,
12
	body: {
13
		name: string
14
		traffic_type?: 'conversational'
15
		service_plan?: 'global'
16
		concurrent_call_limit?: number
17
		enabled?: false | true
18
		tags?: string[]
19
		usage_payment_method?: 'rate-deck'
20
		whitelisted_destinations?: string[]
21
		max_destination_rate?: number
22
		daily_spend_limit?: string
23
		daily_spend_limit_enabled?: false | true
24
		call_recording?: {
25
			call_recording_type?: 'all' | 'none' | 'by_caller_phone_number'
26
			call_recording_caller_phone_numbers?: string[]
27
			call_recording_channels?: 'single' | 'dual'
28
			call_recording_format?: 'wav' | 'mp3'
29
		}
30
		billing_group_id?: string
31
	}
32
) {
33
	const url = new URL(`https://api.telnyx.com/v2/outbound_voice_profiles/${id}`)
34

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