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

- `conversational_ai_phone_numbers_create_Request`

## Response

### 200

Risposta riuscita

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

## Errors

### 422 Unprocessable Entity Error

Errore di convalida

- `detail` (list of ValidationError, optional)

## Types

### CreateTwilioPhoneNumberRequest

- `phone_number` (string, required) — Numero di telefono
- `label` (string, required) — Etichetta del 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
- `provider` ("twilio", optional, default: twilio)
- `agent_id` (string, optional, nullable) — ID dell'agente a cui assegnare il numero di telefono
- `account_auth_token` (string, optional, nullable) — Token di autenticazione dell'account Twilio, necessario per le importazioni di API Key per convalidare le firme dei webhook in entrata
- `region_config` (RegionConfigRequest, optional, nullable) — Configurazione delle regioni aggiuntive di Twilio
- `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.
- `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.

### CreateExotelPhoneNumberRequest

- `phone_number` (string, required) — Numero di telefono
- `label` (string, required) — Etichetta del numero di telefono
- `account_sid` (string, required) — SID dell'account Exotel
- `api_key` (string, required) — Chiave API Exotel
- `api_token` (string, required) — Token API Exotel
- `api_subdomain` (enum, required) — Host API Exotel specifico della regione
  - Allowed values: `api.in.exotel.com`, `api.exotel.com`
- `app_id` (string, required) — Identificatore dell'applet Exotel usato in Calls/connect
- `provider` ("exotel", optional, default: exotel)
- `agent_id` (string, optional, nullable) — ID dell'agente a cui assegnare il numero di telefono
- `applet_url` (string, optional, nullable) — 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.

### CreateSIPTrunkPhoneNumberRequestV2

- `phone_number` (string, required) — Numero di telefono
- `label` (string, required) — Etichetta del numero di telefono
- `provider` ("sip_trunk", optional, default: sip_trunk)
- `agent_id` (string, optional, nullable) — ID dell'agente a cui assegnare il numero di telefono
- `inbound_trunk_config` (InboundSIPTrunkConfigRequestModel, optional, nullable)
- `outbound_trunk_config` (OutboundSIPTrunkConfigRequestModel, optional, nullable)
- `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.

### ValidationError

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

### 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, nullable) — 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, nullable) — 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, nullable) — Credenziali di autenticazione digest facoltative (nome utente/password).
- `remote_domains` (list of string, optional, nullable) — 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, nullable) — 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`

### ValidationErrorLocItems

### SIPTrunkCredentialsRequestModel

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

## Examples

**Request**

```json
{
  "account_sid": "your-account-sid",
  "api_key": "your-api-key",
  "api_subdomain": "api.in.exotel.com",
  "api_token": "********",
  "app_id": "12345",
  "label": "Exotel Outbound",
  "phone_number": "+919999999999",
  "provider": "exotel"
}
```

**Response**

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

**SDK Code**

```python
import requests

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

payload = {
    "account_sid": "your-account-sid",
    "api_key": "your-api-key",
    "api_subdomain": "api.in.exotel.com",
    "api_token": "********",
    "app_id": "12345",
    "label": "Exotel Outbound",
    "phone_number": "+919999999999",
    "provider": "exotel"
}
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: '{"account_sid":"your-account-sid","api_key":"your-api-key","api_subdomain":"api.in.exotel.com","api_token":"********","app_id":"12345","label":"Exotel Outbound","phone_number":"+919999999999","provider":"exotel"}'
};

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  \"account_sid\": \"your-account-sid\",\n  \"api_key\": \"your-api-key\",\n  \"api_subdomain\": \"api.in.exotel.com\",\n  \"api_token\": \"********\",\n  \"app_id\": \"12345\",\n  \"label\": \"Exotel Outbound\",\n  \"phone_number\": \"+919999999999\",\n  \"provider\": \"exotel\"\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  \"account_sid\": \"your-account-sid\",\n  \"api_key\": \"your-api-key\",\n  \"api_subdomain\": \"api.in.exotel.com\",\n  \"api_token\": \"********\",\n  \"app_id\": \"12345\",\n  \"label\": \"Exotel Outbound\",\n  \"phone_number\": \"+919999999999\",\n  \"provider\": \"exotel\"\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  \"account_sid\": \"your-account-sid\",\n  \"api_key\": \"your-api-key\",\n  \"api_subdomain\": \"api.in.exotel.com\",\n  \"api_token\": \"********\",\n  \"app_id\": \"12345\",\n  \"label\": \"Exotel Outbound\",\n  \"phone_number\": \"+919999999999\",\n  \"provider\": \"exotel\"\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' => '{
  "account_sid": "your-account-sid",
  "api_key": "your-api-key",
  "api_subdomain": "api.in.exotel.com",
  "api_token": "********",
  "app_id": "12345",
  "label": "Exotel Outbound",
  "phone_number": "+919999999999",
  "provider": "exotel"
}',
  '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  \"account_sid\": \"your-account-sid\",\n  \"api_key\": \"your-api-key\",\n  \"api_subdomain\": \"api.in.exotel.com\",\n  \"api_token\": \"********\",\n  \"app_id\": \"12345\",\n  \"label\": \"Exotel Outbound\",\n  \"phone_number\": \"+919999999999\",\n  \"provider\": \"exotel\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "account_sid": "your-account-sid",
  "api_key": "your-api-key",
  "api_subdomain": "api.in.exotel.com",
  "api_token": "********",
  "app_id": "12345",
  "label": "Exotel Outbound",
  "phone_number": "+919999999999",
  "provider": "exotel"
] 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()
```