Get an available sending number
Returns the best available line (E.164) to send from, applying smart
number assignment. Optionally pass to recipients to make the choice
“sticky” — reusing the line an existing chat with those recipients is
already on. Without to, the best available line is chosen, always
preferring lines with a healthier reputation.
This does not reserve the line. Without to, the least-recently-used
available line is returned — suggestions and your own sends (including
an explicit from on chat creation) both count as use, so successive
calls cycle through your available lines and traffic spreads evenly.
Pass the returned phone_number as from when you create the chat to
guarantee the same line.
Also returns vcf_url: a time-limited link to a vCard (.vcf) for the
chosen line, carrying its contact card (name/photo) with the chosen
number as the primary TEL and the partner’s other available lines as
backups. Share it with recipients so they can save the line as a contact.
Lines you pass in exclude_from are left out of the vCard too.
Get an available sending number
package main
import (
"context"
"fmt"
"github.com/linq-team/linq-go"
"github.com/linq-team/linq-go/option"
)
func main() {
client := linqgo.NewClient(
option.WithAPIKey("My API Key"),
)
availableNumber, err := client.AvailableNumber.Get(context.TODO(), linqgo.AvailableNumberGetParams{
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", availableNumber.PhoneNumber)
}
{
"phone_number": "+12025551234",
"vcf_url": "https://s3.us-east-1.amazonaws.com/linq-attachments/vcf/9716d5c5/12025551234.vcf?X-Amz-Signature=..."
}{
"error": {
"status": 401,
"code": 2004,
"message": "Unauthorized - missing or invalid authentication token",
"doc_url": "https://docs.linqapp.com/error/codes/2xxx/2004/"
},
"success": false
}{
"error": {
"status": 500,
"code": 3006,
"message": "Internal server error",
"doc_url": "https://docs.linqapp.com/error/codes/3xxx/3006/"
},
"success": false
}Returns Examples
{
"phone_number": "+12025551234",
"vcf_url": "https://s3.us-east-1.amazonaws.com/linq-attachments/vcf/9716d5c5/12025551234.vcf?X-Amz-Signature=..."
}{
"error": {
"status": 401,
"code": 2004,
"message": "Unauthorized - missing or invalid authentication token",
"doc_url": "https://docs.linqapp.com/error/codes/2xxx/2004/"
},
"success": false
}{
"error": {
"status": 500,
"code": 3006,
"message": "Internal server error",
"doc_url": "https://docs.linqapp.com/error/codes/3xxx/3006/"
},
"success": false
}