0

Request a SIM card enable

by
Published Apr 8, 2025

This API enables a SIM card, connecting it to the network and making it possible to consume data. To enable a SIM card, it must be associated with a SIM card group. The API will trigger an asynchronous operation called a SIM Card Action. Transitioning to the enabled state may take a period of time. The status of the SIM Card Action can be followed through the [List SIM Card Action](https://developersdev.telnyx.com/docs/api/v2/wireless/SIM-Card-Actions#ListSIMCardActions) API.

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * Request a SIM card enable
7
 * This API enables a SIM card, connecting it to the network and making it possible to consume data.
8
To enable a SIM card, it must be associated with a SIM card group.
9
The API will trigger an asynchronous operation called a SIM Card Action. Transitioning to the enabled state may take a period of time. The status of the SIM Card Action can be followed through the [List SIM Card Action](https://developersdev.telnyx.com/docs/api/v2/wireless/SIM-Card-Actions#ListSIMCardActions) API.
10

11
 */
12
export async function main(auth: Telnyx, id: string) {
13
	const url = new URL(`https://api.telnyx.com/v2/sim_cards/${id}/actions/enable`)
14

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