0

Register SIM cards

by
Published Apr 8, 2025

Register the SIM cards associated with the provided registration codes to the current user's account. If sim_card_group_id is provided, the SIM cards will be associated with that group. Otherwise, the default group for the current user will be used.

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * Register SIM cards
7
 * Register the SIM cards associated with the provided registration codes to the current user's account.
8
If sim_card_group_id is provided, the SIM cards will be associated with that group. Otherwise, the default group for the current user will be used.
9

10
 */
11
export async function main(
12
	auth: Telnyx,
13
	body: {
14
		sim_card_group_id?: string
15
		tags?: string[]
16
		registration_codes: string[]
17
		status?: 'enabled' | 'disabled' | 'standby'
18
	}
19
) {
20
	const url = new URL(`https://api.telnyx.com/v2/actions/register/sim_cards`)
21

22
	const response = await fetch(url, {
23
		method: 'POST',
24
		headers: {
25
			'Content-Type': 'application/json',
26
			Authorization: 'Bearer ' + auth.apiKey
27
		},
28
		body: JSON.stringify(body)
29
	})
30
	if (!response.ok) {
31
		const text = await response.text()
32
		throw new Error(`${response.status} ${text}`)
33
	}
34
	return await response.json()
35
}
36