Edits history of script submission #13047 for ' Create a call control application (telnyx)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Telnyx = {
    	apiKey: string
    }
    /**
     * Create a call control application
     * Create a call control application.
     */
    export async function main(
    	auth: Telnyx,
    	body: {
    		application_name: string
    		webhook_event_url: string
    		active?: false | true
    		anchorsite_override?: '"Latency"' | '"Chicago, IL"' | '"Ashburn, VA"' | '"San Jose, CA"'
    		dtmf_type?: 'RFC 2833' | 'Inband' | 'SIP INFO'
    		first_command_timeout?: false | true
    		first_command_timeout_secs?: number
    		inbound?: {
    			channel_limit?: number
    			shaken_stir_enabled?: false | true
    			sip_subdomain?: string
    			sip_subdomain_receive_settings?: 'only_my_connections' | 'from_anyone'
    		}
    		outbound?: { channel_limit?: number; outbound_voice_profile_id?: string }
    		webhook_api_version?: '1' | '2'
    		webhook_event_failover_url?: string
    		webhook_timeout_secs?: number
    	}
    ) {
    	const url = new URL(`https://api.telnyx.com/v2/call_control_applications`)
    
    	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