0

Update a conference resource

by
Published Apr 8, 2025

Updates a conference resource.

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * Update a conference resource
7
 * Updates a conference resource.
8
 */
9
export async function main(
10
	auth: Telnyx,
11
	account_sid: string,
12
	conference_sid: string,
13
	body: {
14
		Status?: string
15
		AnnounceUrl?: string
16
		AnnounceMethod?: 'GET' | 'POST'
17
	}
18
) {
19
	const url = new URL(
20
		`https://api.telnyx.com/v2/texml/Accounts/${account_sid}/Conferences/${conference_sid}`
21
	)
22

23
	const response = await fetch(url, {
24
		method: 'POST',
25
		headers: {
26
			'Content-Type': 'application/x-www-form-urlencoded',
27
			Authorization: 'Bearer ' + auth.apiKey
28
		},
29
		body: new URLSearchParams(body as Record<string, string>)
30
	})
31
	if (!response.ok) {
32
		const text = await response.text()
33
		throw new Error(`${response.status} ${text}`)
34
	}
35
	return await response.json()
36
}
37