- name
- telnyx-porting-in-go
- description
- Port phone numbers into Telnyx. Check portability, create port orders, upload LOA documents, and track porting status. This skill provides Go SDK examples.
- metadata
- {"author":"telnyx","product":"porting-in","language":"go","generated_by":"telnyx-ext-skills-generator"}
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
# Telnyx Porting In - Go
## Installation
```bash
go get github.com/team-telnyx/telnyx-go
```
## Setup
```go
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.
## List all porting events
Returns a list of all porting events.
`GET /porting/events`
```go
page, err := client.Porting.Events.List(context.TODO(), telnyx.PortingEventListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
```
## Show a porting event
Show a specific porting event.
`GET /porting/events/{id}`
```go
event, err := client.Porting.Events.Get(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", event.Data)
```
## Republish a porting event
Republish a specific porting event.
`POST /porting/events/{id}/republish`
```go
err := client.Porting.Events.Republish(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
```
## Preview the LOA configuration parameters
Preview the LOA template that would be generated without need to create LOA configuration.
`POST /porting/loa_configuration_preview`
```go
response, err := client.Porting.LoaConfigurations.Preview0(context.TODO(), telnyx.PortingLoaConfigurationPreview0Params{
Address: telnyx.PortingLoaConfigurationPreview0ParamsAddress{
City: "Austin",
CountryCode: "US",
State: "TX",
StreetAddress: "600 Congress Avenue",
ZipCode: "78701",
},
CompanyName: "Telnyx",
Contact: telnyx.PortingLoaConfigurationPreview0ParamsContact{
Email: "testing@telnyx.com",
PhoneNumber: "+12003270001",
},
Logo: telnyx.PortingLoaConfigurationPreview0ParamsLogo{
DocumentID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
},
Name: "My LOA Configuration",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response)
```
## List LOA configurations
List the LOA configurations.
`GET /porting/loa_configurations`
```go
page, err := client.Porting.LoaConfigurations.List(context.TODO(), telnyx.PortingLoaConfigurationListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
```
## Create a LOA configuration
Create a LOA configuration.
`POST /porting/loa_configurations`
```go
loaConfiguration, err := client.Porting.LoaConfigurations.New(context.TODO(), 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 {
panic(err.Error())
}
fmt.Printf("%+v\n", loaConfiguration.Data)
```
## Retrieve a LOA configuration
Retrieve a specific LOA configuration.
`GET /porting/loa_configurations/{id}`
```go
loaConfiguration, err := client.Porting.LoaConfigurations.Get(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", loaConfiguration.Data)
```
## Update a LOA configuration
Update a specific LOA configuration.
`PATCH /porting/loa_configurations/{id}`
```go
loaConfiguration, err := client.Porting.LoaConfigurations.Update(
context.TODO(),
"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 {
panic(err.Error())
}
fmt.Printf("%+v\n", loaConfiguration.Data)
```
## Delete a LOA configuration
Delete a specific LOA configuration.
`DELETE /porting/loa_configurations/{id}`
```go
err := client.Porting.LoaConfigurations.Delete(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
```
## Preview a LOA configuration
Preview a specific LOA configuration.
`GET /porting/loa_configurations/{id}/preview`
```go
response, err := client.Porting.LoaConfigurations.Preview1(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response)
```
## List all porting orders
Returns a list of your porting order.
`GET /porting_orders`
```go
page, err := client.PortingOrders.List(context.TODO(), telnyx.PortingOrderListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
```
## Create a porting order
Creates a new porting order object.
`POST /porting_orders` — Required: `phone_numbers`
```go
portingOrder, err := client.PortingOrders.New(context.TODO(), telnyx.PortingOrderNewParams{
PhoneNumbers: []string{"+13035550000", "+13035550001", "+13035550002"},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", portingOrder.Data)
```
## Retrieve a porting order
Retrieves the details of an existing porting order.
`GET /porting_orders/{id}`
```go
portingOrder, err := client.PortingOrders.Get(
context.TODO(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.PortingOrderGetParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", portingOrder.Data)
```
## Edit a porting order
Edits the details of an existing porting order.
`PATCH /porting_orders/{id}`
```go
portingOrder, err := client.PortingOrders.Update(
context.TODO(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.PortingOrderUpdateParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", portingOrder.Data)
```
## Delete a porting order
Deletes an existing porting order.
`DELETE /porting_orders/{id}`
```go
err := client.PortingOrders.Delete(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
```
## Activate every number in a porting order asynchronously.
Activate each number in a porting order asynchronously.
`POST /porting_orders/{id}/actions/activate`
```go
response, err := client.PortingOrders.Actions.Activate(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
```
## Cancel a porting order
`POST /porting_orders/{id}/actions/cancel`
```go
response, err := client.PortingOrders.Actions.Cancel(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
```
## Submit a porting order.
Confirm and submit your porting order.
`POST /porting_orders/{id}/actions/confirm`
```go
response, err := client.PortingOrders.Actions.Confirm(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
```
## Share a porting order
Creates a sharing token for a porting order.
`POST /porting_orders/{id}/actions/share`
```go
response, err := client.PortingOrders.Actions.Share(
context.TODO(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.PortingOrderActionShareParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
```
## List all porting activation jobs
Returns a list of your porting activation jobs.
`GET /porting_orders/{id}/activation_jobs`
```go
page, err := client.PortingOrders.ActivationJobs.List(
context.TODO(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.PortingOrderActivationJobListParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
```
## Retrieve a porting activation job
Returns a porting activation job.
`GET /porting_orders/{id}/activation_jobs/{activationJobId}`
```go
activationJob, err := client.PortingOrders.ActivationJobs.Get(
context.TODO(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.PortingOrderActivationJobGetParams{
ID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", activationJob.Data)
```
## Update a porting activation job
Updates the activation time of a porting activation job.
`PATCH /porting_orders/{id}/activation_jobs/{activationJobId}`
```go
activationJob, err := client.PortingOrders.ActivationJobs.Update(
context.TODO(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.PortingOrderActivationJobUpdateParams{
ID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", activationJob.Data)
```
## List additional documents
Returns a list of additional documents for a porting order.
`GET /porting_orders/{id}/additional_documents`
```go
page, err := client.PortingOrders.AdditionalDocuments.List(
context.TODO(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.PortingOrderAdditionalDocumentListParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
```
## Create a list of additional documents
Creates a list of additional documents for a porting order.
`POST /porting_orders/{id}/additional_documents`
```go
additionalDocument, err := client.PortingOrders.AdditionalDocuments.New(
context.TODO(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.PortingOrderAdditionalDocumentNewParams{},
)
if err != nil {
Ver no GitHub