Purchase a phone number for a specific account.
POST https://services.leadconnectorhq.com/phone-system/numbers/location/{locationId}/purchase
Authorization
Path parameters
Body
Responses
201 - Phone number successfully purchased. Returns the updated Twilio account state for the account.
id (string, required): Unique identifier of the Twilio account record Example: 8xMPW85D2z5jgcTa5L1p
account_sid (string, required): Twilio Account SID Example: ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
under_ghl_account (boolean, required): Whether this account is under a GHL-managed Twilio account Example: True
validate_sms (boolean, required): Whether SMS validation is enabled Example: True
location_id (string, required): The account ID this Twilio account belongs to Example: aa4PBpxnPc9bs4LSdiW7
migration_status (string): Current migration status of the account Example: completed
migration_numbers (string[]): List of numbers being migrated
assigned_to_numbers (object): Map of phone numbers to assigned user IDs
numbers (object, required): Map of phone numbers to their service type (e.g. 'conversation')
number_name (object): Map of phone numbers to their friendly names
new_account_sid (string): New account SID if the account has been migrated to new credentials
{
"id": "8xMPW85D2z5jgcTa5L1p",
"account_sid": "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"under_ghl_account": true,
"validate_sms": true,
"location_id": "aa4PBpxnPc9bs4LSdiW7",
"migration_numbers": [],
"assigned_to_numbers": {},
"numbers": {
"+18705871861": "conversation"
},
"number_name": {
"+18705871861": "My Number"
},
"new_account_sid": ""
}
400 - Bad request - Invalid parameters or number unavailable
message (string): Example: Phone number is no longer available
error (string): Example: Bad Request
statusCode (number): Example: 400
{
"message": "Phone number is no longer available",
"error": "Bad Request",
"statusCode": 400
}
401 - Unauthorized
500 - Internal server error - An unexpected error occurred while purchasing the phone number
Example
curl -X POST 'https://services.leadconnectorhq.com/phone-system/numbers/location/YOUR_locationId/purchase' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Version: 2021-07-28' \
-H 'Content-Type: application/json' \
-d '{
"phoneNumber": "+18305551234",
"countryCode": "US",
"numberType": "local",
"addressSid": "AD1234567890abcdef1234567890abcde",
"bundleSid": "BU1234567890abcdef1234567890abcde",
"locality": "San Antonio",
"region": "TX",
"fingerprintId": "fp_abc123def456",
"skipLocationKYC": false
}'
const response = await fetch('https://services.leadconnectorhq.com/phone-system/numbers/location/YOUR_locationId/purchase', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
Version: '2021-07-28',
'Content-Type': 'application/json',
},
body: JSON.stringify({"phoneNumber": "+18305551234", "countryCode": "US", "numberType": "local", "addressSid": "AD1234567890abcdef1234567890abcde", "bundleSid": "BU1234567890abcdef1234567890abcde", "locality": "San Antonio", "region": "TX", "fingerprintId": "fp_abc123def456", "skipLocationKYC": false}),
});
const data = await response.json();
import os, requests
response = requests.request(
'POST',
'https://services.leadconnectorhq.com/phone-system/numbers/location/YOUR_locationId/purchase',
headers={
'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
'Version': '2021-07-28',
'Content-Type': 'application/json',
},
json={"phoneNumber": "+18305551234", "countryCode": "US", "numberType": "local", "addressSid": "AD1234567890abcdef1234567890abcde", "bundleSid": "BU1234567890abcdef1234567890abcde", "locality": "San Antonio", "region": "TX", "fingerprintId": "fp_abc123def456", "skipLocationKYC": false},
)
data = response.json()
<?php
$ch = curl_init('https://services.leadconnectorhq.com/phone-system/numbers/location/YOUR_locationId/purchase');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
'Version: 2021-07-28',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode({'phoneNumber': '+18305551234', 'countryCode': 'US', 'numberType': 'local', 'addressSid': 'AD1234567890abcdef1234567890abcde', 'bundleSid': 'BU1234567890abcdef1234567890abcde', 'locality': 'San Antonio', 'region': 'TX', 'fingerprintId': 'fp_abc123def456', 'skipLocationKYC': false}),
]);
$data = json_decode(curl_exec($ch), true);