Edits history of script submission #13460 for ' Request setting a SIM card to standby (telnyx)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Telnyx = {
    	apiKey: string
    }
    /**
     * Request setting a SIM card to standby
     * The SIM card will be able to connect to the network once the process to set it to standby has been completed, thus making it possible to consume data.
     */
    export async function main(auth: Telnyx, id: string) {
    	const url = new URL(`https://api.telnyx.com/v2/sim_cards/${id}/actions/set_standby`)
    
    	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