Telnyx Iot - JavaScript
Installation
npm install telnyx
Setup
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
All examples below assume client is already initialized as shown above.
Get all wireless regions
Retrieve all wireless regions for the given product.
GET /wireless/regions
const response = await client.wireless.retrieveRegions({ product: 'public_ips' });
console.log(response.data);
Get all SIM cards
Get all SIM cards belonging to the user that match the given filters.
GET /sim_cards
// Automatically fetches more pages as needed.
for await (const simpleSimCard of client.simCards.list()) {
console.log(simpleSimCard.id);
}
Get SIM card
Returns the details regarding a specific SIM card.
GET /sim_cards/{id}
const simCard = await client.simCards.retrieve('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(simCard.data);
Update a SIM card
Updates SIM card data
PATCH /sim_cards/{id}
const simCard = await client.simCards.update('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(simCard.data);
Deletes a SIM card
The SIM card will be decommissioned, removed from your account and you will stop being charged.<br />The SIM card won't be able to connect to the network after the deletion is completed, thus makin...
DELETE /sim_cards/{id}
const simCard = await client.simCards.delete('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(simCard.data);
Get activation code for an eSIM
It returns the activation code for an eSIM.<br/><br/> This API is only available for eSIMs.
GET /sim_cards/{id}/activation_code
const response = await client.simCards.getActivationCode('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(response.data);
Get SIM card device details
It returns the device details where a SIM card is currently being used.
GET /sim_cards/{id}/device_details
const response = await client.simCards.getDeviceDetails('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(response.data);
Get SIM card public IP definition
It returns the public IP requested for a SIM card.
GET /sim_cards/{id}/public_ip
const response = await client.simCards.getPublicIP('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(response.data);
List wireless connectivity logs
This API allows listing a paginated collection of Wireless Connectivity Logs associated with a SIM Card, for troubleshooting purposes.
GET /sim_cards/{id}/wireless_connectivity_logs
// Automatically fetches more pages as needed.
for await (const simCardListWirelessConnectivityLogsResponse of client.simCards.listWirelessConnectivityLogs(
'6a09cdc3-8948-47f0-aa62-74ac943d6c58',
)) {
console.log(simCardListWirelessConnectivityLogsResponse.id);
}
Request a SIM card disable
This API disables a SIM card, disconnecting it from the network and making it impossible to consume data.<br/> The API will trigger an asynchronous operation called a SIM Card Action.
POST /sim_cards/{id}/actions/disable
const response = await client.simCards.actions.disable('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(response.data);
Request a SIM card enable
This API enables a SIM card, connecting it to the network and making it possible to consume data.<br/> To enable a SIM card, it must be associated with a SIM card group.<br/> The API will trigger a...
POST /sim_cards/{id}/actions/enable
const response = await client.simCards.actions.enable('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(response.data);
Request removing a SIM card public IP
This API removes an existing public IP from a SIM card.
POST /sim_cards/{id}/actions/remove_public_ip
const response = await client.simCards.actions.removePublicIP( '6a09cdc3-8948-47f0-aa62-74ac943d6c58', ); console.log(response.data);
Request setting a SIM card public IP
This API makes a SIM card reachable on the public internet by mapping a random public IP to the SIM card.
POST /sim_cards/{id}/actions/set_public_ip
const response = await client.simCards.actions.setPublicIP('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(response.data);
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.<br/> To set a SIM card to standby, it must be ...
POST /sim_cards/{id}/actions/set_standby
const response = await client.simCards.actions.setStandby('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(response.data);
Request bulk setting SIM card public IPs.
This API triggers an asynchronous operation to set a public IP for each of the specified SIM cards.<br/> For each SIM Card a SIM Card Action will be generated.
POST /sim_cards/actions/bulk_set_public_ips — Required: sim_card_ids
const response = await client.simCards.actions.bulkSetPublicIPs({
sim_card_ids: ['6b14e151-8493-4fa1-8664-1cc4e6d14158'],
});
console.log(response.data);
Validate SIM cards registration codes
It validates whether SIM card registration codes are valid or not.
POST /sim_cards/actions/validate_registration_codes
const response = await client.simCards.actions.validateRegistrationCodes(); console.log(response.data);
List SIM card actions
This API lists a paginated collection of SIM card actions.
GET /sim_card_actions
// Automatically fetches more pages as needed.
for await (const simCardAction of client.simCards.actions.list()) {
console.log(simCardAction.id);
}
Get SIM card action details
This API fetches detailed information about a SIM card action to follow-up on an existing asynchronous operation.
GET /sim_card_actions/{id}
const action = await client.simCards.actions.retrieve('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(action.data);
List bulk SIM card actions
This API lists a paginated collection of bulk SIM card actions.
GET /bulk_sim_card_actions
// Automatically fetches more pages as needed.
for await (const bulkSimCardActionListResponse of client.bulkSimCardActions.list()) {
console.log(bulkSimCardActionListResponse.id);
}
Get bulk SIM card action details
This API fetches information about a bulk SIM card action.
GET /bulk_sim_card_actions/{id}
const bulkSimCardAction = await client.bulkSimCardActions.retrieve( '6a09cdc3-8948-47f0-aa62-74ac943d6c58', ); console.log(bulkSimCardAction.data);
Get all SIM card groups
Get all SIM card groups belonging to the user that match the given filters.
GET /sim_card_groups
// Automatically fetches more pages as needed.
for await (const simCardGroupListResponse of client.simCardGroups.list()) {
console.log(simCardGroupListResponse.id);
}
Create a SIM card group
Creates a new SIM card group object
POST /sim_card_groups — Required: name
const simCardGroup = await client.simCardGroups.create({ name: 'My Test Group' });
console.log(simCardGroup.data);
Get SIM card group
Returns the details regarding a specific SIM card group
GET /sim_card_groups/{id}
const simCardGroup = await client.simCardGroups.retrieve('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(simCardGroup.data);
Update a SIM card group
Updates a SIM card group
PATCH /sim_card_groups/{id}
const simCardGroup = await client.simCardGroups.update('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(simCardGroup.data);
Delete a SIM card group
Permanently deletes a SIM card group
DELETE /sim_card_groups/{id}
const simCardGroup = await client.simCardGroups.delete('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(simCardGroup.data);
Request Private Wireless Gateway removal from SIM card group
This action will asynchronously remove an existing Private Wireless Gateway definition from a SIM card group.
POST /sim_card_groups/{id}/actions/remove_private_wireless_gateway
const response = await client.simCardGroups.actions.removePrivateWirelessGateway( '6a09cdc3-8948-47f0-aa62-74ac943d6c58', ); console.log(response.data);
Request Wireless Blocklist removal from SIM card group
This action will asynchronously remove an existing Wireless Blocklist to all the SIMs in the SIM card group.
POST /sim_card_groups/{id}/actions/remove_wireless_blocklist
const response = await client.simCardGroups.actions.removeWirelessBlocklist( '6a09cdc3-8948-47f0-aa62-74ac943d6c58', ); console.log(response.data);
Request Private Wireless Gateway assignment for SIM card group
This action will asynchronously assign a provisioned Private Wireless Gateway to the SIM card group.
POST /sim_card_groups/{id}/actions/set_private_wireless_gateway — Required: private_wireless_gateway_id
const response = await client.simCardGroups.actions.setPrivateWirelessGateway(
'6a09cdc3-8948-47f0-aa62-74ac943d6c58',
{ private_wireless_gateway_id: '6a09cdc3-8948-47f0-aa62-74ac943d6c58' },
);
console.log(response.data);
Request Wireless Blocklist assignment for SIM card group
This action will asynchronously assign a Wireless Blocklist to all the SIMs in the SIM card group.
POST /sim_card_groups/{id}/actions/set_wireless_blocklist — Required: wireless_blocklist_id
const response = await client.simCardGroups.actions.setWirelessBlocklist(
'6a09cdc3-8948-47f0-aa62-74ac943d6c58',
{ wireless_blocklist_id: '6a09cdc3-8948-47f0-aa62-74ac943d6c58' },
);
console.log(response.data);
List SIM card group actions
This API allows listing a paginated collection a SIM card group actions.
GET /sim_card_group_actions
// Automatically fetches more pages as needed.
for await (const simCardGroupAction of client.simCardGroups.actions.list()) {
console.log(simCardGroupAction.id);
}
Get SIM card group action details
This API allows fetching detailed information about a SIM card group action resource to make follow-ups in an existing asynchronous operation.
GET /sim_card_group_actions/{id}
const action = await client.simCardGroups.actions.retrieve('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(action.data);
Get all SIM card orders
Get all SIM card orders according to filters.
GET /sim_card_orders
// Automatically fetches more pages as needed.
for await (const simCardOrder of client.simCardOrders.list()) {
console.log(simCardOrder.id);
}
Create a SIM card order
Creates a new order for SIM cards.
POST /sim_card_orders — Required: address_id, quantity
const simCardOrder = await client.simCardOrders.create({
address_id: '1293384261075731499',
quantity: 23,
});
console.log(simCardOrder.data);
Get a single SIM card order
Get a single SIM card order by its ID.
GET /sim_card_orders/{id}
const simCardOrder = await client.simCardOrders.retrieve('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(simCardOrder.data);
Preview SIM card orders
Preview SIM card order purchases.
POST /sim_card_order_preview — Required: quantity, address_id
const response = await client.simCardOrderPreview.preview({
address_id: '1293384261075731499',
quantity: 21,
});
console.log(response.data);
List SIM card data usage notifications
Lists a paginated collection of SIM card data usage notifications.
GET /sim_card_data_usage_notifications
// Automatically fetches more pages as needed.
for await (const simCardDataUsageNotification of client.simCardDataUsageNotifications.list()) {
console.log(simCardDataUsageNotification.id);
}
Create a new SIM card data usage notification
Creates a new SIM card data usage notification.
POST /sim_card_data_usage_notifications — Required: sim_card_id, threshold
const simCardDataUsageNotification = await client.simCardDataUsageNotifications.create({
sim_card_id: '6a09cdc3-8948-47f0-aa62-74ac943d6c58',
threshold: {},
});
console.log(simCardDataUsageNotification.data);
Get a single SIM card data usage notification
Get a single SIM Card Data Usage Notification.
GET /sim_card_data_usage_notifications/{id}
const simCardDataUsageNotification = await client.simCardDataUsageNotifications.retrieve( '6a09cdc3-8948-47f0-aa62-74ac943d6c58', ); console.log(simCardDataUsageNotification.data);
Updates information for a SIM Card Data Usage Notification
Updates information for a SIM Card Data Usage Notification.
PATCH /sim_card_data_usage_notifications/{id}
const simCardDataUsageNotification = await client.simCardDataUsageNotifications.update( '6a09cdc3-8948-47f0-aa62-74ac943d6c58', ); console.log(simCardDataUsageNotification.data);
Delete SIM card data usage notifications
Delete the SIM Card Data Usage Notification.
DELETE /sim_card_data_usage_notifications/{id}
const simCardDataUsageNotification = await client.simCardDataUsageNotifications.delete( '6a09cdc3-8948-47f0-aa62-74ac943d6c58', ); console.log(simCardDataUsageNotification.data);
Purchase eSIMs
Purchases and registers the specified amount of eSIMs to the current user's account.<br/><br/> If <code>sim_card_group_id</code> is provided, the eSIMs will be associated with that group.
POST /actions/purchase/esims — Required: amount
const purchase = await client.actions.purchase.create({ amount: 10 });
console.log(purchase.data);
Register SIM cards
Register the SIM cards associated with the provided registration codes to the current user's account.<br/><br/> If <code>sim_card_group_id</code> is provided, the SIM cards will be associated with ...
POST /actions/register/sim_cards — Required: registration_codes
const register = await client.actions.register.create({
registration_codes: ['0000000001', '0000000002', '0000000003'],
});
console.log(register.data);
List OTA updates
GET /ota_updates
// Automatically fetches more pages as needed.
for await (const otaUpdateListResponse of client.otaUpdates.list()) {
console.log(otaUpdateListResponse.id);
}
Get OTA update
This API returns the details of an Over the Air (OTA) update.
GET /ota_updates/{id}
const otaUpdate = await client.otaUpdates.retrieve('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(otaUpdate.data);
Get all Private Wireless Gateways
Get all Private Wireless Gateways belonging to the user.
GET /private_wireless_gateways
// Automatically fetches more pages as needed.
for await (const privateWirelessGateway of client.privateWirelessGateways.list()) {
console.log(privateWirelessGateway.id);
}
Create a Private Wireless Gateway
Asynchronously create a Private Wireless Gateway for SIM cards for a previously created network.
POST /private_wireless_gateways — Required: network_id, name
const privateWirelessGateway = await client.privateWirelessGateways.create({
name: 'My private wireless gateway',
network_id: '6a09cdc3-8948-47f0-aa62-74ac943d6c58',
});
console.log(privateWirelessGateway.data);
Get a Private Wireless Gateway
Retrieve information about a Private Wireless Gateway.
GET /private_wireless_gateways/{id}
const privateWirelessGateway = await client.privateWirelessGateways.retrieve( '6a09cdc3-8948-47f0-aa62-74ac943d6c58', ); console.log(privateWirelessGateway.data);
Delete a Private Wireless Gateway
Deletes the Private Wireless Gateway.
DELETE /private_wireless_gateways/{id}
const privateWirelessGateway = await client.privateWirelessGateways.delete( '6a09cdc3-8948-47f0-aa62-74ac943d6c58', ); console.log(privateWirelessGateway.data);
Get all Wireless Blocklists
Get all Wireless Blocklists belonging to the user.
GET /wireless_blocklists
// Automatically fetches more pages as needed.
for await (const wirelessBlocklist of client.wirelessBlocklists.list()) {
console.log(wirelessBlocklist.id);
}
Create a Wireless Blocklist
Create a Wireless Blocklist to prevent SIMs from connecting to certain networks.
POST /wireless_blocklists — Required: name, type, values
const wirelessBlocklist = await client.wirelessBlocklists.create({
name: 'My Wireless Blocklist',
type: 'country',
values: ['CA', 'US'],
});
console.log(wirelessBlocklist.data);
Update a Wireless Blocklist
Update a Wireless Blocklist.
PATCH /wireless_blocklists
const wirelessBlocklist = await client.wirelessBlocklists.update(); console.log(wirelessBlocklist.data);
Get a Wireless Blocklist
Retrieve information about a Wireless Blocklist.
GET /wireless_blocklists/{id}
const wirelessBlocklist = await client.wirelessBlocklists.retrieve( '6a09cdc3-8948-47f0-aa62-74ac943d6c58', ); console.log(wirelessBlocklist.data);
Delete a Wireless Blocklist
Deletes the Wireless Blocklist.
DELETE /wireless_blocklists/{id}
const wirelessBlocklist = await client.wirelessBlocklists.delete( '6a09cdc3-8948-47f0-aa62-74ac943d6c58', ); console.log(wirelessBlocklist.data);
Get all possible wireless blocklist values
Retrieve all wireless blocklist values for a given blocklist type.
GET /wireless_blocklist_values
const wirelessBlocklistValues = await client.wirelessBlocklistValues.list({ type: 'country' });
console.log(wirelessBlocklistValues.data);