//native
type Telnyx = {
apiKey: string
}
/**
* Deletes all numbers associated with a phone number block
* Creates a new background job to delete all the phone numbers associated with the given block. We will only consider the phone number block as deleted after all phone numbers associated with it are removed, so multiple executions of this job may be necessary in case some of the phone numbers present errors during the deletion process.
*/
export async function main(auth: Telnyx, body: { phone_number_block_id: string }) {
const url = new URL(
`https://api.telnyx.com/v2/phone_number_blocks/jobs/delete_phone_number_block`
)
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