//native
type Telnyx = {
apiKey: string
}
/**
* Request siprec session for a call
* Starts siprec session with specified parameters for call idientified by call_sid.
*/
export async function main(
auth: Telnyx,
account_sid: string,
call_sid: string,
body: {
ConnectorName?: string
Track?: 'both_tracks' | 'inbound_track' | 'outbound_track'
IncludeMetadataCustomHeaders?: false | true
Secure?: false | true
SessionTimeoutSecs?: number
StatusCallback?: string
StatusCallbackMethod?: 'GET' | 'POST'
}
) {
const url = new URL(
`https://api.telnyx.com/v2/texml/Accounts/${account_sid}/Calls/${call_sid}/Siprec.json`
)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: 'Bearer ' + auth.apiKey
},
body: new URLSearchParams(body as Record<string, string>)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 428 days ago