Skip to main content
POST
/
api
/
v2
/
platform
/
telephony
/
trunks
/
{id}
/
detach-numbers
/
Detach Numbers from Trunk
curl --request POST \
  --url https://unpod.ai/api/v2/platform/telephony/trunks/{id}/detach-numbers/ \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --header 'Org-Handle: <org-handle>' \
  --data '
{
  "number_ids": [
    501
  ]
}
'
import requests

url = "https://unpod.ai/api/v2/platform/telephony/trunks/{id}/detach-numbers/"

payload = { "number_ids": [501] }
headers = {
"Org-Handle": "<org-handle>",
"Authorization": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {
'Org-Handle': '<org-handle>',
Authorization: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({number_ids: [501]})
};

fetch('https://unpod.ai/api/v2/platform/telephony/trunks/{id}/detach-numbers/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://unpod.ai/api/v2/platform/telephony/trunks/{id}/detach-numbers/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'number_ids' => [
501
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json",
"Org-Handle: <org-handle>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://unpod.ai/api/v2/platform/telephony/trunks/{id}/detach-numbers/"

payload := strings.NewReader("{\n \"number_ids\": [\n 501\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Org-Handle", "<org-handle>")
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://unpod.ai/api/v2/platform/telephony/trunks/{id}/detach-numbers/")
.header("Org-Handle", "<org-handle>")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"number_ids\": [\n 501\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://unpod.ai/api/v2/platform/telephony/trunks/{id}/detach-numbers/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Org-Handle"] = '<org-handle>'
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"number_ids\": [\n 501\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "status_code": 200,
  "message": "Numbers unmapped from trunk.",
  "data": {
    "trunk_id": 21,
    "numbers": [
      { "number_id": 501, "ok": true }
    ]
  }
}
{ "status_code": 404, "message": "Trunk not found." }
Unmap one or more numbers from this trunk. Detaching deletes the number’s bridge mapping, fires deprovision, sets the number back to NOT_ASSIGNED, and releases channels.
Prerequisites: API Token + Org-Handle. See Authentication.

Headers

NameTypeRequiredDescription
AuthorizationstringYesToken <your-api-key>
Org-HandlestringYesOrganization domain handle
Content-TypestringYesapplication/json

Path parameters

NameTypeRequiredDescription
idintegerYesTrunk id

Request body

FieldTypeRequiredDescription
number_idsinteger[]YesNumbers to unmap

Partial success

Each data.numbers entry reports ok/error. A number that isn’t mapped to this trunk returns ok: false with "Number is not mapped to this trunk."
{
  "status_code": 200,
  "message": "Numbers unmapped from trunk.",
  "data": {
    "trunk_id": 21,
    "numbers": [
      { "number_id": 501, "ok": true }
    ]
  }
}
{ "status_code": 404, "message": "Trunk not found." }
cURL
curl -s -X POST "https://unpod.ai/api/v2/platform/telephony/trunks/21/detach-numbers/" \
  -H "Authorization: Token <your-api-key>" \
  -H "Org-Handle: <your-org-handle>" \
  -H "Content-Type: application/json" \
  -d '{"number_ids": [501]}'

Authorizations

Authorization
string
header
required

Format: Token

Headers

Org-Handle
string
required

Organization domain handle

Example:

"unpod.tv"

Path Parameters

id
integer
required
Example:

21

Body

application/json
number_ids
integer[]
required
Example:
[501]

Response

Numbers unmapped from trunk (partial-success per number)