Create a phone number extension
Creates a new phone number extension.
POST
/
porting_orders
/
{porting_order_id}
/
phone_number_extensions
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const phoneNumberExtension = await client.portingOrders.phoneNumberExtensions.create(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{
activation_ranges: [{ end_at: 10, start_at: 1 }],
extension_range: { end_at: 10, start_at: 1 },
porting_phone_number_id: 'f24151b6-3389-41d3-8747-7dd8c681e5e2',
},
);
console.log(phoneNumberExtension.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
)
phone_number_extension = client.porting_orders.phone_number_extensions.create(
porting_order_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
activation_ranges=[{
"end_at": 10,
"start_at": 1,
}],
extension_range={
"end_at": 10,
"start_at": 1,
},
porting_phone_number_id="f24151b6-3389-41d3-8747-7dd8c681e5e2",
)
print(phone_number_extension.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"),
)
phoneNumberExtension, err := client.PortingOrders.PhoneNumberExtensions.New(
context.TODO(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.PortingOrderPhoneNumberExtensionNewParams{
ActivationRanges: []telnyx.PortingOrderPhoneNumberExtensionNewParamsActivationRange{{
EndAt: 10,
StartAt: 1,
}},
ExtensionRange: telnyx.PortingOrderPhoneNumberExtensionNewParamsExtensionRange{
EndAt: 10,
StartAt: 1,
},
PortingPhoneNumberID: "f24151b6-3389-41d3-8747-7dd8c681e5e2",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", phoneNumberExtension.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.phonenumberextensions.PhoneNumberExtensionCreateParams;
import com.telnyx.sdk.models.portingorders.phonenumberextensions.PhoneNumberExtensionCreateResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
PhoneNumberExtensionCreateParams params = PhoneNumberExtensionCreateParams.builder()
.portingOrderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.addActivationRange(PhoneNumberExtensionCreateParams.ActivationRange.builder()
.endAt(10L)
.startAt(1L)
.build())
.extensionRange(PhoneNumberExtensionCreateParams.ExtensionRange.builder()
.endAt(10L)
.startAt(1L)
.build())
.portingPhoneNumberId("f24151b6-3389-41d3-8747-7dd8c681e5e2")
.build();
PhoneNumberExtensionCreateResponse phoneNumberExtension = client.portingOrders().phoneNumberExtensions().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
phone_number_extension = telnyx.porting_orders.phone_number_extensions.create(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
activation_ranges: [{end_at: 10, start_at: 1}],
extension_range: {end_at: 10, start_at: 1},
porting_phone_number_id: "f24151b6-3389-41d3-8747-7dd8c681e5e2"
)
puts(phone_number_extension)<?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 {
$phoneNumberExtension = $client->portingOrders->phoneNumberExtensions->create(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
activationRanges: [['endAt' => 10, 'startAt' => 1]],
extensionRange: ['endAt' => 10, 'startAt' => 1],
portingPhoneNumberID: 'f24151b6-3389-41d3-8747-7dd8c681e5e2',
);
var_dump($phoneNumberExtension);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx porting-orders:phone-number-extensions create \
--api-key 'My API Key' \
--porting-order-id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e \
--activation-range '{end_at: 10, start_at: 1}' \
--extension-range '{end_at: 10, start_at: 1}' \
--porting-phone-number-id f24151b6-3389-41d3-8747-7dd8c681e5e2curl --request POST \
--url https://api.telnyx.com/v2/porting_orders/{porting_order_id}/phone_number_extensions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"porting_phone_number_id": "f24151b6-3389-41d3-8747-7dd8c681e5e2",
"extension_range": {
"start_at": 1,
"end_at": 10
},
"activation_ranges": [
{
"start_at": 1,
"end_at": 10
}
]
}
'{
"data": {
"id": "f24151b6-3389-41d3-8747-7dd8c681e5e2",
"porting_phone_number_id": "f24151b6-3389-41d3-8747-7dd8c681e5e2",
"extension_range": {
"start_at": 1,
"end_at": 10
},
"activation_ranges": [
{
"start_at": 1,
"end_at": 10
}
],
"record_type": "porting_phone_number_extension",
"created_at": "2021-03-19T10:07:15.527Z",
"updated_at": "2021-03-19T10:07:15.527Z"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Identifies the Porting Order associated with the phone number extension
Body
application/json
Identifies the porting phone number associated with this porting phone number extension.
Example:
"f24151b6-3389-41d3-8747-7dd8c681e5e2"
Show child attributes
Show child attributes
Specifies the activation ranges for this porting phone number extension. The activation range must be within the extension range and should not overlap with other activation ranges.
Show child attributes
Show child attributes
Response
Successful response
Show child attributes
Show child attributes
Was this page helpful?
⌘I
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const phoneNumberExtension = await client.portingOrders.phoneNumberExtensions.create(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{
activation_ranges: [{ end_at: 10, start_at: 1 }],
extension_range: { end_at: 10, start_at: 1 },
porting_phone_number_id: 'f24151b6-3389-41d3-8747-7dd8c681e5e2',
},
);
console.log(phoneNumberExtension.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
)
phone_number_extension = client.porting_orders.phone_number_extensions.create(
porting_order_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
activation_ranges=[{
"end_at": 10,
"start_at": 1,
}],
extension_range={
"end_at": 10,
"start_at": 1,
},
porting_phone_number_id="f24151b6-3389-41d3-8747-7dd8c681e5e2",
)
print(phone_number_extension.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"),
)
phoneNumberExtension, err := client.PortingOrders.PhoneNumberExtensions.New(
context.TODO(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.PortingOrderPhoneNumberExtensionNewParams{
ActivationRanges: []telnyx.PortingOrderPhoneNumberExtensionNewParamsActivationRange{{
EndAt: 10,
StartAt: 1,
}},
ExtensionRange: telnyx.PortingOrderPhoneNumberExtensionNewParamsExtensionRange{
EndAt: 10,
StartAt: 1,
},
PortingPhoneNumberID: "f24151b6-3389-41d3-8747-7dd8c681e5e2",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", phoneNumberExtension.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.phonenumberextensions.PhoneNumberExtensionCreateParams;
import com.telnyx.sdk.models.portingorders.phonenumberextensions.PhoneNumberExtensionCreateResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
PhoneNumberExtensionCreateParams params = PhoneNumberExtensionCreateParams.builder()
.portingOrderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.addActivationRange(PhoneNumberExtensionCreateParams.ActivationRange.builder()
.endAt(10L)
.startAt(1L)
.build())
.extensionRange(PhoneNumberExtensionCreateParams.ExtensionRange.builder()
.endAt(10L)
.startAt(1L)
.build())
.portingPhoneNumberId("f24151b6-3389-41d3-8747-7dd8c681e5e2")
.build();
PhoneNumberExtensionCreateResponse phoneNumberExtension = client.portingOrders().phoneNumberExtensions().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
phone_number_extension = telnyx.porting_orders.phone_number_extensions.create(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
activation_ranges: [{end_at: 10, start_at: 1}],
extension_range: {end_at: 10, start_at: 1},
porting_phone_number_id: "f24151b6-3389-41d3-8747-7dd8c681e5e2"
)
puts(phone_number_extension)<?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 {
$phoneNumberExtension = $client->portingOrders->phoneNumberExtensions->create(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
activationRanges: [['endAt' => 10, 'startAt' => 1]],
extensionRange: ['endAt' => 10, 'startAt' => 1],
portingPhoneNumberID: 'f24151b6-3389-41d3-8747-7dd8c681e5e2',
);
var_dump($phoneNumberExtension);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx porting-orders:phone-number-extensions create \
--api-key 'My API Key' \
--porting-order-id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e \
--activation-range '{end_at: 10, start_at: 1}' \
--extension-range '{end_at: 10, start_at: 1}' \
--porting-phone-number-id f24151b6-3389-41d3-8747-7dd8c681e5e2curl --request POST \
--url https://api.telnyx.com/v2/porting_orders/{porting_order_id}/phone_number_extensions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"porting_phone_number_id": "f24151b6-3389-41d3-8747-7dd8c681e5e2",
"extension_range": {
"start_at": 1,
"end_at": 10
},
"activation_ranges": [
{
"start_at": 1,
"end_at": 10
}
]
}
'{
"data": {
"id": "f24151b6-3389-41d3-8747-7dd8c681e5e2",
"porting_phone_number_id": "f24151b6-3389-41d3-8747-7dd8c681e5e2",
"extension_range": {
"start_at": 1,
"end_at": 10
},
"activation_ranges": [
{
"start_at": 1,
"end_at": 10
}
],
"record_type": "porting_phone_number_extension",
"created_at": "2021-03-19T10:07:15.527Z",
"updated_at": "2021-03-19T10:07:15.527Z"
}
}