0

Update Verification Request

by
Published Apr 8, 2025

Update an existing tollfree verification request. This is particularly useful when there are pending customer actions to be taken.

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * Update Verification Request
7
 * Update an existing tollfree verification request. This is particularly useful when there are pending customer actions to be taken.
8
 */
9
export async function main(
10
	auth: Telnyx,
11
	id: string,
12
	body: {
13
		businessName: string
14
		corporateWebsite: string
15
		businessAddr1: string
16
		businessAddr2?: string
17
		businessCity: string
18
		businessState: string
19
		businessZip: string
20
		businessContactFirstName: string
21
		businessContactLastName: string
22
		businessContactEmail: string
23
		businessContactPhone: string
24
		messageVolume:
25
			| '10'
26
			| '100'
27
			| '1,000'
28
			| '10,000'
29
			| '100,000'
30
			| '250,000'
31
			| '500,000'
32
			| '750,000'
33
			| '1,000,000'
34
			| '5,000,000'
35
			| '10,000,000+'
36
		phoneNumbers: { phoneNumber: string }[]
37
		useCase:
38
			| '2FA'
39
			| 'App Notifications'
40
			| 'Appointments'
41
			| 'Auctions'
42
			| 'Auto Repair Services'
43
			| 'Bank Transfers'
44
			| 'Billing'
45
			| 'Booking Confirmations'
46
			| 'Business Updates'
47
			| 'COVID-19 Alerts'
48
			| 'Career Training'
49
			| 'Chatbot'
50
			| 'Conversational / Alerts'
51
			| 'Courier Services & Deliveries'
52
			| 'Emergency Alerts'
53
			| 'Events & Planning'
54
			| 'Financial Services'
55
			| 'Fraud Alerts'
56
			| 'Fundraising'
57
			| 'General Marketing'
58
			| 'General School Updates'
59
			| 'HR / Staffing'
60
			| 'Healthcare Alerts'
61
			| 'Housing Community Updates'
62
			| 'Insurance Services'
63
			| 'Job Dispatch'
64
			| 'Legal Services'
65
			| 'Mixed'
66
			| 'Motivational Reminders'
67
			| 'Notary Notifications'
68
			| 'Order Notifications'
69
			| 'Political'
70
			| 'Public Works'
71
			| 'Real Estate Services'
72
			| 'Religious Services'
73
			| 'Repair and Diagnostics Alerts'
74
			| 'Rewards Program'
75
			| 'Surveys'
76
			| 'System Alerts'
77
			| 'Voting Reminders'
78
			| 'Waitlist Alerts'
79
			| 'Webinar Reminders'
80
			| 'Workshop Alerts'
81
		useCaseSummary: string
82
		productionMessageContent: string
83
		optInWorkflow: string
84
		optInWorkflowImageURLs: { url: string }[]
85
		additionalInformation: string
86
		isvReseller: string
87
		webhookUrl?: string
88
	}
89
) {
90
	const url = new URL(`https://api.telnyx.com/v2/messaging_tollfree/verification/requests/${id}`)
91

92
	const response = await fetch(url, {
93
		method: 'PATCH',
94
		headers: {
95
			'Content-Type': 'application/json',
96
			Authorization: 'Bearer ' + auth.apiKey
97
		},
98
		body: JSON.stringify(body)
99
	})
100
	if (!response.ok) {
101
		const text = await response.text()
102
		throw new Error(`${response.status} ${text}`)
103
	}
104
	return await response.json()
105
}
106