0

Update a conference participant

by
Published Apr 8, 2025

Updates a conference participant

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 participant
7
 * Updates a conference participant
8
 */
9
export async function main(
10
	auth: Telnyx,
11
	account_sid: string,
12
	conference_sid: string,
13
	call_sid: string,
14
	body: {
15
		Muted?: false | true
16
		Hold?: false | true
17
		HoldUrl?: string
18
		HoldMethod?: 'GET' | 'POST'
19
		AnnounceUrl?: string
20
		AnnounceMethod?: 'GET' | 'POST'
21
		WaitUrl?: string
22
		BeepOnExit?: false | true
23
		EndConferenceOnExit?: false | true
24
		Coaching?: false | true
25
		CallSidToCoach?: string
26
	}
27
) {
28
	const url = new URL(
29
		`https://api.telnyx.com/v2/texml/Accounts/${account_sid}/Conferences/${conference_sid}/Participants/${call_sid}`
30
	)
31

32
	const response = await fetch(url, {
33
		method: 'POST',
34
		headers: {
35
			'Content-Type': 'application/x-www-form-urlencoded',
36
			Authorization: 'Bearer ' + auth.apiKey
37
		},
38
		body: new URLSearchParams(body as Record<string, string>)
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