0

Deletes a SIM card

by
Published Apr 8, 2025

The SIM card will be decommissioned, removed from your account and you will stop being charged.The SIM card won't be able to connect to the network after the deletion is completed, thus making it impossible to consume data. Transitioning to the disabled state may take a period of time. Until the transition is completed, the SIM card status will be disabling disabling.In order to re-enable the SIM card, you will need to re-register it.

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * Deletes a SIM card
7
 * The SIM card will be decommissioned, removed from your account and you will stop being charged.The SIM card won't be able to connect to the network after the deletion is completed, thus making it impossible to consume data.
8
Transitioning to the disabled state may take a period of time.
9
Until the transition is completed, the SIM card status will be disabling disabling.In order to re-enable the SIM card, you will need to re-register it.
10
 */
11
export async function main(auth: Telnyx, id: string) {
12
	const url = new URL(`https://api.telnyx.com/v2/sim_cards/${id}`)
13

14
	const response = await fetch(url, {
15
		method: 'DELETE',
16
		headers: {
17
			Authorization: 'Bearer ' + auth.apiKey
18
		},
19
		body: undefined
20
	})
21
	if (!response.ok) {
22
		const text = await response.text()
23
		throw new Error(`${response.status} ${text}`)
24
	}
25
	return await response.json()
26
}
27