Create a traffic policy profile
Create a new traffic policy profile. At least one of services, ip_ranges, or domains must be provided.
POST
/
traffic
/
policy
/
profiles
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const trafficPolicyProfile = await client.trafficPolicyProfiles.create({ type: 'whitelist' });
console.log(trafficPolicyProfile.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
)
traffic_policy_profile = client.traffic_policy_profiles.create(
type="whitelist",
)
print(traffic_policy_profile.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"),
)
trafficPolicyProfile, err := client.TrafficPolicyProfiles.New(context.TODO(), telnyx.TrafficPolicyProfileNewParams{
Type: telnyx.TrafficPolicyProfileNewParamsTypeWhitelist,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", trafficPolicyProfile.Data)
}package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.trafficpolicyprofiles.TrafficPolicyProfileCreateParams;
import com.telnyx.sdk.models.trafficpolicyprofiles.TrafficPolicyProfileCreateResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
TrafficPolicyProfileCreateParams params = TrafficPolicyProfileCreateParams.builder()
.type(TrafficPolicyProfileCreateParams.Type.WHITELIST)
.build();
TrafficPolicyProfileCreateResponse trafficPolicyProfile = client.trafficPolicyProfiles().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
traffic_policy_profile = telnyx.traffic_policy_profiles.create(type: :whitelist)
puts(traffic_policy_profile)<?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 {
$trafficPolicyProfile = $client->trafficPolicyProfiles->create(
type: 'whitelist',
domains: ['www.hbomax.com', 'netflix.com'],
ipRanges: ['10.64.0.0/24', '10.64.0.0/25'],
limitBwKbps: 512,
services: ['service_123', 'service_456'],
);
var_dump($trafficPolicyProfile);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx traffic-policy-profiles create \
--api-key 'My API Key' \
--type whitelistcurl --request POST \
--url https://api.telnyx.com/v2/traffic/policy/profiles \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "whitelist",
"services": [
"service_123",
"service_456"
],
"ip_ranges": [
"10.64.0.0/24",
"10.64.0.0/25"
],
"domains": [
"www.hbomax.com",
"netflix.com"
],
"limit_bw_kbps": 512
}
'{
"data": {
"id": "6a09cdc3-8948-47f0-aa62-74ac943d6c58",
"record_type": "traffic_policy_profile",
"type": "whitelist",
"services": [
"service_123",
"service_456"
],
"ip_ranges": [
"10.64.0.0/24",
"10.64.0.0/25"
],
"domains": [
"www.hbomax.com",
"netflix.com"
],
"limit_bw_kbps": 512,
"created_at": "2018-02-02T22:25:27.521Z",
"updated_at": "2018-02-02T22:25:27.521Z"
}
}{
"errors": [
{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}
]
}{
"errors": [
{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
The type of the traffic policy profile.
Available options:
whitelist, blacklist Example:
"whitelist"
Array of PCEF service IDs to include in the profile.
Example:
["service_123", "service_456"]
Array of IP ranges in CIDR notation.
Example:
["10.64.0.0/24", "10.64.0.0/25"]
Array of domain names.
Example:
["www.hbomax.com", "netflix.com"]
Bandwidth limit in kbps. Must be 512 or 1024.
Available options:
512, 1024 Example:
512
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 trafficPolicyProfile = await client.trafficPolicyProfiles.create({ type: 'whitelist' });
console.log(trafficPolicyProfile.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
)
traffic_policy_profile = client.traffic_policy_profiles.create(
type="whitelist",
)
print(traffic_policy_profile.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"),
)
trafficPolicyProfile, err := client.TrafficPolicyProfiles.New(context.TODO(), telnyx.TrafficPolicyProfileNewParams{
Type: telnyx.TrafficPolicyProfileNewParamsTypeWhitelist,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", trafficPolicyProfile.Data)
}package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.trafficpolicyprofiles.TrafficPolicyProfileCreateParams;
import com.telnyx.sdk.models.trafficpolicyprofiles.TrafficPolicyProfileCreateResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
TrafficPolicyProfileCreateParams params = TrafficPolicyProfileCreateParams.builder()
.type(TrafficPolicyProfileCreateParams.Type.WHITELIST)
.build();
TrafficPolicyProfileCreateResponse trafficPolicyProfile = client.trafficPolicyProfiles().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
traffic_policy_profile = telnyx.traffic_policy_profiles.create(type: :whitelist)
puts(traffic_policy_profile)<?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 {
$trafficPolicyProfile = $client->trafficPolicyProfiles->create(
type: 'whitelist',
domains: ['www.hbomax.com', 'netflix.com'],
ipRanges: ['10.64.0.0/24', '10.64.0.0/25'],
limitBwKbps: 512,
services: ['service_123', 'service_456'],
);
var_dump($trafficPolicyProfile);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx traffic-policy-profiles create \
--api-key 'My API Key' \
--type whitelistcurl --request POST \
--url https://api.telnyx.com/v2/traffic/policy/profiles \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "whitelist",
"services": [
"service_123",
"service_456"
],
"ip_ranges": [
"10.64.0.0/24",
"10.64.0.0/25"
],
"domains": [
"www.hbomax.com",
"netflix.com"
],
"limit_bw_kbps": 512
}
'{
"data": {
"id": "6a09cdc3-8948-47f0-aa62-74ac943d6c58",
"record_type": "traffic_policy_profile",
"type": "whitelist",
"services": [
"service_123",
"service_456"
],
"ip_ranges": [
"10.64.0.0/24",
"10.64.0.0/25"
],
"domains": [
"www.hbomax.com",
"netflix.com"
],
"limit_bw_kbps": 512,
"created_at": "2018-02-02T22:25:27.521Z",
"updated_at": "2018-02-02T22:25:27.521Z"
}
}{
"errors": [
{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}
]
}{
"errors": [
{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}
]
}