0

Conference recording start

by
Published Apr 8, 2025

Start recording the conference. Recording will stop on conference end, or via the Stop Recording command. **Expected Webhooks (see [callback schema](https://developers.telnyx.com/api/call-control/start-conference-recording#callbacks) below):** - `conference.recording.saved`

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * Conference recording start
7
 * Start recording the conference. Recording will stop on conference end, or via the Stop Recording command.
8

9
**Expected Webhooks (see [callback schema](https://developers.telnyx.com/api/call-control/start-conference-recording#callbacks) below):**
10

11
- `conference.recording.saved`
12
 */
13
export async function main(
14
	auth: Telnyx,
15
	id: string,
16
	body: {
17
		format: 'wav' | 'mp3'
18
		command_id?: string
19
		play_beep?: false | true
20
		trim?: 'trim-silence'
21
		custom_file_name?: string
22
	}
23
) {
24
	const url = new URL(`https://api.telnyx.com/v2/conferences/${id}/actions/record_start`)
25

26
	const response = await fetch(url, {
27
		method: 'POST',
28
		headers: {
29
			'Content-Type': 'application/json',
30
			Authorization: 'Bearer ' + auth.apiKey
31
		},
32
		body: JSON.stringify(body)
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