Skip to main content
POST
/
10dlc
/
phone_number_campaigns
JavaScript
import Telnyx from 'telnyx';

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

const phoneNumberCampaign = await client.messaging10dlc.phoneNumberCampaigns.create({
  campaignId: '4b300178-131c-d902-d54e-72d90ba1620j',
  phoneNumber: '+18005550199',
});

console.log(phoneNumberCampaign.campaignId);
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_campaign = client.messaging_10dlc.phone_number_campaigns.create(
campaign_id="4b300178-131c-d902-d54e-72d90ba1620j",
phone_number="+18005550199",
)
print(phone_number_campaign.campaign_id)
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"),
)
phoneNumberCampaign, err := client.Messaging10dlc.PhoneNumberCampaigns.New(context.TODO(), telnyx.Messaging10dlcPhoneNumberCampaignNewParams{
PhoneNumberCampaignCreate: telnyx.PhoneNumberCampaignCreateParam{
CampaignID: "4b300178-131c-d902-d54e-72d90ba1620j",
PhoneNumber: "+18005550199",
},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", phoneNumberCampaign.CampaignID)
}
package com.telnyx.sdk.example;

import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.messaging10dlc.phonenumbercampaigns.PhoneNumberCampaign;
import com.telnyx.sdk.models.messaging10dlc.phonenumbercampaigns.PhoneNumberCampaignCreate;

public final class Main {
private Main() {}

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

PhoneNumberCampaignCreate params = PhoneNumberCampaignCreate.builder()
.campaignId("4b300178-131c-d902-d54e-72d90ba1620j")
.phoneNumber("+18005550199")
.build();
PhoneNumberCampaign phoneNumberCampaign = client.messaging10dlc().phoneNumberCampaigns().create(params);
}
}
require "telnyx"

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

phone_number_campaign = telnyx.messaging_10dlc.phone_number_campaigns.create(
campaign_id: "4b300178-131c-d902-d54e-72d90ba1620j",
phone_number: "+18005550199"
)

puts(phone_number_campaign)
<?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 {
$phoneNumberCampaign = $client->messaging10dlc->phoneNumberCampaigns->create(
campaignID: '4b300178-131c-d902-d54e-72d90ba1620j',
phoneNumber: '+18005550199',
);

var_dump($phoneNumberCampaign);
} catch (APIException $e) {
echo $e->getMessage();
}
telnyx messaging-10dlc:phone-number-campaigns create \
--api-key 'My API Key' \
--campaign-id 4b300178-131c-d902-d54e-72d90ba1620j \
--phone-number +18005550199
curl --request POST \
--url https://api.telnyx.com/v2/10dlc/phone_number_campaigns \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phoneNumber": "+18005550199",
"campaignId": "4b300178-131c-d902-d54e-72d90ba1620j"
}
'
{
  "phoneNumber": "+18005550199",
  "campaignId": "<string>",
  "createdAt": "2021-03-08T17:57:48.801186",
  "updatedAt": "2021-03-08T17:57:48.801186",
  "brandId": "7ba705b7-22af-493f-addc-ac04b7ca071c",
  "tcrBrandId": "BBRAND1",
  "tcrCampaignId": "CCAMPA1",
  "telnyxCampaignId": "3008dd9f-66d7-40e0-bf23-bf2d8d1a96ba",
  "assignmentStatus": "ASSIGNED",
  "failureReasons": "<string>"
}
{
"errors": [
{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
}
}
]
}

Authorizations

Authorization
string
header
required

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

Body

application/json
phoneNumber
string
required

The phone number you want to link to a specified campaign.

Example:

"+18005550199"

campaignId
string
required

The ID of the campaign you want to link to the specified phone number.

Example:

"4b300178-131c-d902-d54e-72d90ba1620j"

Response

Successful Response

phoneNumber
string
required
Example:

"+18005550199"

campaignId
string
required

For shared campaigns, this is the TCR campaign ID, otherwise it is the campaign ID

createdAt
string
required
Example:

"2021-03-08T17:57:48.801186"

updatedAt
string
required
Example:

"2021-03-08T17:57:48.801186"

brandId
string

Brand ID. Empty if the number is associated to a shared campaign.

Example:

"7ba705b7-22af-493f-addc-ac04b7ca071c"

tcrBrandId
string

TCR's alphanumeric ID for the brand.

Example:

"BBRAND1"

tcrCampaignId
string

TCR's alphanumeric ID for the campaign.

Example:

"CCAMPA1"

telnyxCampaignId
string

Campaign ID. Empty if the number is associated to a shared campaign.

Example:

"3008dd9f-66d7-40e0-bf23-bf2d8d1a96ba"

assignmentStatus
enum<string>

The assignment status of the number.

Available options:
FAILED_ASSIGNMENT,
PENDING_ASSIGNMENT,
ASSIGNED,
PENDING_UNASSIGNMENT,
FAILED_UNASSIGNMENT
Example:

"ASSIGNED"

failureReasons
string

Extra info about a failure to assign/unassign a number. Relevant only if the assignmentStatus is either FAILED_ASSIGNMENT or FAILED_UNASSIGNMENT