> 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.

# Importa numero di telefono

POST https://api.elevenlabs.io/v1/convai/phone-numbers
Content-Type: application/json

Importa il numero di telefono dalla configurazione del provider (Twilio, Exotel o trunk SIP)

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

## 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

### Body (application/json)

This endpoint expects a PhoneNumbersCreateRequestBody.

- `PhoneNumbersCreateRequestBody`
  - `provider`: `twilio`
    - `label` (string, required) — Etichetta del numero di telefono
    - `phone_number` (string, required) — Numero di telefono
    - `sid` (string, required) — SID dell'account Twilio (inizia con `AC`) o SID della API Key (inizia con `SK`)
    - `token` (string, required) — Segreto associato a `sid`: l'Account Auth Token per un Account SID oppure l'API Key Secret per un API Key SID
    - `account_auth_token` (string, optional) — Token di autenticazione dell'account Twilio, necessario per le importazioni di API Key per convalidare le firme dei webhook in entrata
    - `agent_id` (string, optional) — ID dell'agente a cui assegnare il numero di telefono
    - `enable_sms` (boolean, optional, default: true) — Instrada gli SMS in entrata a ElevenLabs. È attivo per impostazione predefinita; imposta false per saltare la configurazione degli SMS per i numeri che non la supportano.
    - `region_config` (RegionConfigRequest, optional) — Configurazione delle regioni aggiuntive di Twilio
    - `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`
    - `account_sid` (string, required) — SID dell'account Exotel
    - `api_key` (string, required) — Chiave API Exotel
    - `api_subdomain` (enum, required) — Host API Exotel specifico della regione
      - Allowed values: `api.in.exotel.com`, `api.exotel.com`
    - `api_token` (string, required) — Token API Exotel
    - `app_id` (string, required) — Identificatore dell'applet Exotel usato in Calls/connect
    - `label` (string, required) — Etichetta del numero di telefono
    - `phone_number` (string, required) — Numero di telefono
    - `agent_id` (string, optional) — ID dell'agente a cui assegnare il numero di telefono
    - `applet_url` (string, optional) — Override facoltativo dell'URL completo dell'applet. Per impostazione predefinita, viene usato l'URL start_voice di Exotel derivato dal SID dell'account e dall'ID dell'app.
    - `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
    - `phone_number` (string, required) — Numero di telefono
    - `agent_id` (string, optional) — ID dell'agente a cui assegnare il numero di telefono
    - `inbound_trunk_config` (InboundSipTrunkConfigRequestModel, optional)
    - `outbound_trunk_config` (OutboundSipTrunkConfigRequestModel, optional)
    - `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.

## Response

### 200

Risposta riuscita

- `phone_number_id` (string, required) — ID dell'entità telefonica

## Errors

### 422 Phone Numbers Create Request Unprocessable Entity Error

Errore di convalida

- `detail` (list of ValidationError, optional)

## Types

### RegionConfigRequest

- `region_id` (enum, required) — ID della regione
  - Allowed values: `us1`, `ie1`, `au1`
- `token` (string, required) — Token di autenticazione per questa regione
- `edge_location` (enum, required) — Posizione edge per questa regione
  - Allowed values: `ashburn`, `dublin`, `frankfurt`, `sao-paulo`, `singapore`, `sydney`, `tokyo`, `umatilla`, `roaming`

### 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`

### 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
{
  "provider": "twilio",
  "label": "label",
  "phone_number": "phone_number",
  "sid": "sid",
  "token": "token"
}
```

**Response**

```json
{
  "phone_number_id": "phone_number_id"
}
```

**SDK Code**

```python
import requests

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

payload = {
    "provider": "twilio",
    "label": "label",
    "phone_number": "phone_number",
    "sid": "sid",
    "token": "token"
}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/convai/phone-numbers';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"provider":"twilio","label":"label","phone_number":"phone_number","sid":"sid","token":"token"}'
};

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"

	payload := strings.NewReader("{\n  \"provider\": \"twilio\",\n  \"label\": \"label\",\n  \"phone_number\": \"phone_number\",\n  \"sid\": \"sid\",\n  \"token\": \"token\"\n}")

	req, _ := http.NewRequest("POST", 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")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"provider\": \"twilio\",\n  \"label\": \"label\",\n  \"phone_number\": \"phone_number\",\n  \"sid\": \"sid\",\n  \"token\": \"token\"\n}"

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.post("https://api.elevenlabs.io/v1/convai/phone-numbers")
  .header("Content-Type", "application/json")
  .body("{\n  \"provider\": \"twilio\",\n  \"label\": \"label\",\n  \"phone_number\": \"phone_number\",\n  \"sid\": \"sid\",\n  \"token\": \"token\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.elevenlabs.io/v1/convai/phone-numbers', [
  'body' => '{
  "provider": "twilio",
  "label": "label",
  "phone_number": "phone_number",
  "sid": "sid",
  "token": "token"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/convai/phone-numbers");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"provider\": \"twilio\",\n  \"label\": \"label\",\n  \"phone_number\": \"phone_number\",\n  \"sid\": \"sid\",\n  \"token\": \"token\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "provider": "twilio",
  "label": "label",
  "phone_number": "phone_number",
  "sid": "sid",
  "token": "token"
] as [String : Any]

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

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