Telnyx Porting In - Go

SkillDocs & knowledge

Port phone numbers into Telnyx. Check portability, create port orders, upload LOA documents, and track porting status. 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 Porting In - Go skill

What this skill tells your AI

The instructions your AI receives, as published by team-telnyx/ai in skills/telnyx-porting-in-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

  • Phone numbers must be in E.164 format (e.g., +13125550001). Include the + prefix and country code. No spaces, dashes, or parentheses.
  • Pagination: Use ListAutoPaging() for automatic iteration: iter := client.Resource.ListAutoPaging(ctx, params); for iter.Next() { item := iter.Current() }.

Run a portability check

Runs a portability check, returning the results immediately.

POST /portability_checks

Optional: phone_numbers (array[string])

	response, err := client.PortabilityChecks.Run(context.Background(), telnyx.PortabilityCheckRunParams{
		PhoneNumbers: []string{"+18005550101"},
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns: fast_portable (boolean), not_portable_reason (string), phone_number (string), portable (boolean), record_type (string)

List all porting events

Returns a list of all porting events.

GET /porting/events

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

Returns: available_notification_methods (array[string]), event_type (enum: porting_order.deleted), id (uuid), payload (object), payload_status (enum: created, completed), porting_order_id (uuid)

Show a porting event

Show a specific porting event.

GET /porting/events/{id}

	event, err := client.Porting.Events.Get(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", event.Data)

Returns: available_notification_methods (array[string]), event_type (enum: porting_order.deleted), id (uuid), payload (object), payload_status (enum: created, completed), porting_order_id (uuid)

Republish a porting event

Republish a specific porting event.

POST /porting/events/{id}/republish

	err := client.Porting.Events.Republish(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}

List LOA configurations

List the LOA configurations.

GET /porting/loa_configurations

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

Returns: address (object), company_name (string), contact (object), created_at (date-time), id (uuid), logo (object), name (string), organization_id (string), record_type (string), updated_at (date-time)

Create a LOA configuration

Create a LOA configuration.

POST /porting/loa_configurations

	loaConfiguration, err := client.Porting.LoaConfigurations.New(context.Background(), telnyx.PortingLoaConfigurationNewParams{
		Address: telnyx.PortingLoaConfigurationNewParamsAddress{
			City:          "Austin",
			CountryCode:   "US",
			State:         "TX",
			StreetAddress: "600 Congress Avenue",
			ZipCode:       "78701",
		},
		CompanyName: "Telnyx",
		Contact: telnyx.PortingLoaConfigurationNewParamsContact{
			Email:       "testing@telnyx.com",
			PhoneNumber: "+12003270001",
		},
		Logo: telnyx.PortingLoaConfigurationNewParamsLogo{
			DocumentID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		},
		Name: "My LOA Configuration",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", loaConfiguration.Data)

Returns: address (object), company_name (string), contact (object), created_at (date-time), id (uuid), logo (object), name (string), organization_id (string), record_type (string), updated_at (date-time)

Preview the LOA configuration parameters

Preview the LOA template that would be generated without need to create LOA configuration.

POST /porting/loa_configurations/preview

	response, err := client.Porting.LoaConfigurations.Preview(context.Background(), telnyx.PortingLoaConfigurationPreviewParams{
		Address: telnyx.PortingLoaConfigurationPreviewParamsAddress{
			City:          "Austin",
			CountryCode:   "US",
			State:         "TX",
			StreetAddress: "600 Congress Avenue",
			ZipCode:       "78701",
		},
		CompanyName: "Telnyx",
		Contact: telnyx.PortingLoaConfigurationPreviewParamsContact{
			Email:       "testing@telnyx.com",
			PhoneNumber: "+12003270001",
		},
		Logo: telnyx.PortingLoaConfigurationPreviewParamsLogo{
			DocumentID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		},
		Name: "My LOA Configuration",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response)

Retrieve a LOA configuration

Retrieve a specific LOA configuration.

GET /porting/loa_configurations/{id}

	loaConfiguration, err := client.Porting.LoaConfigurations.Get(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", loaConfiguration.Data)

Returns: address (object), company_name (string), contact (object), created_at (date-time), id (uuid), logo (object), name (string), organization_id (string), record_type (string), updated_at (date-time)

Update a LOA configuration

Update a specific LOA configuration.

PATCH /porting/loa_configurations/{id}

	loaConfiguration, err := client.Porting.LoaConfigurations.Update(
		context.Background(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.PortingLoaConfigurationUpdateParams{
			Address: telnyx.PortingLoaConfigurationUpdateParamsAddress{
				City:          "Austin",
				CountryCode:   "US",
				State:         "TX",
				StreetAddress: "600 Congress Avenue",
				ZipCode:       "78701",
			},
			CompanyName: "Telnyx",
			Contact: telnyx.PortingLoaConfigurationUpdateParamsContact{
				Email:       "testing@telnyx.com",
				PhoneNumber: "+12003270001",
			},
			Logo: telnyx.PortingLoaConfigurationUpdateParamsLogo{
				DocumentID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
			},
			Name: "My LOA Configuration",
		},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", loaConfiguration.Data)

Returns: address (object), company_name (string), contact (object), created_at (date-time), id (uuid), logo (object), name (string), organization_id (string), record_type (string), updated_at (date-time)

Delete a LOA configuration

Delete a specific LOA configuration.

DELETE /porting/loa_configurations/{id}

	err := client.Porting.LoaConfigurations.Delete(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}

Preview a LOA configuration

Preview a specific LOA configuration.

GET /porting/loa_configurations/{id}/preview

	response, err := client.Porting.LoaConfigurations.Preview1(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response)

List porting related reports

List the reports generated about porting operations.

GET /porting/reports

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

Returns: created_at (date-time), document_id (uuid), id (uuid), params (object), record_type (string), report_type (enum: export_porting_orders_csv), status (enum: pending, completed), updated_at (date-time)

Create a porting related report

Generate reports about porting operations.

POST /porting/reports

	report, err := client.Porting.Reports.New(context.Background(), telnyx.PortingReportNewParams{
		Params: telnyx.ExportPortingOrdersCsvReportParam{
			Filters: telnyx.ExportPortingOrdersCsvReportFiltersParam{},
		},
		ReportType: telnyx.PortingReportNewParamsReportTypeExportPortingOrdersCsv,
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", report.Data)

Returns: created_at (date-time), document_id (uuid), id (uuid), params (object), record_type (string), report_type (enum: export_porting_orders_csv), status (enum: pending, completed), updated_at (date-time)

Retrieve a report

Retrieve a specific report generated.

GET /porting/reports/{id}

	report, err := client.Porting.Reports.Get(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", report.Data)

Returns: created_at (date-time), document_id (uuid), id (uuid), params (object), record_type (string), report_type (enum: export_porting_orders_csv), status (enum: pending, completed), updated_at (date-time)

List available carriers in the UK

List available carriers in the UK.

GET /porting/uk_carriers

	response, err := client.Porting.ListUkCarriers(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns: alternative_cupids (array[string]), created_at (date-time), cupid (string), id (uuid), name (string), record_type (string), updated_at (date-time)

List all porting orders

Returns a list of your porting order.

GET /porting_orders

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

Returns: activation_settings (object), additional_steps (array[string]), created_at (date-time), customer_group_reference (string | null), customer_reference (string | null), description (string), documents (object), end_user (object), id (uuid), messaging (object), misc (object), old_service_provider_ocn (string), parent_support_key (string | null), phone_number_configuration (object), phone_number_type (enum: landline, local, mobile, national, shared_cost, toll_free), phone_numbers (array[object]), porting_phone_numbers_count (integer), record_type (string), requirements (array[object]), requirements_met (boolean), status (object), support_key (string | null), updated_at (date-time), user_feedback (object), user_id (uuid), webhook_url (uri)

Create a porting order

Creates a new porting order object.

POST /porting_orders — Required: phone_numbers

Optional: customer_group_reference (string), customer_reference (string | null)

	portingOrder, err := client.PortingOrders.New(context.Background(), telnyx.PortingOrderNewParams{
		PhoneNumbers: []string{"+13035550000", "+13035550001", "+13035550002"},
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", portingOrder.Data)

Returns: activation_settings (object), additional_steps (array[string]), created_at (date-time), customer_group_reference (string | null), customer_reference (string | null), description (string), documents (object), end_user (object), id (uuid), messaging (object), misc (object), old_service_provider_ocn (string), parent_support_key (string | null), phone_number_configuration (object), phone_number_type (enum: landline, local, mobile, national, shared_cost, toll_free), phone_numbers (array[object]), porting_phone_numbers_count (integer), record_type (string), requirements (array[object]), requirements_met (boolean), status (object), support_key (string | null), updated_at (date-time), user_feedback (object), user_id (uuid), webhook_url (uri)

List all exception types

Returns a list of all possible exception types for a porting order.

GET /porting_orders/exception_types

	response, err := client.PortingOrders.GetExceptionTypes(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns: code (enum: ACCOUNT_NUMBER_MISMATCH, AUTH_PERSON_MISMATCH, BTN_ATN_MISMATCH, ENTITY_NAME_MISMATCH, FOC_EXPIRED, FOC_REJECTED, LOCATION_MISMATCH, LSR_PENDING, MAIN_BTN_PORTING, OSP_IRRESPONSIVE, OTHER, PASSCODE_PIN_INVALID, PHONE_NUMBER_HAS_SPECIAL_FEATURE, PHONE_NUMBER_MISMATCH, PHONE_NUMBER_NOT_PORTABLE, PORT_TYPE_INCORRECT, PORTING_ORDER_SPLIT_REQUIRED, POSTAL_CODE_MISMATCH, RATE_CENTER_NOT_PORTABLE, SV_CONFLICT, SV_UNKNOWN_FAILURE), description (string)

List all phone number configurations

Returns a list of phone number configurations paginated.

GET /porting_orders/phone_number_configurations

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

Returns: created_at (date-time), id (uuid), porting_phone_number_id (uuid), record_type (string), updated_at (date-time), user_bundle_id (uuid)

Create a list of phone number configurations

Creates a list of phone number configurations.

POST /porting_orders/phone_number_configurations

	phoneNumberConfiguration, err := client.PortingOrders.PhoneNumberConfigurations.New(context.Background(), telnyx.PortingOrderPhoneNumberConfigurationNewParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", phoneNumberConfiguration.Data)

Returns: created_at (date-time), id (uuid), porting_phone_number_id (uuid), record_type (string), updated_at (date-time), user_bundle_id (uuid)

Retrieve a porting order

Retrieves the details of an existing porting order.

GET /porting_orders/{id}

	portingOrder, err := client.PortingOrders.Get(
		context.Background(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.PortingOrderGetParams{},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", portingOrder.Data)

Returns: activation_settings (object), additional_steps (array[string]), created_at (date-time), customer_group_reference (string | null), customer_reference (string | null), description (string), documents (object), end_user (object), id (uuid), messaging (object), misc (object), old_service_provider_ocn (string), parent_support_key (string | null), phone_number_configuration (object), phone_number_type (enum: landline, local, mobile, national, shared_cost, toll_free), phone_numbers (array[object]), porting_phone_numbers_count (integer), record_type (string), requirements (array[object]), requirements_met (boolean), status (object), support_key (string | null), updated_at (date-time), user_feedback (object), user_id (uuid), webhook_url (uri)

Edit a porting order

Edits the details of an existing porting order. Any or all of a porting orders attributes may be included in the resource object included in a PATCH request. If a request does not include all of the attributes for a resource, the system will interpret the missing attributes as if they were included with their current values.

PATCH /porting_orders/{id}

Optional: activation_settings (object), customer_group_reference (string), customer_reference (string), documents (object), end_user (object), messaging (object), misc (object), phone_number_configuration (object), requirement_group_id (uuid), requirements (array[object]), user_feedback (object), webhook_url (uri)

	portingOrder, err := client.PortingOrders.Update(
		context.Background(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.PortingOrderUpdateParams{},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", portingOrder.Data)

Returns: activation_settings (object), additional_steps (array[string]), created_at (date-time), customer_group_reference (string | null), customer_reference (string | null), description (string), documents (object), end_user (object), id (uuid), messaging (object), misc (object), old_service_provider_ocn (string), parent_support_key (string | null), phone_number_configuration (object), phone_number_type (enum: landline, local, mobile, national, shared_cost, toll_free), phone_numbers (array[object]), porting_phone_numbers_count (integer), record_type (string), requirements (array[object]), requirements_met (boolean), status (object), support_key (string | null), updated_at (date-time), user_feedback (object), user_id (uuid), webhook_url (uri)

Delete a porting order

Deletes an existing porting order. This operation is restrict to porting orders in draft state.

DELETE /porting_orders/{id}

	err := client.PortingOrders.Delete(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}

Activate every number in a porting order asynchronously.

Activate each number in a porting order asynchronously. This operation is limited to US FastPort orders only.

POST /porting_orders/{id}/actions/activate

	response, err := client.PortingOrders.Actions.Activate(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns: activate_at (date-time), activation_type (enum: scheduled, on-demand), activation_windows (array[object]), created_at (date-time), id (uuid), record_type (string), status (enum: created, in-process, completed, failed), updated_at (date-time)

Cancel a porting order

POST /porting_orders/{id}/actions/cancel

	response, err := client.PortingOrders.Actions.Cancel(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns: activation_settings (object), additional_steps (array[string]), created_at (date-time), customer_group_reference (string | null), customer_reference (string | null), description (string), documents (object), end_user (object), id (uuid), messaging (object), misc (object), old_service_provider_ocn (string), parent_support_key (string | null), phone_number_configuration (object), phone_number_type (enum: landline, local, mobile, national, shared_cost, toll_free), phone_numbers (array[object]), porting_phone_numbers_count (integer), record_type (string), requirements (array[object]), requirements_met (boolean), status (object), support_key (string | null), updated_at (date-time), user_feedback (object), user_id (uuid), webhook_url (uri)

Submit a porting order.

Confirm and submit your porting order.

POST /porting_orders/{id}/actions/confirm

	response, err := client.PortingOrders.Actions.Confirm(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns: activation_settings (object), additional_steps (array[string]), created_at (date-time), customer_group_reference (string | null), customer_reference (string | null), description (string), documents (object), end_user (object), id (uuid), messaging (object), misc (object), old_service_provider_ocn (string), parent_support_key (string | null), phone_number_configuration (object), phone_number_type (enum: landline, local, mobile, national, shared_cost, toll_free), phone_numbers (array[object]), porting_phone_numbers_count (integer), record_type (string), requirements (array[object]), requirements_met (boolean), status (object), support_key (string | null), updated_at (date-time), user_feedback (object), user_id (uuid), webhook_url (uri)

Share a porting order

Creates a sharing token for a porting order. The token can be used to share the porting order with non-Telnyx users.

POST /porting_orders/{id}/actions/share

	response, err := client.PortingOrders.Actions.Share(
		context.Background(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.PortingOrderActionShareParams{},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns: created_at (date-time), expires_at (date-time), expires_in_seconds (integer), id (uuid), permissions (array[string]), porting_order_id (uuid), record_type (string), token (string)

List all porting activation jobs

Returns a list of your porting activation jobs.

GET /porting_orders/{id}/activation_jobs

	page, err := client.PortingOrders.ActivationJobs.List(
		context.Background(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.PortingOrderActivationJobListParams{},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)

Returns: activate_at (date-time), activation_type (enum: scheduled, on-demand), activation_windows (array[object]), created_at (date-time), id (uuid), record_type (string), status (enum: created, in-process, completed, failed), updated_at (date-time)

Retrieve a porting activation job

Returns a porting activation job.

GET /porting_orders/{id}/activation_jobs/{activationJobId}

	activationJob, err := client.PortingOrders.ActivationJobs.Get(
		context.Background(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.PortingOrderActivationJobGetParams{
			ID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", activationJob.Data)

Returns: activate_at (date-time), activation_type (enum: scheduled, on-demand), activation_windows (array[object]), created_at (date-time), id (uuid), record_type (string), status (enum: created, in-process, completed, failed), updated_at (date-time)

Update a porting activation job

Updates the activation time of a porting activation job.

PATCH /porting_orders/{id}/activation_jobs/{activationJobId}

	activationJob, err := client.PortingOrders.ActivationJobs.Update(
		context.Background(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.PortingOrderActivationJobUpdateParams{
			ID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", activationJob.Data)

Returns: activate_at (date-time), activation_type (enum: scheduled, on-demand), activation_windows (array[object]), created_at (date-time), id (uuid), record_type (string), status (enum: created, in-process, completed, failed), updated_at (date-time)

List additional documents

Returns a list of additional documents for a porting order.

GET /porting_orders/{id}/additional_documents

	page, err := client.PortingOrders.AdditionalDocuments.List(
		context.Background(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.PortingOrderAdditionalDocumentListParams{},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)

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-porting-in-go
Source
github.com/team-telnyx/ai