Skip to main content
POST
/
porting_orders
/
{porting_order_id}
/
associated_phone_numbers
JavaScript
import Telnyx from 'telnyx';

const client = new Telnyx({
  apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});

const associatedPhoneNumber = await client.portingOrders.associatedPhoneNumbers.create(
  '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
  {
    action: 'keep',
    phone_number_range: {},
  },
);

console.log(associatedPhoneNumber.data);
import os
from telnyx import Telnyx

client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
associated_phone_number = client.porting_orders.associated_phone_numbers.create(
porting_order_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
action="keep",
phone_number_range={},
)
print(associated_phone_number.data)
package main

import (
"context"
"fmt"

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

func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
associatedPhoneNumber, err := client.PortingOrders.AssociatedPhoneNumbers.New(
context.TODO(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.PortingOrderAssociatedPhoneNumberNewParams{
Action: telnyx.PortingOrderAssociatedPhoneNumberNewParamsActionKeep,
PhoneNumberRange: telnyx.PortingOrderAssociatedPhoneNumberNewParamsPhoneNumberRange{},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", associatedPhoneNumber.Data)
}
package com.telnyx.sdk.example;

import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.portingorders.associatedphonenumbers.AssociatedPhoneNumberCreateParams;
import com.telnyx.sdk.models.portingorders.associatedphonenumbers.AssociatedPhoneNumberCreateResponse;

public final class Main {
private Main() {}

public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();

AssociatedPhoneNumberCreateParams params = AssociatedPhoneNumberCreateParams.builder()
.portingOrderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.action(AssociatedPhoneNumberCreateParams.Action.KEEP)
.phoneNumberRange(AssociatedPhoneNumberCreateParams.PhoneNumberRange.builder().build())
.build();
AssociatedPhoneNumberCreateResponse associatedPhoneNumber = client.portingOrders().associatedPhoneNumbers().create(params);
}
}
require "telnyx"

telnyx = Telnyx::Client.new(api_key: "My API Key")

associated_phone_number = telnyx.porting_orders.associated_phone_numbers.create(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
action: :keep,
phone_number_range: {}
)

puts(associated_phone_number)
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;

$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');

try {
$associatedPhoneNumber = $client
->portingOrders
->associatedPhoneNumbers
->create(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
action: 'keep',
phoneNumberRange: [
'endAt' => '+441234567899', 'startAt' => '+441234567890'
],
);

var_dump($associatedPhoneNumber);
} catch (APIException $e) {
echo $e->getMessage();
}
telnyx porting-orders:associated-phone-numbers create \
--api-key 'My API Key' \
--porting-order-id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e \
--action keep \
--phone-number-range '{}'
curl --request POST \
--url https://api.telnyx.com/v2/porting_orders/{porting_order_id}/associated_phone_numbers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone_number_range": {
"start_at": "+441234567890",
"end_at": "+441234567899"
},
"action": "keep"
}
'
{
  "data": {
    "id": "f24151b6-3389-41d3-8747-7dd8c681e5e2",
    "porting_order_id": "a24151b6-3389-41d3-8747-7dd8c681e5e2",
    "country_code": "GB",
    "phone_number_type": "local",
    "phone_number_range": {
      "start_at": "+441234567890",
      "end_at": "+441234567899"
    },
    "action": "keep",
    "record_type": "porting_associated_phone_number",
    "created_at": "2021-03-19T10:07:15.527Z",
    "updated_at": "2021-03-19T10:07:15.527Z"
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

porting_order_id
string<uuid>
required

Identifies the Porting Order associated with the phone number

Body

application/json
phone_number_range
object
required
action
enum<string>
required

Specifies the action to take with this phone number during partial porting.

Available options:
keep,
disconnect
Example:

"keep"

Response

Successful response

data
object