Delete a Virtual Number
Agent Skill
Automate this endpoint with an AI agent using the 2chat-calls skill:
npx skills add 2ChatCo/agent-skills -s 2chat-calls
Delete one of the virtual phone numbers connected to your 2Chat account.
Endpoint
DELETE https://api.p.2chat.io/open/voip/virtual-numbers/{virtual_number_uuid}
Authentication
Include your API key in the X-User-API-Key header. Learn more about authentication.
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
virtual_number_uuid | string (path) | Yes | The UUID of the virtual number to delete. Must start with DID (e.g. DID64a54de2-8ebe-4c01-838f-a2235815dab4). Use the List Virtual Numbers endpoint to obtain it. |
Invocation
- cURL
- Python
- JavaScript
- PHP
curl --location --request DELETE 'https://api.p.2chat.io/open/voip/virtual-numbers/DID64a54de2-8ebe-4c01-838f-a2235815dab4' \
--header 'X-User-API-Key: your_api_key_here'
import requests
virtual_number_uuid = "DID64a54de2-8ebe-4c01-838f-a2235815dab4"
url = f"https://api.p.2chat.io/open/voip/virtual-numbers/{virtual_number_uuid}"
headers = {
"X-User-API-Key": "your_api_key_here"
}
response = requests.delete(url, headers=headers)
print(response.json())
const axios = require('axios');
const virtualNumberUuid = 'DID64a54de2-8ebe-4c01-838f-a2235815dab4';
const response = await axios.delete(
`https://api.p.2chat.io/open/voip/virtual-numbers/${virtualNumberUuid}`,
{
headers: {
'X-User-API-Key': 'your_api_key_here'
}
}
);
console.log(response.data);
<?php
$curl = curl_init();
$virtualNumberUuid = 'DID64a54de2-8ebe-4c01-838f-a2235815dab4';
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.p.2chat.io/open/voip/virtual-numbers/$virtualNumberUuid",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => array(
'X-User-API-Key: your_api_key_here'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Response
Success (HTTP 200 OK)
{
"success": true
}
| Field | Description |
|---|---|
success | true when the number was deleted |
Error
{
"error": true,
"error_message": "Description of what went wrong"
}
| Field | Description |
|---|---|
error | true when the request failed |
error_message | A description of what went wrong |