//native
type Telnyx = {
apiKey: string
}
/**
* Create a customer service record
* Create a new customer service record for the provided phone number.
*/
export async function main(
auth: Telnyx,
body: {
phone_number: string
webhook_url?: string
additional_data?: {
name?: string
authorized_person_name?: string
pin?: string
account_number?: string
customer_code?: string
address_line_1?: string
city?: string
state?: string
zip_code?: string
billing_phone_number?: string
}
}
) {
const url = new URL(`https://api.telnyx.com/v2/customer_service_records`)
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