//native
type Telnyx = {
apiKey: string
}
/**
* Create conference
* Create a conference from an existing call leg using a `call_control_id` and a conference name.
*/
export async function main(
auth: Telnyx,
body: {
call_control_id: string
name: string
beep_enabled?: 'always' | 'never' | 'on_enter' | 'on_exit'
client_state?: string
comfort_noise?: false | true
command_id?: string
duration_minutes?: number
hold_audio_url?: string
hold_media_name?: string
max_participants?: number
start_conference_on_create?: false | true
}
) {
const url = new URL(`https://api.telnyx.com/v2/conferences`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 428 days ago