0

List conferences

by
Published Apr 8, 2025

Lists conferences. Conferences are created on demand, and will expire after all participants have left the conference or after 4 hours regardless of the number of active participants. Conferences are listed in descending order by `expires_at`.

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 conferences
7
 * Lists conferences. Conferences are created on demand, and will expire after all participants have left the conference or after 4 hours regardless of the number of active participants. Conferences are listed in descending order by `expires_at`.
8
 */
9
export async function main(
10
	auth: Telnyx,
11
	filter_name_: string | undefined,
12
	filter_status_: 'init' | 'in_progress' | 'completed' | undefined,
13
	page_number_: string | undefined,
14
	page_size_: string | undefined
15
) {
16
	const url = new URL(`https://api.telnyx.com/v2/conferences`)
17
	for (const [k, v] of [
18
		['filter[name]', filter_name_],
19
		['filter[status]', filter_status_],
20
		['page[number]', page_number_],
21
		['page[size]', page_size_]
22
	]) {
23
		if (v !== undefined && v !== '' && k !== undefined) {
24
			url.searchParams.append(k, v)
25
		}
26
	}
27
	const response = await fetch(url, {
28
		method: 'GET',
29
		headers: {
30
			Authorization: 'Bearer ' + auth.apiKey
31
		},
32
		body: undefined
33
	})
34
	if (!response.ok) {
35
		const text = await response.text()
36
		throw new Error(`${response.status} ${text}`)
37
	}
38
	return await response.json()
39
}
40