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

# 電話番号を更新

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

電話番号に割り当てられたエージェントを更新します

Reference: https://elevenlabs.io/docs/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) — 電話番号ID。電話番号をインポートすると返されます。

### Body (application/json)

This endpoint expects an UpdatePhoneNumberRequest.

- `agent_id` (string, optional, nullable)
- `label` (string, optional, nullable)
- `inbound_trunk_config` (InboundSIPTrunkConfigRequestModel, optional, nullable)
- `outbound_trunk_config` (OutboundSIPTrunkConfigRequestModel, optional, nullable)
- `livekit_stack` (enum, optional, nullable, default: standard)
  - Allowed values: `standard`, `static`
- `store_sip_messages` (boolean, optional, nullable)
- `environment` (string, optional, nullable) — この番号への通話で環境変数を解決するために使用する環境です。
- `branch_id` (string, optional, nullable) — この番号への通話に使用するエージェントブランチ。

## Response

### 200

成功レスポンス。

- `conversational_ai_phone_numbers_update_Response_200`
  - `provider`: `twilio` (GetPhoneNumberTwilioResponseModel)
    - `label` (string, required) — 電話番号のラベル
    - `phone_number` (string, required) — 電話番号
    - `phone_number_id` (string, required) — 電話番号のID
    - `assigned_agent` (PhoneNumberAgentInfo, optional, nullable) — 電話番号に割り当てられたエージェント。
    - `supports_inbound` (boolean, optional, default: true, deprecated) — このフィールドは非推奨であり、今後削除されます。この電話番号が着信通話に対応しているかどうかです。
    - `supports_outbound` (boolean, optional, default: true, deprecated) — このフィールドは非推奨であり、今後削除されます。この電話番号が発信通話に対応しているかどうかです。
  - `provider`: `exotel` (GetPhoneNumberExotelResponseModel)
    - `label` (string, required) — 電話番号のラベル
    - `phone_number` (string, required) — 電話番号
    - `phone_number_id` (string, required) — 電話番号のID
    - `assigned_agent` (PhoneNumberAgentInfo, optional, nullable) — 電話番号に割り当てられたエージェント。
    - `supports_inbound` (boolean, optional, default: true, deprecated) — このフィールドは非推奨であり、今後削除されます。この電話番号が着信通話に対応しているかどうかです。
    - `supports_outbound` (boolean, optional, default: true, deprecated) — このフィールドは非推奨であり、今後削除されます。この電話番号が発信通話に対応しているかどうかです。
  - `provider`: `sip_trunk` (GetPhoneNumberSIPTrunkResponseModel)
    - `label` (string, required) — 電話番号のラベル
    - `livekit_stack` (enum, required, default: standard) — この番号に使用するLivekitスタックのタイプ。
      - Allowed values: `standard`, `static`
    - `phone_number` (string, required) — 電話番号
    - `phone_number_id` (string, required) — 電話番号のID
    - `assigned_agent` (PhoneNumberAgentInfo, optional, nullable) — 電話番号に割り当てられたエージェント。
    - `inbound_trunk` (GetPhoneNumberInboundSIPTrunkConfigResponseModel, optional, nullable) — 着信SIPトランクの設定（設定されている場合）。
    - `outbound_trunk` (GetPhoneNumberOutboundSIPTrunkConfigResponseModel, optional, nullable) — 発信SIPトランクの設定（設定されている場合）。
    - `store_sip_messages` (boolean, optional, default: true) — この電話番号のSIPメッセージを保存するかどうか。
    - `provider_config` (GetPhoneNumberOutboundSIPTrunkConfigResponseModel, optional, nullable, deprecated) — 電話番号のSIPトランク設定詳細
    - `supports_inbound` (boolean, optional, default: true, deprecated) — このフィールドは非推奨であり、今後削除されます。この電話番号が着信通話に対応しているかどうかです。
    - `supports_outbound` (boolean, optional, default: true, deprecated) — このフィールドは非推奨であり、今後削除されます。この電話番号が発信通話に対応しているかどうかです。

## Errors

### 422 Unprocessable Entity Error

検証エラー

- `detail` (list of ValidationError, optional)

## Types

### InboundSIPTrunkConfigRequestModel

- `allowed_addresses` (list of string, optional, nullable) — トランクの使用を許可するIPアドレスのリスト。リストの各項目には、個別のIPアドレスまたはCIDRブロックを表すClassless Inter-Domain Routing表記を指定できます。
- `allowed_numbers` (list of string, optional, nullable) — トランクの使用を許可する電話番号のリスト。
- `media_encryption` (enum, optional, default: allowed) — メディアを暗号化するかどうか（データレイヤー）。
  - Allowed values: `disabled`, `allowed`, `required`
- `credentials` (SIPTrunkCredentialsRequestModel, optional, nullable) — 任意のダイジェスト認証情報（ユーザー名／パスワード）です。
- `remote_domains` (list of string, optional, nullable) — TLS証明書の検証に使用するリモートSIPサーバーのドメイン。
- `attributes_to_headers` (map from string to string, optional) — attributes_to_headers用の動的変数名からヘッダー名へのマップ

### OutboundSIPTrunkConfigRequestModel

- `address` (string, required) — SIP INVITEの送信先ホスト名またはIPです。
- `transport` (enum, optional, default: auto) — SIPトランスポート（シグナリング層）に使用するプロトコル。
  - Allowed values: `auto`, `udp`, `tcp`, `tls`
- `media_encryption` (enum, optional, default: allowed) — メディアを暗号化するかどうか（データレイヤー）。
  - Allowed values: `disabled`, `allowed`, `required`
- `headers` (map from string to string, optional) — INVITEリクエストのSIP X-*ヘッダーです。これらのヘッダーはそのまま送信され、この通話の識別に役立つ場合があります。
- `attributes_to_headers` (map from string to string, optional) — attributes_to_headers用の動的変数名からヘッダー名へのマップ
- `credentials` (SIPTrunkCredentialsRequestModel, optional, nullable) — 任意のダイジェスト認証情報（ユーザー名／パスワード）です。指定しない場合はACL認証を使用します。
- `enabled_codecs` (list of enum, optional) — 発信通話のSDPで提供するメディアコーデック。空の場合、サポートされているすべてのコーデックが提供されます。
  - Allowed values: `G722/8000`, `PCMU/8000`, `PCMA/8000`

### PhoneNumberAgentInfo

- `agent_id` (string, required) — エージェントのID
- `agent_name` (string, required) — エージェントの名前。
- `environment` (string, optional, nullable) — この番号への通話で環境変数を解決するために使用する環境です。
- `branch_id` (string, optional, nullable) — この番号への通話に使用するエージェントブランチ。

### GetPhoneNumberInboundSIPTrunkConfigResponseModel

- `allowed_addresses` (list of string, required) — トランクの使用を許可するIPアドレスのリスト。リストの各項目には、個別のIPアドレスまたはCIDRブロックを表すClassless Inter-Domain Routing表記を指定できます。
- `allowed_numbers` (list of string, required, nullable) — トランクの使用を許可する電話番号のリスト。
- `media_encryption` (enum, required, default: allowed)
  - Allowed values: `disabled`, `allowed`, `required`
- `has_auth_credentials` (boolean, required) — 認証情報が設定されているかどうか。
- `username` (string, optional, nullable) — SIPトランクのユーザー名（利用可能な場合）
- `remote_domains` (list of string, optional, nullable) — TLS証明書の検証に使用するリモートSIPサーバーのドメイン。
- `attributes_to_headers` (map from string to string, optional) — attributes_to_headers用の動的変数名からヘッダー名へのマップ

### GetPhoneNumberOutboundSIPTrunkConfigResponseModel

電話番号のSIPトランク設定詳細

- `address` (string, required) — SIP INVITEの送信先ホスト名またはIP
- `transport` (enum, required, default: auto) — SIPトランスポートに使用するプロトコル
  - Allowed values: `auto`, `udp`, `tcp`, `tls`
- `media_encryption` (enum, required, default: allowed) — メディアを暗号化するかどうか（データレイヤー）。
  - Allowed values: `disabled`, `allowed`, `required`
- `has_auth_credentials` (boolean, required) — 認証情報が設定されているかどうか。
- `headers` (map from string to string, optional) — INVITEリクエストのSIPヘッダー
- `attributes_to_headers` (map from string to string, optional) — attributes_to_headers用の動的変数名からヘッダー名へのマップ
- `username` (string, optional, nullable) — SIPトランクのユーザー名（利用可能な場合）
- `has_outbound_trunk` (boolean, optional, default: false) — LiveKit SIPアウトバウンドトランクが設定されているかどうか。
- `enabled_codecs` (list of enum, optional) — 発信通話のSDPで提供するメディアコーデック。空の場合、サポートされているすべてのコーデックが提供されます。
  - Allowed values: `G722/8000`, `PCMU/8000`, `PCMA/8000`

### ValidationError

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

### SIPTrunkCredentialsRequestModel

- `username` (string, required) — SIPトランクのユーザー名
- `password` (string, optional, nullable) — SIPトランクのパスワード。指定しない場合は変更されません。

### ValidationErrorLocItems

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "provider": "twilio",
  "label": "Customer Support",
  "phone_number": "+1234567890",
  "phone_number_id": "phone_123"
}
```

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