Edits history of script submission #13088 for ' Create an outbound voice profile (telnyx)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Telnyx = {
    	apiKey: string
    }
    /**
     * Create an outbound voice profile
     * Create an outbound voice profile.
     */
    export async function main(
    	auth: Telnyx,
    	body: {
    		name: string
    		traffic_type?: 'conversational'
    		service_plan?: 'global'
    		concurrent_call_limit?: number
    		enabled?: false | true
    		tags?: string[]
    		usage_payment_method?: 'rate-deck'
    		whitelisted_destinations?: string[]
    		max_destination_rate?: number
    		daily_spend_limit?: string
    		daily_spend_limit_enabled?: false | true
    		call_recording?: {
    			call_recording_type?: 'all' | 'none' | 'by_caller_phone_number'
    			call_recording_caller_phone_numbers?: string[]
    			call_recording_channels?: 'single' | 'dual'
    			call_recording_format?: 'wav' | 'mp3'
    		}
    		billing_group_id?: string
    	}
    ) {
    	const url = new URL(`https://api.telnyx.com/v2/outbound_voice_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