//native
type Telnyx = {
apiKey: string
}
/**
* Leave a conference
* Removes a call leg from a conference and moves it back to parked state.
**Expected Webhooks (see [callback schema](https://developers.telnyx.com/api/call-control/leave-conference#callbacks) below):**
- `conference.participant.left`
*/
export async function main(
auth: Telnyx,
id: string,
body: {
call_control_id: string
command_id?: string
beep_enabled?: 'always' | 'never' | 'on_enter' | 'on_exit'
}
) {
const url = new URL(`https://api.telnyx.com/v2/conferences/${id}/actions/leave`)
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