0

Delete Verification Request

by
Published Apr 8, 2025

Delete a verification request A request may only be deleted when when the request is in the "rejected" state. * `HTTP 200`: request successfully deleted * `HTTP 400`: request exists but can't be deleted (i.e. not rejected) * `HTTP 404`: request unknown or already deleted

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * Delete Verification Request
7
 * Delete a verification request
8

9
A request may only be deleted when when the request is in the "rejected" state.
10

11
* `HTTP 200`: request successfully deleted
12
* `HTTP 400`: request exists but can't be deleted (i.e. not rejected)
13
* `HTTP 404`: request unknown or already deleted
14
 */
15
export async function main(auth: Telnyx, id: string) {
16
	const url = new URL(`https://api.telnyx.com/v2/messaging_tollfree/verification/requests/${id}`)
17

18
	const response = await fetch(url, {
19
		method: 'DELETE',
20
		headers: {
21
			Authorization: 'Bearer ' + auth.apiKey
22
		},
23
		body: undefined
24
	})
25
	if (!response.ok) {
26
		const text = await response.text()
27
		throw new Error(`${response.status} ${text}`)
28
	}
29
	return await response.json()
30
}
31