Edits history of script submission #13041 for ' Create a Verify profile (telnyx)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Telnyx = {
    	apiKey: string
    }
    /**
     * Create a Verify profile
     * Creates a new Verify profile to associate verifications with.
     */
    export async function main(
    	auth: Telnyx,
    	body: {
    		name: string
    		webhook_url?: string
    		webhook_failover_url?: string
    		sms?: {
    			messaging_template_id?: string
    			app_name?: string
    			alpha_sender?: string
    			code_length?: number
    			whitelisted_destinations: string[]
    			default_verification_timeout_secs?: number
    		}
    		call?: {
    			messaging_template_id?: string
    			app_name?: string
    			code_length?: number
    			whitelisted_destinations?: string[]
    			default_verification_timeout_secs?: number
    		}
    		flashcall?: {
    			whitelisted_destinations?: string[]
    			default_verification_timeout_secs?: number
    		}
    		language?: string
    	}
    ) {
    	const url = new URL(`https://api.telnyx.com/v2/verify_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