0

List all Fax Applications

by
Published Apr 8, 2025

This endpoint returns a list of your Fax Applications inside the 'data' attribute of the response. You can adjust which applications are listed by using filters. Fax Applications are used to configure how you send and receive faxes using the Programmable Fax API with Telnyx.

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 Fax Applications
7
 * This endpoint returns a list of your Fax Applications inside the 'data' attribute of the response. You can adjust which applications are listed by using filters. Fax Applications are used to configure how you send and receive faxes using the Programmable Fax API with Telnyx.
8
 */
9
export async function main(
10
	auth: Telnyx,
11
	page_number_: string | undefined,
12
	page_size_: string | undefined,
13
	filter_application_name__contains_: string | undefined,
14
	filter_outbound_voice_profile_id_: string | undefined,
15
	sort: 'created_at' | 'friendly_name' | 'active' | undefined
16
) {
17
	const url = new URL(`https://api.telnyx.com/v2/fax_applications`)
18
	for (const [k, v] of [
19
		['page[number]', page_number_],
20
		['page[size]', page_size_],
21
		['filter[application_name][contains]', filter_application_name__contains_],
22
		['filter[outbound_voice_profile_id]', filter_outbound_voice_profile_id_],
23
		['sort', sort]
24
	]) {
25
		if (v !== undefined && v !== '' && k !== undefined) {
26
			url.searchParams.append(k, v)
27
		}
28
	}
29
	const response = await fetch(url, {
30
		method: 'GET',
31
		headers: {
32
			Authorization: 'Bearer ' + auth.apiKey
33
		},
34
		body: undefined
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