1 | |
2 | type Telnyx = { |
3 | apiKey: string |
4 | } |
5 | |
6 | * Create an FQDN connection |
7 | * Creates a FQDN connection. |
8 | */ |
9 | export async function main( |
10 | auth: Telnyx, |
11 | body: { |
12 | active?: false | true |
13 | anchorsite_override?: |
14 | | 'Latency' |
15 | | 'Chicago, IL' |
16 | | 'Ashburn, VA' |
17 | | 'San Jose, CA' |
18 | | 'Sydney, Australia' |
19 | | 'Amsterdam, Netherlands' |
20 | | 'London, UK' |
21 | | 'Toronto, Canada' |
22 | | 'Vancouver, Canada' |
23 | | 'Frankfurt, Germany' |
24 | connection_name: string |
25 | transport_protocol?: 'UDP' | 'TCP' | 'TLS' |
26 | default_on_hold_comfort_noise_enabled?: false | true |
27 | dtmf_type?: 'RFC 2833' | 'Inband' | 'SIP INFO' |
28 | encode_contact_header_enabled?: false | true |
29 | encrypted_media?: 'SRTP' |
30 | microsoft_teams_sbc?: false | true |
31 | onnet_t38_passthrough_enabled?: false | true |
32 | ios_push_credential_id?: string |
33 | android_push_credential_id?: string |
34 | webhook_event_url?: string |
35 | webhook_event_failover_url?: string |
36 | webhook_api_version?: '1' | '2' |
37 | webhook_timeout_secs?: number |
38 | rtcp_settings?: { |
39 | port?: 'rtcp-mux' | 'rtp+1' |
40 | capture_enabled?: false | true |
41 | report_frequency_secs?: number |
42 | } |
43 | inbound?: { |
44 | ani_number_format?: '+E.164' | 'E.164' | '+E.164-national' | 'E.164-national' |
45 | dnis_number_format?: '+e164' | 'e164' | 'national' | 'sip_username' |
46 | codecs?: string[] |
47 | default_routing_method?: 'sequential' | 'round-robin' |
48 | default_primary_fqdn_id?: string |
49 | default_secondary_fqdn_id?: string |
50 | default_tertiary_fqdn_id?: string |
51 | channel_limit?: number |
52 | generate_ringback_tone?: false | true |
53 | isup_headers_enabled?: false | true |
54 | prack_enabled?: false | true |
55 | privacy_zone_enabled?: false | true |
56 | sip_compact_headers_enabled?: false | true |
57 | sip_region?: 'US' | 'Europe' | 'Australia' |
58 | sip_subdomain?: string |
59 | sip_subdomain_receive_settings?: 'only_my_connections' | 'from_anyone' |
60 | timeout_1xx_secs?: number |
61 | timeout_2xx_secs?: number |
62 | shaken_stir_enabled?: false | true |
63 | } |
64 | outbound?: { |
65 | ani_override?: string |
66 | ani_override_type?: 'always' | 'normal' | 'emergency' |
67 | call_parking_enabled?: false | true |
68 | channel_limit?: number |
69 | generate_ringback_tone?: false | true |
70 | instant_ringback_enabled?: false | true |
71 | ip_authentication_method?: 'credential-authentication' | 'ip-authentication' |
72 | ip_authentication_apiKey?: string |
73 | localization?: string |
74 | outbound_voice_profile_id?: string |
75 | t38_reinvite_source?: |
76 | | 'telnyx' |
77 | | 'customer' |
78 | | 'disabled' |
79 | | 'passthru' |
80 | | 'caller-passthru' |
81 | | 'callee-passthru' |
82 | tech_prefix?: string |
83 | encrypted_media?: 'SRTP' |
84 | timeout_1xx_secs?: number |
85 | timeout_2xx_secs?: number |
86 | } |
87 | } |
88 | ) { |
89 | const url = new URL(`https://api.telnyx.com/v2/fqdn_connections`) |
90 |
|
91 | const response = await fetch(url, { |
92 | method: 'POST', |
93 | headers: { |
94 | 'Content-Type': 'application/json', |
95 | Authorization: 'Bearer ' + auth.apiKey |
96 | }, |
97 | body: JSON.stringify(body) |
98 | }) |
99 | if (!response.ok) { |
100 | const text = await response.text() |
101 | throw new Error(`${response.status} ${text}`) |
102 | } |
103 | return await response.json() |
104 | } |
105 |
|