1 | |
2 | type Telnyx = { |
3 | apiKey: string |
4 | } |
5 | |
6 | * Submit Campaign |
7 | * Before creating a campaign, use the [Qualify By Usecase endpoint](https://developers. |
8 | */ |
9 | export async function main( |
10 | auth: Telnyx, |
11 | body: { |
12 | affiliateMarketing?: false | true |
13 | ageGated?: false | true |
14 | autoRenewal?: false | true |
15 | brandId: string |
16 | description: string |
17 | directLending?: false | true |
18 | embeddedLink?: false | true |
19 | embeddedPhone?: false | true |
20 | helpKeywords?: string |
21 | helpMessage?: string |
22 | messageFlow?: string |
23 | mnoIds?: number[] |
24 | numberPool?: false | true |
25 | optinKeywords?: string |
26 | optinMessage?: string |
27 | optoutKeywords?: string |
28 | optoutMessage?: string |
29 | referenceId?: string |
30 | resellerId?: string |
31 | sample1?: string |
32 | sample2?: string |
33 | sample3?: string |
34 | sample4?: string |
35 | sample5?: string |
36 | subUsecases?: string[] |
37 | subscriberHelp?: false | true |
38 | subscriberOptin?: false | true |
39 | subscriberOptout?: false | true |
40 | tag?: string[] |
41 | termsAndConditions?: false | true |
42 | privacyPolicyLink?: string |
43 | termsAndConditionsLink?: string |
44 | embeddedLinkSample?: string |
45 | usecase: string |
46 | webhookURL?: string |
47 | webhookFailoverURL?: string |
48 | } |
49 | ) { |
50 | const url = new URL(`https://api.telnyx.com/v2/campaignBuilder`) |
51 |
|
52 | const response = await fetch(url, { |
53 | method: 'POST', |
54 | headers: { |
55 | 'Content-Type': 'application/json', |
56 | Authorization: 'Bearer ' + auth.apiKey |
57 | }, |
58 | body: JSON.stringify(body) |
59 | }) |
60 | if (!response.ok) { |
61 | const text = await response.text() |
62 | throw new Error(`${response.status} ${text}`) |
63 | } |
64 | return await response.json() |
65 | } |
66 |
|