//native
type Telnyx = {
apiKey: string
}
/**
* Create a messaging profile
*
*/
export async function main(
auth: Telnyx,
body: {
name: string
whitelisted_destinations: string[]
enabled?: false | true
webhook_url?: string
webhook_failover_url?: string
webhook_api_version?: '1' | '2' | '2010-04-01'
number_pool_settings?: {
toll_free_weight: number
long_code_weight: number
skip_unhealthy: false | true
sticky_sender?: false | true
geomatch?: false | true
}
url_shortener_settings?: {
domain: string
prefix?: string
replace_blacklist_only?: false | true
send_webhooks?: false | true
}
alpha_sender?: string
}
) {
const url = new URL(`https://api.telnyx.com/v2/messaging_profiles`)
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