//native
type Telnyx = {
apiKey: string
}
/**
* Submit Campaign
* Before creating a campaign, use the [Qualify By Usecase endpoint](https://developers.
*/
export async function main(
auth: Telnyx,
body: {
affiliateMarketing?: false | true
ageGated?: false | true
autoRenewal?: false | true
brandId: string
description: string
directLending?: false | true
embeddedLink?: false | true
embeddedPhone?: false | true
helpKeywords?: string
helpMessage?: string
messageFlow?: string
mnoIds?: number[]
numberPool?: false | true
optinKeywords?: string
optinMessage?: string
optoutKeywords?: string
optoutMessage?: string
referenceId?: string
resellerId?: string
sample1?: string
sample2?: string
sample3?: string
sample4?: string
sample5?: string
subUsecases?: string[]
subscriberHelp?: false | true
subscriberOptin?: false | true
subscriberOptout?: false | true
tag?: string[]
termsAndConditions?: false | true
privacyPolicyLink?: string
termsAndConditionsLink?: string
embeddedLinkSample?: string
usecase: string
webhookURL?: string
webhookFailoverURL?: string
}
) {
const url = new URL(`https://api.telnyx.com/v2/campaignBuilder`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 428 days ago