0

Update recording on a call

by
Published Apr 8, 2025

Updates recording resource for particular call.

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 recording on a call
7
 * Updates recording resource for particular call.
8
 */
9
export async function main(
10
	auth: Telnyx,
11
	account_sid: string,
12
	call_sid: string,
13
	recording_sid: string,
14
	body: { Status?: 'in-progress' | 'paused' | 'stopped' }
15
) {
16
	const url = new URL(
17
		`https://api.telnyx.com/v2/texml/Accounts/${account_sid}/Calls/${call_sid}/Recordings/${recording_sid}.json`
18
	)
19

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