//native
type Telnyx = {
apiKey: string
}
/**
* Delete a document
* Delete a document.A document can only be deleted if it's not linked to a service. If it is linked to a service, it must be unlinked prior to deleting.
*/
export async function main(auth: Telnyx, id: string) {
const url = new URL(`https://api.telnyx.com/v2/documents/${id}`)
const response = await fetch(url, {
method: 'DELETE',
headers: {
Authorization: 'Bearer ' + auth.apiKey
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 428 days ago