1 | |
2 | type Telnyx = { |
3 | apiKey: string |
4 | } |
5 | |
6 | * Update a call control application |
7 | * Updates settings of an existing call control application. |
8 | */ |
9 | export async function main( |
10 | auth: Telnyx, |
11 | id: string, |
12 | body: { |
13 | application_name: string |
14 | webhook_event_url: string |
15 | active?: false | true |
16 | anchorsite_override?: '"Latency"' | '"Chicago, IL"' | '"Ashburn, VA"' | '"San Jose, CA"' |
17 | dtmf_type?: 'RFC 2833' | 'Inband' | 'SIP INFO' |
18 | first_command_timeout?: false | true |
19 | first_command_timeout_secs?: number |
20 | inbound?: { |
21 | channel_limit?: number |
22 | shaken_stir_enabled?: false | true |
23 | sip_subdomain?: string |
24 | sip_subdomain_receive_settings?: 'only_my_connections' | 'from_anyone' |
25 | } |
26 | outbound?: { channel_limit?: number; outbound_voice_profile_id?: string } |
27 | webhook_api_version?: '1' | '2' |
28 | webhook_event_failover_url?: string |
29 | webhook_timeout_secs?: number |
30 | } |
31 | ) { |
32 | const url = new URL(`https://api.telnyx.com/v2/call_control_applications/${id}`) |
33 |
|
34 | const response = await fetch(url, { |
35 | method: 'PATCH', |
36 | headers: { |
37 | 'Content-Type': 'application/json', |
38 | Authorization: 'Bearer ' + auth.apiKey |
39 | }, |
40 | body: JSON.stringify(body) |
41 | }) |
42 | if (!response.ok) { |
43 | const text = await response.text() |
44 | throw new Error(`${response.status} ${text}`) |
45 | } |
46 | return await response.json() |
47 | } |
48 |
|