0

List all External Connections

by
Published Apr 8, 2025

This endpoint returns a list of your External Connections inside the 'data' attribute of the response. External Connections are used by Telnyx customers to seamless configure SIP trunking integrations with Telnyx Partners, through External Voice Integrations in Mission Control Portal.

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * List all External Connections
7
 * This endpoint returns a list of your External Connections inside the 'data' attribute of the response. External Connections are used by Telnyx customers to seamless configure SIP trunking integrations with Telnyx Partners, through External Voice Integrations in Mission Control Portal.
8
 */
9
export async function main(
10
	auth: Telnyx,
11
	page_number_: string | undefined,
12
	page_size_: string | undefined,
13
	filter_connection_name__contains_: string | undefined,
14
	filter_external_sip_connection_: 'zoom' | 'operator_connect' | undefined,
15
	filter_id_: string | undefined,
16
	filter_created_at_: string | undefined,
17
	filter_phone_number__contains_: string | undefined
18
) {
19
	const url = new URL(`https://api.telnyx.com/v2/external_connections`)
20
	for (const [k, v] of [
21
		['page[number]', page_number_],
22
		['page[size]', page_size_],
23
		['filter[connection_name][contains]', filter_connection_name__contains_],
24
		['filter[external_sip_connection]', filter_external_sip_connection_],
25
		['filter[id]', filter_id_],
26
		['filter[created_at]', filter_created_at_],
27
		['filter[phone_number][contains]', filter_phone_number__contains_]
28
	]) {
29
		if (v !== undefined && v !== '' && k !== undefined) {
30
			url.searchParams.append(k, v)
31
		}
32
	}
33
	const response = await fetch(url, {
34
		method: 'GET',
35
		headers: {
36
			Authorization: 'Bearer ' + auth.apiKey
37
		},
38
		body: undefined
39
	})
40
	if (!response.ok) {
41
		const text = await response.text()
42
		throw new Error(`${response.status} ${text}`)
43
	}
44
	return await response.json()
45
}
46