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

# फ़ोन नंबर इंपोर्ट करें

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

प्रोवाइडर कॉन्फ़िगरेशन (Twilio, Exotel या SIP trunk) से फ़ोन नंबर इंपोर्ट करें

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) — फ़ोन नंबर का लेबल
    - `phone_number` (string, required) — फ़ोन नंबर
    - `sid` (string, required) — Twilio Account SID (`AC` से शुरू) या API Key SID (`SK` से शुरू)
    - `token` (string, required) — `sid` के साथ जोड़ा गया secret: Account SID के लिए Account Auth Token या API Key SID के लिए API Key Secret
    - `account_auth_token` (string, optional) — Twilio Account Auth Token, जो इनबाउंड webhook हस्ताक्षरों को सत्यापित करने के लिए API Key इंपोर्ट हेतु आवश्यक है
    - `agent_id` (string, optional) — फ़ोन नंबर असाइन करने के लिए एजेंट ID
    - `enable_sms` (boolean, optional, default: true) — इनबाउंड SMS को ElevenLabs पर रूट करें। डिफ़ॉल्ट रूप से चालू है; जिन नंबरों में यह समर्थित नहीं है, उनके लिए SMS कॉन्फ़िगरेशन छोड़ने हेतु इसे false पर सेट करें।
    - `region_config` (RegionConfigRequest, optional) — Twilio अतिरिक्त क्षेत्र कॉन्फ़िगरेशन
    - `supports_inbound` (boolean, optional, default: true, deprecated) — यह फ़ील्ड डिप्रिकेटेड है और भविष्य में हटा दी जाएगी। क्या यह फ़ोन नंबर इनबाउंड कॉल सपोर्ट करता है।
    - `supports_outbound` (boolean, optional, default: true, deprecated) — यह फ़ील्ड डिप्रिकेटेड है और भविष्य में हटा दी जाएगी। क्या यह फ़ोन नंबर आउटबाउंड कॉल सपोर्ट करता है।
  - `provider`: `exotel`
    - `account_sid` (string, required) — Exotel Account SID
    - `api_key` (string, required) — Exotel API Key
    - `api_subdomain` (enum, required) — क्षेत्र-विशिष्ट Exotel API host
      - Allowed values: `api.in.exotel.com`, `api.exotel.com`
    - `api_token` (string, required) — Exotel API Token
    - `app_id` (string, required) — Calls/connect में इस्तेमाल होने वाला Exotel applet identifier
    - `label` (string, required) — फ़ोन नंबर का लेबल
    - `phone_number` (string, required) — फ़ोन नंबर
    - `agent_id` (string, optional) — फ़ोन नंबर असाइन करने के लिए एजेंट ID
    - `applet_url` (string, optional) — वैकल्पिक पूर्ण applet URL override। डिफ़ॉल्ट रूप से account SID और app ID से प्राप्त Exotel start_voice URL इस्तेमाल होता है।
    - `supports_inbound` (boolean, optional, default: true, deprecated) — यह फ़ील्ड डिप्रिकेटेड है और भविष्य में हटा दी जाएगी। क्या यह फ़ोन नंबर इनबाउंड कॉल सपोर्ट करता है।
    - `supports_outbound` (boolean, optional, default: true, deprecated) — यह फ़ील्ड डिप्रिकेटेड है और भविष्य में हटा दी जाएगी। क्या यह फ़ोन नंबर आउटबाउंड कॉल सपोर्ट करता है।
  - `provider`: `sip_trunk`
    - `label` (string, required) — फ़ोन नंबर का लेबल
    - `phone_number` (string, required) — फ़ोन नंबर
    - `agent_id` (string, optional) — फ़ोन नंबर असाइन करने के लिए एजेंट ID
    - `inbound_trunk_config` (InboundSipTrunkConfigRequestModel, optional)
    - `outbound_trunk_config` (OutboundSipTrunkConfigRequestModel, optional)
    - `supports_inbound` (boolean, optional, default: true, deprecated) — यह फ़ील्ड डिप्रिकेटेड है और भविष्य में हटा दी जाएगी। क्या यह फ़ोन नंबर इनबाउंड कॉल सपोर्ट करता है।
    - `supports_outbound` (boolean, optional, default: true, deprecated) — यह फ़ील्ड डिप्रिकेटेड है और भविष्य में हटा दी जाएगी। क्या यह फ़ोन नंबर आउटबाउंड कॉल सपोर्ट करता है।

## Response

### 200

सफल रिस्पॉन्स

- `phone_number_id` (string, required) — Phone entity ID

## Errors

### 422 Phone Numbers Create Request Unprocessable Entity Error

वैलिडेशन एरर

- `detail` (list of ValidationError, optional)

## Types

### RegionConfigRequest

- `region_id` (enum, required) — क्षेत्र ID
  - Allowed values: `us1`, `ie1`, `au1`
- `token` (string, required) — इस क्षेत्र के लिए Auth Token
- `edge_location` (enum, required) — इस रीजन के लिए एज लोकेशन
  - Allowed values: `ashburn`, `dublin`, `frankfurt`, `sao-paulo`, `singapore`, `sydney`, `tokyo`, `umatilla`, `roaming`

### InboundSipTrunkConfigRequestModel

- `allowed_addresses` (list of string, optional) — ट्रंक का उपयोग करने के लिए अनुमत IP पतों की सूची। सूची में हर आइटम एक अलग IP पता या CIDR ब्लॉक दर्शाने वाला Classless Inter-Domain Routing नोटेशन हो सकता है।
- `allowed_numbers` (list of string, optional) — ट्रंक का उपयोग करने के लिए अनुमत फ़ोन नंबर की सूची।
- `media_encryption` (enum, optional, default: allowed) — media (data layer) को एन्क्रिप्ट करना है या नहीं।
  - Allowed values: `disabled`, `allowed`, `required`
- `credentials` (SipTrunkCredentialsRequestModel, optional) — वैकल्पिक digest authentication credentials (username/password)।
- `remote_domains` (list of string, optional) — TLS सर्टिफ़िकेट को वैलिडेट करने के लिए इस्तेमाल होने वाले रिमोट SIP सर्वर के डोमेन।
- `attributes_to_headers` (map from string to string, optional) — attributes_to_headers के लिए डायनामिक वेरिएबल नाम और हेडर नाम का मैप

### OutboundSipTrunkConfigRequestModel

- `address` (string, required) — होस्टनेम या IP, जिस पर SIP INVITE भेजा जाता है।
- `transport` (enum, optional, default: auto) — SIP ट्रांसपोर्ट (सिग्नलिंग लेयर) के लिए इस्तेमाल किया जाने वाला प्रोटोकॉल।
  - Allowed values: `auto`, `udp`, `tcp`, `tls`
- `media_encryption` (enum, optional, default: allowed) — media (data layer) को एन्क्रिप्ट करना है या नहीं।
  - Allowed values: `disabled`, `allowed`, `required`
- `headers` (map from string to string, optional) — INVITE request के लिए SIP X-* headers। ये headers जैसे हैं वैसे ही भेजे जाते हैं और इस call की पहचान करने में मदद कर सकते हैं।
- `attributes_to_headers` (map from string to string, optional) — attributes_to_headers के लिए डायनामिक वेरिएबल नाम और हेडर नाम का मैप
- `credentials` (SipTrunkCredentialsRequestModel, optional) — वैकल्पिक digest authentication credentials (username/password)। न दिए जाने पर ACL authentication माना जाता है।
- `enabled_codecs` (list of enum, optional) — आउटबाउंड कॉल के लिए SDP में दिए जाने वाले मीडिया कोडेक। खाली होने पर सभी समर्थित कोडेक दिए जाते हैं।
  - Allowed values: `G722/8000`, `PCMU/8000`, `PCMA/8000`

### ValidationError

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

### SipTrunkCredentialsRequestModel

- `username` (string, required) — SIP trunk username
- `password` (string, optional) — SIP trunk password - निर्दिष्ट न होने पर अपरिवर्तित रहेगा

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