//native
type Telnyx = {
apiKey: string
}
/**
* Send the verification codes
* Send the verification code for all porting phone numbers.
*/
export async function main(
auth: Telnyx,
id: string,
body: { phone_numbers?: string[]; verification_method?: 'sms' | 'call' }
) {
const url = new URL(`https://api.telnyx.com/v2/porting_orders/${id}/verification_codes/send`)
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.text()
}
Submitted by hugo697 428 days ago