Add phone numbers to a DIR
Register phone numbers under a DIR. The enterprise is resolved server-side from the DIR id. Same body, failure modes, and batch semantics whichever path form you use.
Pricing: This is a billable action. See https://telnyx.com/pricing/numbers for current pricing.
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.dir.phoneNumbers.add('16635d38-75a6-4481-82e8-69af60e05011', {
documents: [
{
document_id: '2a7e8337-e803-4057-a4ae-26c40eb0bc6c',
document_type: 'letter_of_authorization',
description: 'LOA authorising Telnyx to register these numbers under the DIR.',
},
],
phone_numbers: ['+19493253498', '+12134445566'],
});
console.log(response.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
)
response = client.dir.phone_numbers.add(
dir_id="16635d38-75a6-4481-82e8-69af60e05011",
documents=[{
"document_id": "2a7e8337-e803-4057-a4ae-26c40eb0bc6c",
"document_type": "letter_of_authorization",
"description": "LOA authorising Telnyx to register these numbers under the DIR.",
}],
phone_numbers=["+19493253498", "+12134445566"],
)
print(response.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"),
)
response, err := client.Dir.PhoneNumbers.Add(
context.TODO(),
"16635d38-75a6-4481-82e8-69af60e05011",
telnyx.DirPhoneNumberAddParams{
Documents: []telnyx.DirPhoneNumberAddParamsDocument{{
DocumentID: "2a7e8337-e803-4057-a4ae-26c40eb0bc6c",
DocumentType: "letter_of_authorization",
Description: telnyx.String("LOA authorising Telnyx to register these numbers under the DIR."),
}},
PhoneNumbers: []string{"+19493253498", "+12134445566"},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.dir.phonenumbers.PhoneNumberAddParams;
import com.telnyx.sdk.models.dir.phonenumbers.PhoneNumberAddResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
PhoneNumberAddParams params = PhoneNumberAddParams.builder()
.dirId("16635d38-75a6-4481-82e8-69af60e05011")
.addDocument(PhoneNumberAddParams.Document.builder()
.documentId("2a7e8337-e803-4057-a4ae-26c40eb0bc6c")
.documentType(PhoneNumberAddParams.Document.DocumentType.LETTER_OF_AUTHORIZATION)
.build())
.addPhoneNumber("+19493253498")
.addPhoneNumber("+12134445566")
.build();
PhoneNumberAddResponse response = client.dir().phoneNumbers().add(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.dir.phone_numbers.add(
"16635d38-75a6-4481-82e8-69af60e05011",
documents: [{document_id: "2a7e8337-e803-4057-a4ae-26c40eb0bc6c", document_type: :letter_of_authorization}],
phone_numbers: ["+19493253498", "+12134445566"]
)
puts(response)<?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 {
$response = $client->dir->phoneNumbers->add(
'16635d38-75a6-4481-82e8-69af60e05011',
documents: [
[
'documentID' => '2a7e8337-e803-4057-a4ae-26c40eb0bc6c',
'documentType' => 'letter_of_authorization',
'description' => 'LOA authorising Telnyx to register these numbers under the DIR.',
],
],
phoneNumbers: ['+19493253498', '+12134445566'],
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx dir:phone-numbers add \
--api-key 'My API Key' \
--dir-id 16635d38-75a6-4481-82e8-69af60e05011 \
--document '{document_id: 2a7e8337-e803-4057-a4ae-26c40eb0bc6c, document_type: letter_of_authorization}' \
--phone-number "'+19493253498'" \
--phone-number "'+12134445566'"curl --request POST \
--url https://api.telnyx.com/v2/dir/{dir_id}/phone_numbers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone_numbers": [
"+19493253498",
"+12134445566"
],
"documents": [
{
"document_id": "2a7e8337-e803-4057-a4ae-26c40eb0bc6c",
"document_type": "letter_of_authorization",
"description": "LOA authorising Telnyx to register these numbers under the DIR."
}
]
}
'{
"data": [
{
"id": "1f56eb76-4078-4af7-ad4d-564b027256ee",
"dir_id": "16635d38-75a6-4481-82e8-69af60e05011",
"enterprise_id": "4a6192a4-573d-446d-b3ce-aff9117272a6",
"phone_number": "+19493253498",
"batch_id": "0a4b1f5e-2f12-4c0c-9a98-9b3a7d8b8e62",
"loa_document_id": null,
"status": "submitted",
"rejection_reason": {
"code": "documentation_incomplete",
"title": "Documentation incomplete",
"detail": "Provided documents do not establish business identity.",
"message": "Please re-upload a clearer scan of the certificate."
},
"created_at": "2026-04-26T18:11:42.850928Z",
"updated_at": "2026-04-26T18:12:11.123456Z",
"verified_at": "2026-04-26T18:12:11.123456Z"
}
]
}Authorizations
Telnyx API key. Generate one at https://portal.telnyx.com/#/app/api-keys.
Path Parameters
The DIR id. Lowercase UUID.
"16635d38-75a6-4481-82e8-69af60e05011"
Body
1–15 phone numbers in E.164 format. 10-digit US numbers are auto-prefixed with 1.
1 - 15 elementsSupporting documents covering this batch. At least one entry with document_type: letter_of_authorization is required - the LOA authorises Telnyx to register these numbers under the DIR. Each document_id must come from the Telnyx Documents API. Additional document types (e.g. business registration) may be included alongside the LOA.
1 - 20 elementsShow child attributes
Show child attributes
Response
Bulk-add response. Inspect both added and errors.
Bulk-add success response (HTTP 201). All numbers in the request were accepted into a single new batch. Every entry in data shares the same batch_id - read it from any element to obtain the batch id for subsequent GET .../phone_number_batches/{batch_id} calls. If any number in the request fails (schema-invalid, not in inventory, already attached to another DIR, etc.) the entire request is rejected with HTTP 400 and the canonical Telnyx error envelope; the success body described here is therefore an all-or-nothing payload.
Phone numbers accepted into the new batch. List order mirrors the request order. Each element shares the same batch_id.
Show child attributes
Show child attributes
Was this page helpful?
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.dir.phoneNumbers.add('16635d38-75a6-4481-82e8-69af60e05011', {
documents: [
{
document_id: '2a7e8337-e803-4057-a4ae-26c40eb0bc6c',
document_type: 'letter_of_authorization',
description: 'LOA authorising Telnyx to register these numbers under the DIR.',
},
],
phone_numbers: ['+19493253498', '+12134445566'],
});
console.log(response.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
)
response = client.dir.phone_numbers.add(
dir_id="16635d38-75a6-4481-82e8-69af60e05011",
documents=[{
"document_id": "2a7e8337-e803-4057-a4ae-26c40eb0bc6c",
"document_type": "letter_of_authorization",
"description": "LOA authorising Telnyx to register these numbers under the DIR.",
}],
phone_numbers=["+19493253498", "+12134445566"],
)
print(response.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"),
)
response, err := client.Dir.PhoneNumbers.Add(
context.TODO(),
"16635d38-75a6-4481-82e8-69af60e05011",
telnyx.DirPhoneNumberAddParams{
Documents: []telnyx.DirPhoneNumberAddParamsDocument{{
DocumentID: "2a7e8337-e803-4057-a4ae-26c40eb0bc6c",
DocumentType: "letter_of_authorization",
Description: telnyx.String("LOA authorising Telnyx to register these numbers under the DIR."),
}},
PhoneNumbers: []string{"+19493253498", "+12134445566"},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.dir.phonenumbers.PhoneNumberAddParams;
import com.telnyx.sdk.models.dir.phonenumbers.PhoneNumberAddResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
PhoneNumberAddParams params = PhoneNumberAddParams.builder()
.dirId("16635d38-75a6-4481-82e8-69af60e05011")
.addDocument(PhoneNumberAddParams.Document.builder()
.documentId("2a7e8337-e803-4057-a4ae-26c40eb0bc6c")
.documentType(PhoneNumberAddParams.Document.DocumentType.LETTER_OF_AUTHORIZATION)
.build())
.addPhoneNumber("+19493253498")
.addPhoneNumber("+12134445566")
.build();
PhoneNumberAddResponse response = client.dir().phoneNumbers().add(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.dir.phone_numbers.add(
"16635d38-75a6-4481-82e8-69af60e05011",
documents: [{document_id: "2a7e8337-e803-4057-a4ae-26c40eb0bc6c", document_type: :letter_of_authorization}],
phone_numbers: ["+19493253498", "+12134445566"]
)
puts(response)<?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 {
$response = $client->dir->phoneNumbers->add(
'16635d38-75a6-4481-82e8-69af60e05011',
documents: [
[
'documentID' => '2a7e8337-e803-4057-a4ae-26c40eb0bc6c',
'documentType' => 'letter_of_authorization',
'description' => 'LOA authorising Telnyx to register these numbers under the DIR.',
],
],
phoneNumbers: ['+19493253498', '+12134445566'],
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx dir:phone-numbers add \
--api-key 'My API Key' \
--dir-id 16635d38-75a6-4481-82e8-69af60e05011 \
--document '{document_id: 2a7e8337-e803-4057-a4ae-26c40eb0bc6c, document_type: letter_of_authorization}' \
--phone-number "'+19493253498'" \
--phone-number "'+12134445566'"curl --request POST \
--url https://api.telnyx.com/v2/dir/{dir_id}/phone_numbers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone_numbers": [
"+19493253498",
"+12134445566"
],
"documents": [
{
"document_id": "2a7e8337-e803-4057-a4ae-26c40eb0bc6c",
"document_type": "letter_of_authorization",
"description": "LOA authorising Telnyx to register these numbers under the DIR."
}
]
}
'{
"data": [
{
"id": "1f56eb76-4078-4af7-ad4d-564b027256ee",
"dir_id": "16635d38-75a6-4481-82e8-69af60e05011",
"enterprise_id": "4a6192a4-573d-446d-b3ce-aff9117272a6",
"phone_number": "+19493253498",
"batch_id": "0a4b1f5e-2f12-4c0c-9a98-9b3a7d8b8e62",
"loa_document_id": null,
"status": "submitted",
"rejection_reason": {
"code": "documentation_incomplete",
"title": "Documentation incomplete",
"detail": "Provided documents do not establish business identity.",
"message": "Please re-upload a clearer scan of the certificate."
},
"created_at": "2026-04-26T18:11:42.850928Z",
"updated_at": "2026-04-26T18:12:11.123456Z",
"verified_at": "2026-04-26T18:12:11.123456Z"
}
]
}