Edits history of script submission #13191 for ' Extend a number reservation (telnyx)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Telnyx = {
    	apiKey: string
    }
    /**
     * Extend a number reservation
     * Extends reservation expiry time on all phone numbers.
     */
    export async function main(auth: Telnyx, number_reservation_id: string) {
    	const url = new URL(
    		`https://api.telnyx.com/v2/number_reservations/${number_reservation_id}/actions/extend`
    	)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		headers: {
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 428 days ago