0

Submit Verification Request

by
Published Apr 8, 2025

Submit a new tollfree verification request

Script telnyx Verified

The script

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

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