Traffic Type
| cURL | Python | PHP | Node | Ruby | Portal |
cURL
Overview
This feature allows a user to select if an eligible number will be routed to an end user as Application-to-Person (A2P) or Person-to-Person (P2P) traffic. Number eligibility is programatically determined by Telnyx based on the observed messaging use case over a specified period of time. All new numbers will initially be designated as A2P traffic until Telnyx has had sufficient time to monitor the traffic profile. If a number is deemed to be eligible for P2P traffic, users will have the option to update their number accordingly.
Features
Selecting a traffic type that aligns with the number's messaging use case will improve message deliverability. The P2P traffic type will also allow customers to send messages internationally — and at a different price than the A2P traffic type. Currently, MMS is only available with the the A2P Traffic Type.
Note:
If you are sending a message internationally from an A2P enabled longcode, we will automatically fail over to alphanumeric routes using a generic Sender
ID.
Managing Traffic Type Using the Telnyx API
Checking a TN's Current Traffic Type
To see what traffic a number is currently designated as via the API:
curl -X GET \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--header "Authorization: Bearer YOUR_API_KEY" \
"https://api.telnyx.com/v2/messaging_phone_numbers/{YOUR_MESSAGING_PHONE_NUMBER}"
Example Response
{
"record_type": "messaging_phone_number",
"id": "1826003884872261711",
"phone_number": "+13125550001",
"organization_id": "a9b37e61-32bc-4a03-bf90-080c3b55db6f",
"messaging_profile_id": "16fd2706-8baf-433b-82eb-8c7fada847da",
"created_at": "2019-11-06T03:20:05.680Z",
"updated_at": "2019-11-06T03:20:05.680Z",
"country_code": "US",
"type": "longcode",
"traffic_type": "P2P",
"messaging_product": "P2P",
"health" : {
"message_count": 85,
"inbound_outbound_ratio": 0.43,
"success_ratio": 0.95,
"spam_ratio": 0.03
},
"eligible_messaging_products": ["A2P", "P2P"],
"features": {
"sms": {
"domestic_two_way": true,
"international_inbound": true,
"international_outbound": true
},
"mms": {}
}
}
Looking at the messaging_product
will tell you what messaging product the number is currently registered on. In the above example, the phone number is registered as an P2P
number.
Requesting a traffic type change
You can confirm that you're number is eligible or changing messaging products by looking at eligible_messaging_products
. In this case, the number is eligible for the P2P
messaging product. So, we will be requesting a change from the A2P
product to the P2P
product.
curl -X PATCH \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--header "Authorization: Bearer YOUR_API_KEY" \
--data '{"messaging_product":"P2P"}' \
"https://api.telnyx.com/v2/messaging_phone_numbers/{YOUR_MESSAGING_PHONE_NUMBER}"
Example response
{
"record_type": "messaging_phone_number",
"id": "1826003884872261711",
"phone_number": "+13125550001",
"organization_id": "a9b37e61-32bc-4a03-bf90-080c3b55db6f",
"messaging_profile_id": "16fd2706-8baf-433b-82eb-8c7fada847da",
"created_at": "2019-11-06T03:20:05.680Z",
"updated_at": "2019-11-06T03:20:05.680Z",
"country_code": "US",
"type": "longcode",
"traffic_type": "A2P",
"messaging_product": "A2P",
"health" : {
"message_count": 85,
"inbound_outbound_ratio": 0.43,
"success_ratio": 0.95,
"spam_ratio": 0.03
},
"eligible_messaging_products": ["A2P", "P2P"],
"features": {
"sms": {
"domestic_two_way": true,
"international_inbound": false,
"international_outbound": false
},
"mms": {
"domestic_two_way": true,
"international_inbound": false,
"international_outbound": false
}
}
}
Note: that a few things have changed because of the messaging product change. The
traffic_type
is nowP2P
. This was what we intended to do. Note that we've also lost domestic two_way MMS support, but we've gained international_inbound and international_outbound support for SMS. Changing messaging products may also affect the price per message sent/received.
Python
Overview
This feature allows a user to select if an eligible number will be routed to an end user as Application-to-Person (A2P) or Person-to-Person (P2P) traffic. Number eligibility is programatically determined by Telnyx based on the observed messaging use case over a specified period of time. All new numbers will initially be designated as A2P traffic until Telnyx has had sufficient time to monitor the traffic profile. If a number is deemed to be eligible for P2P traffic, users will have the option to update their number accordingly.
Features
Selecting a traffic type that aligns with the number's messaging use case will improve message deliverability. The P2P traffic type will also allow customers to send messages internationally — and at a different price than the A2P traffic type. Currently, MMS is only available with the the A2P Traffic Type.
Note:
If you are sending a message internationally from an A2P enabled longcode, we will automatically fail over to alphanumeric routes using a generic Sender
ID.
Managing Traffic Type Using the Telnyx API
Checking a TN's Current Traffic Type
To see what traffic a number is currently designated as via the API:
import telnyx
telnyx.api_key = "API_KEY"
telnyx.MessagingPhoneNumbers.retrieve(
{
'phone_number': '+13125550001'
},
Example Response
{
"record_type": "messaging_phone_number",
"id": "1826003884872261711",
"phone_number": "+13125550001",
"organization_id": "a9b37e61-32bc-4a03-bf90-080c3b55db6f",
"messaging_profile_id": "16fd2706-8baf-433b-82eb-8c7fada847da",
"created_at": "2019-11-06T03:20:05.680Z",
"updated_at": "2019-11-06T03:20:05.680Z",
"country_code": "US",
"type": "longcode",
"traffic_type": "P2P",
"messaging_product": "P2P",
"health" : {
"message_count": 85,
"inbound_outbound_ratio": 0.43,
"success_ratio": 0.95,
"spam_ratio": 0.03
},
"eligible_messaging_products": ["A2P", "P2P"],
"features": {
"sms": {
"domestic_two_way": true,
"international_inbound": true,
"international_outbound": true
},
"mms": {}
}
}
Looking at the messaging_product
will tell you what messaging product the number is currently registered on. In the above example, the phone number is registered as an P2P
number.
Requesting a traffic type change
You can confirm that you're number is eligible or changing messaging products by looking at eligible_messaging_products
. In this case, the number is eligible for the P2P
messaging product. So, we will be requesting a change from the A2P
product to the P2P
product.
import telnyx
telnyx.api_key = "API_KEY"
res = telnyx.MessagingPhoneNumber.retrieve("+13125550001")
res.messaging_product = "P2P"
Example response
{
"record_type": "messaging_phone_number",
"id": "1826003884872261711",
"phone_number": "+13125550001",
"organization_id": "a9b37e61-32bc-4a03-bf90-080c3b55db6f",
"messaging_profile_id": "16fd2706-8baf-433b-82eb-8c7fada847da",
"created_at": "2019-11-06T03:20:05.680Z",
"updated_at": "2019-11-06T03:20:05.680Z",
"country_code": "US",
"type": "longcode",
"traffic_type": "A2P",
"messaging_product": "A2P",
"health" : {
"message_count": 85,
"inbound_outbound_ratio": 0.43,
"success_ratio": 0.95,
"spam_ratio": 0.03
},
"eligible_messaging_products": ["A2P", "P2P"],
"features": {
"sms": {
"domestic_two_way": true,
"international_inbound": false,
"international_outbound": false
},
"mms": {
"domestic_two_way": true,
"international_inbound": false,
"international_outbound": false
}
}
}
Note: that a few things have changed because of the messaging product change. The
traffic_type
is nowP2P
. This was what we intended to do. Note that we've also lost domestic two_way MMS support, but we've gained international_inbound and international_outbound support for SMS. Changing messaging products may also affect the price per message sent/received.
PHP
Overview
This feature allows a user to select if an eligible number will be routed to an end user as Application-to-Person (A2P) or Person-to-Person (P2P) traffic. Number eligibility is programatically determined by Telnyx based on the observed messaging use case over a specified period of time. All new numbers will initially be designated as A2P traffic until Telnyx has had sufficient time to monitor the traffic profile. If a number is deemed to be eligible for P2P traffic, users will have the option to update their number accordingly.
Features
Selecting a traffic type that aligns with the number's messaging use case will improve message deliverability. The P2P traffic type will also allow customers to send messages internationally — and at a different price than the A2P traffic type. Currently, MMS is only available with the the A2P Traffic Type.
Note:
If you are sending a message internationally from an A2P enabled longcode, we will automatically fail over to alphanumeric routes using a generic Sender
ID.
Managing Traffic Type Using the Telnyx API
Checking a TN's current traffic type
To see what traffic a number is currently designated as via the API:
\Telnyx\Telnyx::setApiKey('YOUR_API_KEY_HERE');
$phoneNumber = \Telnyx\PhoneNumber::Retrieve("uuid");
$phoneNumber->messaging();
Example Response
{
"record_type": "messaging_phone_number",
"id": "1826003884872261711",
"phone_number": "+13125550001",
"organization_id": "a9b37e61-32bc-4a03-bf90-080c3b55db6f",
"messaging_profile_id": "16fd2706-8baf-433b-82eb-8c7fada847da",
"created_at": "2019-11-06T03:20:05.680Z",
"updated_at": "2019-11-06T03:20:05.680Z",
"country_code": "US",
"type": "longcode",
"traffic_type": "P2P",
"messaging_product": "P2P",
"health" : {
"message_count": 85,
"inbound_outbound_ratio": 0.43,
"success_ratio": 0.95,
"spam_ratio": 0.03
},
"eligible_messaging_products": ["A2P", "P2P"],
"features": {
"sms": {
"domestic_two_way": true,
"international_inbound": true,
"international_outbound": true
},
"mms": {}
}
}
Looking at the messaging_product
will tell you what messaging product the number is currently registered on. In the above example, the phone number is registered as an P2P
number.
Requesting a traffic type change
You can confirm that you're number is eligible or changing messaging products by looking at eligible_messaging_products
. In this case, the number is eligible for the P2P
messaging product. So, we will be requesting a change from the A2P
product to the P2P
product.
\Telnyx\Telnyx::setApiKey('YOUR_API_KEY_HERE');
$phoneNumber = \Telnyx\PhoneNumber::Retrieve("uuid");
$phoneNumber->update_messaging(["messaging_product" => "P2P"]);
Example response
{
"record_type": "messaging_phone_number",
"id": "1826003884872261711",
"phone_number": "+13125550001",
"organization_id": "a9b37e61-32bc-4a03-bf90-080c3b55db6f",
"messaging_profile_id": "16fd2706-8baf-433b-82eb-8c7fada847da",
"created_at": "2019-11-06T03:20:05.680Z",
"updated_at": "2019-11-06T03:20:05.680Z",
"country_code": "US",
"type": "longcode",
"traffic_type": "A2P",
"messaging_product": "A2P",
"health" : {
"message_count": 85,
"inbound_outbound_ratio": 0.43,
"success_ratio": 0.95,
"spam_ratio": 0.03
},
"eligible_messaging_products": ["A2P", "P2P"],
"features": {
"sms": {
"domestic_two_way": true,
"international_inbound": false,
"international_outbound": false
},
"mms": {
"domestic_two_way": true,
"international_inbound": false,
"international_outbound": false
}
}
}
Note: that a few things have changed because of the messaging product change. The
traffic_type
is nowP2P
. This was what we intended to do. Note that we've also lost domestic two_way MMS support, but we've gained international_inbound and international_outbound support for SMS. Changing messaging products may also affect the price per message sent/received.
Node
Overview
This feature allows a user to select if an eligible number will be routed to an end user as Application-to-Person (A2P) or Person-to-Person (P2P) traffic. Number eligibility is programatically determined by Telnyx based on the observed messaging use case over a specified period of time. All new numbers will initially be designated as A2P traffic until Telnyx has had sufficient time to monitor the traffic profile. If a number is deemed to be eligible for P2P traffic, users will have the option to update their number accordingly.