> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.phonic.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.phonic.ai/_mcp/server.

# Delete Custom Phone Number

DELETE https://api.phonic.ai/v1/agents/{nameOrId}/custom-phone-numbers
Content-Type: application/json

Deletes a custom phone number from an agent.

Reference: https://docs.phonic.ai/api-reference/agents/delete-custom-phone-number

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication header of the form `Bearer <PHONIC_API_KEY>`. Manage your API keys [here](https://phonic.co/api-keys).

## Request

### Path parameters

- `nameOrId` (string, required) — The name or the ID of the agent.

### Query parameters

- `project` (string, optional, default: main) — The name of the project containing the agent. Only used when `nameOrId` is a name.

### Body (application/json)

This endpoint expects an object.

- `phone_number` (string, required) — The E.164 formatted phone number to remove (e.g., "+15551234567").

## Response

### 200

Success response

- `success` (boolean, required)

## Errors

### 400 Bad Request Error

Invalid parameters, phone number not assigned to agent, or not a custom phone number

- `error` (BasicErrorError, optional)

### 401 Unauthorized Error

Unsupported authentication method

- `error` (BasicErrorError, optional)

### 403 Forbidden Error

Forbidden

- `error` (BasicErrorError, optional)

### 404 Not Found Error

Agent or phone number not found

- `error` (BasicErrorError, optional)

### 409 Conflict Error

The agent is currently being updated (please try again), or the agent is disabled.

- `error` (BasicErrorError, optional)

## Types

### BasicErrorError

- `message` (string, required) — Error message
- `code` (string, optional) — Error code

## Examples

### Remove custom phone number response

**Response**

```json
{
  "success": true
}
```

**SDK Code**

```python Remove custom phone number response
import requests

url = "https://api.phonic.ai/v1/agents/nameOrId/custom-phone-numbers"

querystring = {"project":"main"}

headers = {"Authorization": "Bearer <apiKey>"}

response = requests.delete(url, headers=headers, params=querystring)

print(response.json())
```

```javascript Remove custom phone number response
const url = 'https://api.phonic.ai/v1/agents/nameOrId/custom-phone-numbers?project=main';
const options = {method: 'DELETE', headers: {Authorization: 'Bearer <apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Remove custom phone number response
package main

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

func main() {

	url := "https://api.phonic.ai/v1/agents/nameOrId/custom-phone-numbers?project=main"

	req, _ := http.NewRequest("DELETE", url, nil)

	req.Header.Add("Authorization", "Bearer <apiKey>")

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

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

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Remove custom phone number response
require 'uri'
require 'net/http'

url = URI("https://api.phonic.ai/v1/agents/nameOrId/custom-phone-numbers?project=main")

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

request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <apiKey>'

response = http.request(request)
puts response.read_body
```

```java Remove custom phone number response
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.delete("https://api.phonic.ai/v1/agents/nameOrId/custom-phone-numbers?project=main")
  .header("Authorization", "Bearer <apiKey>")
  .asString();
```

```php Remove custom phone number response
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('DELETE', 'https://api.phonic.ai/v1/agents/nameOrId/custom-phone-numbers?project=main', [
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Remove custom phone number response
using RestSharp;

var client = new RestClient("https://api.phonic.ai/v1/agents/nameOrId/custom-phone-numbers?project=main");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", "Bearer <apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Remove custom phone number response
import Foundation

let headers = ["Authorization": "Bearer <apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.phonic.ai/v1/agents/nameOrId/custom-phone-numbers?project=main")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### agents_delete_custom_phone_number_example

**Request**

```json
{
  "phone_number": "+15551234567"
}
```

**Response**

```json
{
  "success": true
}
```

**SDK Code**

```python agents_delete_custom_phone_number_example
import requests

url = "https://api.phonic.ai/v1/agents/nameOrId/custom-phone-numbers"

querystring = {"project":"main"}

payload = { "phone_number": "+15551234567" }
headers = {
    "Authorization": "Bearer <apiKey>",
    "Content-Type": "application/json"
}

response = requests.delete(url, json=payload, headers=headers, params=querystring)

print(response.json())
```

```javascript agents_delete_custom_phone_number_example
const url = 'https://api.phonic.ai/v1/agents/nameOrId/custom-phone-numbers?project=main';
const options = {
  method: 'DELETE',
  headers: {Authorization: 'Bearer <apiKey>', 'Content-Type': 'application/json'},
  body: '{"phone_number":"+15551234567"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go agents_delete_custom_phone_number_example
package main

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

func main() {

	url := "https://api.phonic.ai/v1/agents/nameOrId/custom-phone-numbers?project=main"

	payload := strings.NewReader("{\n  \"phone_number\": \"+15551234567\"\n}")

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

	req.Header.Add("Authorization", "Bearer <apiKey>")
	req.Header.Add("Content-Type", "application/json")

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

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

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby agents_delete_custom_phone_number_example
require 'uri'
require 'net/http'

url = URI("https://api.phonic.ai/v1/agents/nameOrId/custom-phone-numbers?project=main")

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

request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"phone_number\": \"+15551234567\"\n}"

response = http.request(request)
puts response.read_body
```

```java agents_delete_custom_phone_number_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.delete("https://api.phonic.ai/v1/agents/nameOrId/custom-phone-numbers?project=main")
  .header("Authorization", "Bearer <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"phone_number\": \"+15551234567\"\n}")
  .asString();
```

```php agents_delete_custom_phone_number_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('DELETE', 'https://api.phonic.ai/v1/agents/nameOrId/custom-phone-numbers?project=main', [
  'body' => '{
  "phone_number": "+15551234567"
}',
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp agents_delete_custom_phone_number_example
using RestSharp;

var client = new RestClient("https://api.phonic.ai/v1/agents/nameOrId/custom-phone-numbers?project=main");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", "Bearer <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"phone_number\": \"+15551234567\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift agents_delete_custom_phone_number_example
import Foundation

let headers = [
  "Authorization": "Bearer <apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["phone_number": "+15551234567"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.phonic.ai/v1/agents/nameOrId/custom-phone-numbers?project=main")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```