Telnyx Iot - Go

SkillDev tools

Manage IoT SIM cards, eSIMs, data plans, and wireless connectivity. Use when building IoT/M2M solutions. This skill provides Go SDK examples.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Telnyx Iot - Go skill

What this skill tells your AI

The instructions your AI receives, as published by team-telnyx/ai in skills/telnyx-iot-go/SKILL.md and read by ahel’s review.

Installation

go get github.com/team-telnyx/telnyx-go

Setup

import (
  "context"
  "fmt"
  "os"

  "github.com/team-telnyx/telnyx-go"
  "github.com/team-telnyx/telnyx-go/option"
)

client := telnyx.NewClient(
  option.WithAPIKey(os.Getenv("TELNYX_API_KEY")),
)

All examples below assume client is already initialized as shown above.

Error Handling

All API calls can fail with network errors, rate limits (429), validation errors (422), or authentication errors (401). Always handle errors in production code:

import "errors"

result, err := client.Messages.Send(ctx, params)
if err != nil {
  var apiErr *telnyx.Error
  if errors.As(err, &apiErr) {
    switch apiErr.StatusCode {
    case 422:
      fmt.Println("Validation error — check required fields and formats")
    case 429:
      // Rate limited — wait and retry with exponential backoff
      fmt.Println("Rate limited, retrying...")
    default:
      fmt.Printf("API error %d: %s\n", apiErr.StatusCode, apiErr.Error())
    }
  } else {
    fmt.Println("Network error — check connectivity and retry")
  }
}

Common error codes: 401 invalid API key, 403 insufficient permissions, 404 resource not found, 422 validation error (check field formats), 429 rate limited (retry with exponential backoff).

Important Notes

  • Pagination: Use ListAutoPaging() for automatic iteration: iter := client.Resource.ListAutoPaging(ctx, params); for iter.Next() { item := iter.Current() }.

Purchase eSIMs

Purchases and registers the specified amount of eSIMs to the current user's account. If sim_card_group_id is provided, the eSIMs will be associated with that group. Otherwise, the default group for the current user will be used.

POST /actions/purchase/esims — Required: amount

Optional: product (string), sim_card_group_id (uuid), status (enum: enabled, disabled, standby), tags (array[string]), whitelabel_name (string)

	purchase, err := client.Actions.Purchase.New(context.Background(), telnyx.ActionPurchaseNewParams{
		Amount: 10,
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", purchase.Data)

Returns: actions_in_progress (boolean), authorized_imeis (array | null), created_at (string), current_billing_period_consumed_data (object), data_limit (object), eid (string | null), esim_installation_status (enum: released, disabled), iccid (string), id (uuid), imsi (string), msisdn (string), record_type (string), resources_with_in_progress_actions (array[object]), sim_card_group_id (uuid), status (object), tags (array[string]), type (enum: physical, esim), updated_at (string), version (string), voice_enabled (boolean)

Register SIM cards

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.

POST /actions/register/sim_cards — Required: registration_codes

Optional: sim_card_group_id (uuid), status (enum: enabled, disabled, standby), tags (array[string])

	register, err := client.Actions.Register.New(context.Background(), telnyx.ActionRegisterNewParams{
		RegistrationCodes: []string{"0000000001", "0000000002", "0000000003"},
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", register.Data)

Returns: actions_in_progress (boolean), authorized_imeis (array | null), created_at (string), current_billing_period_consumed_data (object), data_limit (object), eid (string | null), esim_installation_status (enum: released, disabled), iccid (string), id (uuid), imsi (string), msisdn (string), record_type (string), resources_with_in_progress_actions (array[object]), sim_card_group_id (uuid), status (object), tags (array[string]), type (enum: physical, esim), updated_at (string), version (string), voice_enabled (boolean)

List bulk SIM card actions

This API lists a paginated collection of bulk SIM card actions. A bulk SIM card action contains details about a collection of individual SIM card actions.

GET /bulk_sim_card_actions

	page, err := client.BulkSimCardActions.List(context.Background(), telnyx.BulkSimCardActionListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)

Returns: action_type (enum: bulk_disable_voice, bulk_enable_voice, bulk_set_public_ips), created_at (string), id (uuid), record_type (string), settings (object), sim_card_actions_summary (array[object]), updated_at (string)

Get bulk SIM card action details

This API fetches information about a bulk SIM card action. A bulk SIM card action contains details about a collection of individual SIM card actions.

GET /bulk_sim_card_actions/{id}

	bulkSimCardAction, err := client.BulkSimCardActions.Get(context.Background(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", bulkSimCardAction.Data)

Returns: action_type (enum: bulk_disable_voice, bulk_enable_voice, bulk_set_public_ips), created_at (string), id (uuid), record_type (string), settings (object), sim_card_actions_summary (array[object]), updated_at (string)

List OTA updates

GET /ota_updates

	page, err := client.OtaUpdates.List(context.Background(), telnyx.OtaUpdateListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)

Returns: created_at (string), id (uuid), record_type (string), sim_card_id (uuid), status (enum: in-progress, completed, failed), type (enum: sim_card_network_preferences), updated_at (string)

Get OTA update

This API returns the details of an Over the Air (OTA) update.

GET /ota_updates/{id}

	otaUpdate, err := client.OtaUpdates.Get(context.Background(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", otaUpdate.Data)

Returns: created_at (string), id (uuid), record_type (string), settings (object), sim_card_id (uuid), status (enum: in-progress, completed, failed), type (enum: sim_card_network_preferences), updated_at (string)

List SIM card actions

This API lists a paginated collection of SIM card actions. It enables exploring a collection of existing asynchronous operations using specific filters.

GET /sim_card_actions

	page, err := client.SimCards.Actions.List(context.Background(), telnyx.SimCardActionListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)

Returns: action_type (enum: enable, enable_standby_sim_card, disable, set_standby), created_at (string), id (uuid), record_type (string), settings (object | null), sim_card_id (uuid), status (object), updated_at (string)

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}

	action, err := client.SimCards.Actions.Get(context.Background(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", action.Data)

Returns: action_type (enum: enable, enable_standby_sim_card, disable, set_standby), created_at (string), id (uuid), record_type (string), settings (object | null), sim_card_id (uuid), status (object), updated_at (string)

List SIM card data usage notifications

Lists a paginated collection of SIM card data usage notifications. It enables exploring the collection using specific filters.

GET /sim_card_data_usage_notifications

	page, err := client.SimCardDataUsageNotifications.List(context.Background(), telnyx.SimCardDataUsageNotificationListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)

Returns: created_at (string), id (uuid), record_type (string), sim_card_id (uuid), threshold (object), updated_at (string)

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

	simCardDataUsageNotification, err := client.SimCardDataUsageNotifications.New(context.Background(), telnyx.SimCardDataUsageNotificationNewParams{
		SimCardID: "6a09cdc3-8948-47f0-aa62-74ac943d6c58",
		Threshold: telnyx.SimCardDataUsageNotificationNewParamsThreshold{},
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", simCardDataUsageNotification.Data)

Returns: created_at (string), id (uuid), record_type (string), sim_card_id (uuid), threshold (object), updated_at (string)

Get a single SIM card data usage notification

Get a single SIM Card Data Usage Notification.

GET /sim_card_data_usage_notifications/{id}

	simCardDataUsageNotification, err := client.SimCardDataUsageNotifications.Get(context.Background(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", simCardDataUsageNotification.Data)

Returns: created_at (string), id (uuid), record_type (string), sim_card_id (uuid), threshold (object), updated_at (string)

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}

Optional: created_at (string), id (uuid), record_type (string), sim_card_id (uuid), threshold (object), updated_at (string)

	simCardDataUsageNotification, err := client.SimCardDataUsageNotifications.Update(
		context.Background(),
		"6a09cdc3-8948-47f0-aa62-74ac943d6c58",
		telnyx.SimCardDataUsageNotificationUpdateParams{
			SimCardDataUsageNotification: telnyx.SimCardDataUsageNotificationParam{},
		},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", simCardDataUsageNotification.Data)

Returns: created_at (string), id (uuid), record_type (string), sim_card_id (uuid), threshold (object), updated_at (string)

Delete SIM card data usage notifications

Delete the SIM Card Data Usage Notification.

DELETE /sim_card_data_usage_notifications/{id}

	simCardDataUsageNotification, err := client.SimCardDataUsageNotifications.Delete(context.Background(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", simCardDataUsageNotification.Data)

Returns: created_at (string), id (uuid), record_type (string), sim_card_id (uuid), threshold (object), updated_at (string)

List SIM card group actions

This API allows listing a paginated collection a SIM card group actions. It allows to explore a collection of existing asynchronous operation using specific filters.

GET /sim_card_group_actions

	page, err := client.SimCardGroups.Actions.List(context.Background(), telnyx.SimCardGroupActionListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)

Returns: created_at (string), id (uuid), record_type (string), settings (object), sim_card_group_id (uuid), status (enum: in-progress, completed, failed), type (enum: set_private_wireless_gateway, remove_private_wireless_gateway, set_wireless_blocklist, remove_wireless_blocklist), updated_at (string)

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}

	action, err := client.SimCardGroups.Actions.Get(context.Background(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", action.Data)

Returns: created_at (string), id (uuid), record_type (string), settings (object), sim_card_group_id (uuid), status (enum: in-progress, completed, failed), type (enum: set_private_wireless_gateway, remove_private_wireless_gateway, set_wireless_blocklist, remove_wireless_blocklist), updated_at (string)

Get all SIM card groups

Get all SIM card groups belonging to the user that match the given filters.

GET /sim_card_groups

	page, err := client.SimCardGroups.List(context.Background(), telnyx.SimCardGroupListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)

Returns: consumed_data (object), created_at (string), data_limit (object), default (boolean), id (uuid), name (string), private_wireless_gateway_id (uuid), record_type (string), sim_card_count (integer), updated_at (string), wireless_blocklist_id (uuid)

Create a SIM card group

Creates a new SIM card group object

POST /sim_card_groups — Required: name

Optional: data_limit (object)

	simCardGroup, err := client.SimCardGroups.New(context.Background(), telnyx.SimCardGroupNewParams{
		Name: "My Test Group",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", simCardGroup.Data)

Returns: consumed_data (object), created_at (string), data_limit (object), default (boolean), id (uuid), name (string), private_wireless_gateway_id (uuid), record_type (string), updated_at (string), wireless_blocklist_id (uuid)

Get SIM card group

Returns the details regarding a specific SIM card group

GET /sim_card_groups/{id}

	simCardGroup, err := client.SimCardGroups.Get(
		context.Background(),
		"6a09cdc3-8948-47f0-aa62-74ac943d6c58",
		telnyx.SimCardGroupGetParams{},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", simCardGroup.Data)

Returns: consumed_data (object), created_at (string), data_limit (object), default (boolean), id (uuid), name (string), private_wireless_gateway_id (uuid), record_type (string), updated_at (string), wireless_blocklist_id (uuid)

Update a SIM card group

Updates a SIM card group

PATCH /sim_card_groups/{id}

Optional: data_limit (object), name (string)

	simCardGroup, err := client.SimCardGroups.Update(
		context.Background(),
		"6a09cdc3-8948-47f0-aa62-74ac943d6c58",
		telnyx.SimCardGroupUpdateParams{},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", simCardGroup.Data)

Returns: consumed_data (object), created_at (string), data_limit (object), default (boolean), id (uuid), name (string), private_wireless_gateway_id (uuid), record_type (string), updated_at (string), wireless_blocklist_id (uuid)

Delete a SIM card group

Permanently deletes a SIM card group

DELETE /sim_card_groups/{id}

	simCardGroup, err := client.SimCardGroups.Delete(context.Background(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", simCardGroup.Data)

Returns: consumed_data (object), created_at (string), data_limit (object), default (boolean), id (uuid), name (string), private_wireless_gateway_id (uuid), record_type (string), updated_at (string), wireless_blocklist_id (uuid)

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. Completing this operation defines that all SIM cards in the SIM card group will get their traffic handled by Telnyx's default mobile network configuration.

POST /sim_card_groups/{id}/actions/remove_private_wireless_gateway

	response, err := client.SimCardGroups.Actions.RemovePrivateWirelessGateway(context.Background(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns: created_at (string), id (uuid), record_type (string), settings (object), sim_card_group_id (uuid), status (enum: in-progress, completed, failed), type (enum: set_private_wireless_gateway, remove_private_wireless_gateway, set_wireless_blocklist, remove_wireless_blocklist), updated_at (string)

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

	response, err := client.SimCardGroups.Actions.RemoveWirelessBlocklist(context.Background(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns: created_at (string), id (uuid), record_type (string), settings (object), sim_card_group_id (uuid), status (enum: in-progress, completed, failed), type (enum: set_private_wireless_gateway, remove_private_wireless_gateway, set_wireless_blocklist, remove_wireless_blocklist), updated_at (string)

Request Private Wireless Gateway assignment for SIM card group

This action will asynchronously assign a provisioned Private Wireless Gateway to the SIM card group. Completing this operation defines that all SIM cards in the SIM card group will get their traffic controlled by the associated Private Wireless Gateway. This operation will also imply that new SIM cards assigned to a group will inherit its network definitions.

POST /sim_card_groups/{id}/actions/set_private_wireless_gateway — Required: private_wireless_gateway_id

	response, err := client.SimCardGroups.Actions.SetPrivateWirelessGateway(
		context.Background(),
		"6a09cdc3-8948-47f0-aa62-74ac943d6c58",
		telnyx.SimCardGroupActionSetPrivateWirelessGatewayParams{
			PrivateWirelessGatewayID: "6a09cdc3-8948-47f0-aa62-74ac943d6c58",
		},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns: created_at (string), id (uuid), record_type (string), settings (object), sim_card_group_id (uuid), status (enum: in-progress, completed, failed), type (enum: set_private_wireless_gateway, remove_private_wireless_gateway, set_wireless_blocklist, remove_wireless_blocklist), updated_at (string)

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

	response, err := client.SimCardGroups.Actions.SetWirelessBlocklist(
		context.Background(),
		"6a09cdc3-8948-47f0-aa62-74ac943d6c58",
		telnyx.SimCardGroupActionSetWirelessBlocklistParams{
			WirelessBlocklistID: "6a09cdc3-8948-47f0-aa62-74ac943d6c58",
		},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns: created_at (string), id (uuid), record_type (string), settings (object), sim_card_group_id (uuid), status (enum: in-progress, completed, failed), type (enum: set_private_wireless_gateway, remove_private_wireless_gateway, set_wireless_blocklist, remove_wireless_blocklist), updated_at (string)

Preview SIM card orders

Preview SIM card order purchases.

POST /sim_card_order_preview — Required: quantity, address_id

	response, err := client.SimCardOrderPreview.Preview(context.Background(), telnyx.SimCardOrderPreviewPreviewParams{
		AddressID: "1293384261075731499",
		Quantity:  21,
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns: quantity (integer), record_type (string), shipping_cost (object), sim_cards_cost (object), total_cost (object)

Get all SIM card orders

Get all SIM card orders according to filters.

GET /sim_card_orders

	page, err := client.SimCardOrders.List(context.Background(), telnyx.SimCardOrderListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)

Returns: cost (object), created_at (string), id (uuid), order_address (object), quantity (integer), record_type (string), status (enum: pending, processing, ready_to_ship, shipped, delivered, canceled), tracking_url (uri), updated_at (string)

Create a SIM card order

Creates a new order for SIM cards.

POST /sim_card_orders — Required: address_id, quantity

	simCardOrder, err := client.SimCardOrders.New(context.Background(), telnyx.SimCardOrderNewParams{
		AddressID: "1293384261075731499",
		Quantity:  23,
		SimCardGroupID: "550e8400-e29b-41d4-a716-446655440000",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", simCardOrder.Data)

Returns: cost (object), created_at (string), id (uuid), order_address (object), quantity (integer), record_type (string), status (enum: pending, processing, ready_to_ship, shipped, delivered, canceled), tracking_url (uri), updated_at (string)

Get a single SIM card order

Get a single SIM card order by its ID.

GET /sim_card_orders/{id}

	simCardOrder, err := client.SimCardOrders.Get(context.Background(), "6a09cdc3-8948-47f0-aa62-74ac943d6c58")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", simCardOrder.Data)

Returns: cost (object), created_at (string), id (uuid), order_address (object), quantity (integer), record_type (string), status (enum: pending, processing, ready_to_ship, shipped, delivered, canceled), tracking_url (uri), updated_at (string)

Get all SIM cards

Get all SIM cards belonging to the user that match the given filters.

GET /sim_cards

	page, err := client.SimCards.List(context.Background(), telnyx.SimCardListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)

Returns: actions_in_progress (boolean), authorized_imeis (array | null), created_at (string), current_billing_period_consumed_data (object), data_limit (object), eid (string | null), esim_installation_status (enum: released, disabled), iccid (string), id (uuid), imsi (string), msisdn (string), record_type (string), resources_with_in_progress_actions (array[object]), sim_card_group_id (uuid), status (object), tags (array[string]), type (enum: physical, esim), updated_at (string), version (string), voice_enabled (boolean)

Request bulk disabling voice on SIM cards.

This API triggers an asynchronous operation to disable voice on SIM cards belonging to a specified SIM Card Group. For each SIM Card a SIM Card Action will be generated.

POST /sim_cards/actions/bulk_disable_voice — Required: sim_card_group_id

	response, err := client.SimCards.Actions.BulkDisableVoice(context.Background(), telnyx.SimCardActionBulkDisableVoiceParams{
		SimCardGroupID: "6b14e151-8493-4fa1-8664-1cc4e6d14158",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns: action_type (enum: bulk_disable_voice, bulk_enable_voice, bulk_set_public_ips), created_at (string), id (uuid), record_type (string), settings (object), updated_at (string)

Request bulk enabling voice on SIM cards.

This API triggers an asynchronous operation to enable voice on SIM cards belonging to a specified SIM Card Group. For each SIM Card a SIM Card Action will be generated.

POST /sim_cards/actions/bulk_enable_voice — Required: sim_card_group_id

	response, err := client.SimCards.Actions.BulkEnableVoice(context.Background(), telnyx.SimCardActionBulkEnableVoiceParams{
		SimCardGroupID: "6b14e151-8493-4fa1-8664-1cc4e6d14158",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns: action_type (enum: bulk_disable_voice, bulk_enable_voice, bulk_set_public_ips), created_at (string), id (uuid), record_type (string), settings (object), updated_at (string)

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. For each SIM Card a SIM Card Action will be generated. The status of the SIM Card Action can be followed through the List SIM Card Action API.

POST /sim_cards/actions/bulk_set_public_ips — Required: sim_card_ids

Shortened here. Read the whole file on GitHub.

Signals

GitHub stars
214
Forks
21
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
telnyx-iot-go
Source
github.com/team-telnyx/ai