> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# Aggiorna numero di telefono

PATCH https://api.elevenlabs.io/v1/convai/phone-numbers/{phone_number_id}
Content-Type: application/json

Aggiorna l'agente assegnato a un numero di telefono

Reference: https://elevenlabs.io/docs/eleven-agents/api-reference/phone-numbers/update

## Servers

- `https://api.elevenlabs.io` (Production, default)
- `https://api.us.elevenlabs.io` (Production US)
- `https://api.eu.residency.elevenlabs.io` (Production EU)
- `https://api.in.residency.elevenlabs.io` (Production India)
- `https://api.sg.residency.elevenlabs.io` (Production Singapore)

## Request

### Path parameters

- `phone_number_id` (string, required) — L'ID del numero di telefono. Viene restituito quando viene importato un numero di telefono.

### Body (application/json)

This endpoint expects an object.

- `agent_id` (string, optional)
- `label` (string, optional)
- `inbound_trunk_config` (InboundSipTrunkConfigRequestModel, optional)
- `outbound_trunk_config` (OutboundSipTrunkConfigRequestModel, optional)
- `livekit_stack` (enum, optional, default: standard)
  - Allowed values: `standard`, `static`
- `store_sip_messages` (boolean, optional)
- `environment` (string, optional) — Ambiente da usare per risolvere le variabili di ambiente nelle chiamate a questo numero.
- `branch_id` (string, optional) — Ramo dell'agente da usare per le chiamate a questo numero.

## Response

### 200

Risposta riuscita

- `PhoneNumbersUpdateResponse`
  - `provider`: `twilio`
    - `label` (string, required) — Etichetta del numero di telefono
    - `phone_number` (string, required) — Numero di telefono
    - `phone_number_id` (string, required) — L'ID del numero di telefono
    - `assigned_agent` (PhoneNumberAgentInfo, optional) — L'agente assegnato al numero di telefono
    - `supports_inbound` (boolean, optional, default: true, deprecated) — Questo campo è deprecato e verrà rimosso in futuro. Indica se questo numero di telefono supporta le chiamate in entrata.
    - `supports_outbound` (boolean, optional, default: true, deprecated) — Questo campo è deprecato e verrà rimosso in futuro. Indica se questo numero di telefono supporta le chiamate in uscita.
  - `provider`: `exotel`
    - `label` (string, required) — Etichetta del numero di telefono
    - `phone_number` (string, required) — Numero di telefono
    - `phone_number_id` (string, required) — L'ID del numero di telefono
    - `assigned_agent` (PhoneNumberAgentInfo, optional) — L'agente assegnato al numero di telefono
    - `supports_inbound` (boolean, optional, default: true, deprecated) — Questo campo è deprecato e verrà rimosso in futuro. Indica se questo numero di telefono supporta le chiamate in entrata.
    - `supports_outbound` (boolean, optional, default: true, deprecated) — Questo campo è deprecato e verrà rimosso in futuro. Indica se questo numero di telefono supporta le chiamate in uscita.
  - `provider`: `sip_trunk`
    - `label` (string, required) — Etichetta del numero di telefono
    - `livekit_stack` (enum, required, default: standard) — Tipo di stack Livekit usato per questo numero.
      - Allowed values: `standard`, `static`
    - `phone_number` (string, required) — Numero di telefono
    - `phone_number_id` (string, required) — L'ID del numero di telefono
    - `assigned_agent` (PhoneNumberAgentInfo, optional) — L'agente assegnato al numero di telefono
    - `inbound_trunk` (GetPhoneNumberInboundSipTrunkConfigResponseModel, optional) — Configurazione del trunk SIP in entrata, se configurato.
    - `outbound_trunk` (GetPhoneNumberOutboundSipTrunkConfigResponseModel, optional) — Configurazione del trunk SIP in uscita, se configurato.
    - `store_sip_messages` (boolean, optional, default: true) — Indica se archiviare i messaggi SIP per questo numero di telefono.
    - `provider_config` (GetPhoneNumberOutboundSipTrunkConfigResponseModel, optional, deprecated) — Dettagli della configurazione del trunk SIP per un numero di telefono
    - `supports_inbound` (boolean, optional, default: true, deprecated) — Questo campo è deprecato e verrà rimosso in futuro. Indica se questo numero di telefono supporta le chiamate in entrata.
    - `supports_outbound` (boolean, optional, default: true, deprecated) — Questo campo è deprecato e verrà rimosso in futuro. Indica se questo numero di telefono supporta le chiamate in uscita.

## Errors

### 422 Phone Numbers Update Request Unprocessable Entity Error

Errore di convalida

- `detail` (list of ValidationError, optional)

## Types

### InboundSipTrunkConfigRequestModel

- `allowed_addresses` (list of string, optional) — Elenco degli indirizzi IP autorizzati a usare il trunk. Ogni elemento dell'elenco può essere un singolo indirizzo IP o una notazione Classless Inter-Domain Routing che rappresenta un blocco CIDR.
- `allowed_numbers` (list of string, optional) — Elenco dei numeri di telefono autorizzati a usare il trunk.
- `media_encryption` (enum, optional, default: allowed) — Se crittografare i media (livello dati).
  - Allowed values: `disabled`, `allowed`, `required`
- `credentials` (SipTrunkCredentialsRequestModel, optional) — Credenziali di autenticazione digest facoltative (nome utente/password).
- `remote_domains` (list of string, optional) — Domini dei server SIP remoti utilizzati per convalidare i certificati TLS.
- `attributes_to_headers` (map from string to string, optional) — Mappa del nome della variabile dinamica al nome dell'header per attributes_to_headers

### OutboundSipTrunkConfigRequestModel

- `address` (string, required) — Hostname o IP a cui viene inviato il SIP INVITE.
- `transport` (enum, optional, default: auto) — Protocollo da utilizzare per il trasporto SIP (livello di segnalazione).
  - Allowed values: `auto`, `udp`, `tcp`, `tls`
- `media_encryption` (enum, optional, default: allowed) — Se crittografare i media (livello dati).
  - Allowed values: `disabled`, `allowed`, `required`
- `headers` (map from string to string, optional) — Header SIP X-* per la richiesta INVITE. Questi header vengono inviati così come sono e possono aiutare a identificare questa chiamata.
- `attributes_to_headers` (map from string to string, optional) — Mappa del nome della variabile dinamica al nome dell'header per attributes_to_headers
- `credentials` (SipTrunkCredentialsRequestModel, optional) — Credenziali di autenticazione digest facoltative (nome utente/password). Se non vengono fornite, viene presupposta l'autenticazione ACL.
- `enabled_codecs` (list of enum, optional) — Codec multimediali che devono essere offerti nell'SDP per le chiamate in uscita. Se vuoto, vengono offerti tutti i codec supportati.
  - Allowed values: `G722/8000`, `PCMU/8000`, `PCMA/8000`

### PhoneNumberAgentInfo

- `agent_id` (string, required) — L'ID dell'agente
- `agent_name` (string, required) — Il nome dell'agente
- `environment` (string, optional) — Ambiente da usare per risolvere le variabili di ambiente nelle chiamate a questo numero.
- `branch_id` (string, optional) — Ramo dell'agente da usare per le chiamate a questo numero.

### GetPhoneNumberInboundSipTrunkConfigResponseModel

- `allowed_addresses` (list of string, required) — Elenco degli indirizzi IP autorizzati a usare il trunk. Ogni elemento dell'elenco può essere un singolo indirizzo IP o una notazione Classless Inter-Domain Routing che rappresenta un blocco CIDR.
- `media_encryption` (enum, required, default: allowed)
  - Allowed values: `disabled`, `allowed`, `required`
- `has_auth_credentials` (boolean, required) — Se le credenziali di autenticazione sono configurate
- `allowed_numbers` (list of string, optional) — Elenco dei numeri di telefono autorizzati a usare il trunk.
- `username` (string, optional) — Nome utente del trunk SIP, se disponibile
- `remote_domains` (list of string, optional) — Domini dei server SIP remoti utilizzati per convalidare i certificati TLS.
- `attributes_to_headers` (map from string to string, optional) — Mappa del nome della variabile dinamica al nome dell'header per attributes_to_headers

### GetPhoneNumberOutboundSipTrunkConfigResponseModel

Dettagli della configurazione del trunk SIP per un numero di telefono

- `address` (string, required) — Hostname o IP a cui viene inviato il SIP INVITE
- `transport` (enum, required, default: auto) — Protocollo da utilizzare per il trasporto SIP
  - Allowed values: `auto`, `udp`, `tcp`, `tls`
- `media_encryption` (enum, required, default: allowed) — Se crittografare i media (livello dati).
  - Allowed values: `disabled`, `allowed`, `required`
- `has_auth_credentials` (boolean, required) — Se le credenziali di autenticazione sono configurate
- `headers` (map from string to string, optional) — Header SIP per la richiesta INVITE
- `attributes_to_headers` (map from string to string, optional) — Mappa del nome della variabile dinamica al nome dell'header per attributes_to_headers
- `username` (string, optional) — Nome utente del trunk SIP, se disponibile
- `has_outbound_trunk` (boolean, optional, default: false) — Se è configurato un trunk SIP in uscita LiveKit
- `enabled_codecs` (list of enum, optional) — Codec multimediali offerti nell'SDP per le chiamate in uscita. Se vuoto, vengono offerti tutti i codec supportati.
  - Allowed values: `G722/8000`, `PCMU/8000`, `PCMA/8000`

### ValidationError

- `loc` (list of ValidationErrorLocItem, required)
- `msg` (string, required)
- `type` (string, required)

### SipTrunkCredentialsRequestModel

- `username` (string, required) — Nome utente del trunk SIP
- `password` (string, optional) — Password del trunk SIP: se non specificata, rimane invariata

### ValidationErrorLocItem

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "provider": "twilio",
  "label": "Customer Support",
  "phone_number": "+1234567890",
  "phone_number_id": "phone_123",
  "assigned_agent": {
    "agent_id": "F3Pbu5gP6NNKBscdCdwB",
    "agent_name": "My Agent",
    "environment": "environment",
    "branch_id": "branch_id"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/convai/phone-numbers/TeaqRRdTcIfIu2i7BYfT"

payload = {}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/convai/phone-numbers/TeaqRRdTcIfIu2i7BYfT';
const options = {method: 'PATCH', headers: {'Content-Type': 'application/json'}, body: '{}'};

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

```go
package main

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

func main() {

	url := "https://api.elevenlabs.io/v1/convai/phone-numbers/TeaqRRdTcIfIu2i7BYfT"

	payload := strings.NewReader("{}")

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

	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
require 'uri'
require 'net/http'

url = URI("https://api.elevenlabs.io/v1/convai/phone-numbers/TeaqRRdTcIfIu2i7BYfT")

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

request = Net::HTTP::Patch.new(url)
request["Content-Type"] = 'application/json'
request.body = "{}"

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

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

HttpResponse<String> response = Unirest.patch("https://api.elevenlabs.io/v1/convai/phone-numbers/TeaqRRdTcIfIu2i7BYfT")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.elevenlabs.io/v1/convai/phone-numbers/TeaqRRdTcIfIu2i7BYfT', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/convai/phone-numbers/TeaqRRdTcIfIu2i7BYfT");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/convai/phone-numbers/TeaqRRdTcIfIu2i7BYfT")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```