Use the Number Linking API to associate phone numbers with your 10DLC campaigns. You must link a number to a campaign before using it to send messages. This API allows you to link numbers, retrieve linked numbers, check linking status, and unlink numbers from campaigns.
API Endpoint
https://api.plivo.com/v1/Account/{auth_id}/10dlc/Campaign/{campaign_id}/Number/
The Number Object
Attributes
Unique identifier for a campaign.
Friendly name for the campaign.
Use case of the campaign.
Array containing status of each number linked to the campaign. Each entry includes number and status fields.
Example Object
{
"campaign_alias": "ABC Campaign",
"campaign_id": "CUOGHIN",
"phone_numbers": [
{
"number": "12125557778",
"status": "PROCESSING"
}
],
"usecase": "STARTER"
}
Link Number to Campaign
Link one or more phone numbers to an existing campaign.
POST https://api.plivo.com/v1/Account/{auth_id}/10dlc/Campaign/{campaign_id}/Number/
Arguments
The numbers you want to link to a campaign. Numbers should be in E.164 format.
Fully qualified URL to which status update callbacks for the linking request should be sent.
The HTTP method to be used when calling the URL defined above. Allowed values: GET, POST. Defaults to POST.
import plivo
client = plivo.RestClient("<auth_id>", "<auth_token>")
response = client.campaign.number_link(
campaign_id="<campaign_id>",
url="https://example.com/callback",
method="POST",
numbers=["<phone_number>"],
)
print(response)
Response
{
"api_id": "0b2e010e-b4a1-11ec-a9f5-0242ac110003",
"message": "Request to link 14156667778 to campaign CUOGHIN was received and is being processed"
}
Retrieve All Numbers Linked to a Campaign
Fetch all numbers linked to a particular campaign.
GET https://api.plivo.com/v1/Account/{auth_id}/10dlc/Campaign/{campaign_id}/Number/
No arguments need to be passed.
The status field in the phone_numbers array can have the following values:
FAILED - The linking request failed
PROCESSING - The linking request is being processed
COMPLETED - The number has been successfully linked
import plivo
client = plivo.RestClient("<auth_id>", "<auth_token>")
response = client.campaign.list_number(campaign_id="<campaign_id>")
print(response)
Response
{
"api_id": "8010803c-b4a1-11ec-8f25-0242ac110002",
"campaign_alias": "ABC Campaign",
"campaign_id": "CUOGHIN",
"phone_numbers": [
{
"number": "12125557777",
"status": "PROCESSING"
},
{
"number": "12125557778",
"status": "PROCESSING"
},
{
"number": "12125557779",
"status": "FAILED"
}
],
"usecase": "STARTER"
}
Retrieve Number Status
Fetch the status of a specific number linked to a campaign.
GET https://api.plivo.com/v1/Account/{auth_id}/10dlc/Campaign/{campaign_id}/Number/{number}/
No arguments need to be passed.
The status field can have the values FAILED, PROCESSING, or COMPLETED.
import plivo
client = plivo.RestClient("<auth_id>", "<auth_token>")
response = client.campaign.get_number(
campaign_id="<campaign_id>",
number="<phone_number>"
)
print(response)
Response
{
"api_id": "56df0724-b4a1-11ec-a357-0242ac110002",
"campaign_alias": "ABC Campaign",
"campaign_id": "CUOGHIN",
"phone_numbers": [
{
"number": "12125557777",
"status": "PROCESSING"
}
],
"usecase": "STARTER"
}
Unlink Number from Campaign
Unlink a phone number from a campaign.
DELETE https://api.plivo.com/v1/Account/{auth_id}/10dlc/Campaign/{campaign_id}/Number/{number}/
Arguments
Fully qualified URL to which status update callbacks for the unlinking request should be sent.
The HTTP method to be used when calling the URL defined above. Allowed values: GET, POST. Defaults to POST.
import plivo
client = plivo.RestClient("<auth_id>", "<auth_token>")
response = client.campaign.number_unlink(
campaign_id="<campaign_id>",
number="<phone_number>",
url="https://example.com/callback",
method="POST",
)
print(response)
Response
{
"api_id": "eba3f9aa-b4a1-11ec-85a1-0242ac110003",
"message": "Request to unlink 12125557777 from campaign CUOGHIN was received and is being processed"
}