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

# APIキーを更新

PATCH https://api.elevenlabs.io/v1/service-accounts/{service_account_user_id}/api-keys/{api_key_id}
Content-Type: application/json

サービスアカウントの既存のAPIキーを更新します

Reference: https://elevenlabs.io/docs/api-reference/service-accounts/api-keys/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

- `service_account_user_id` (string, required)
- `api_key_id` (string, required)

### Body (application/json)

This endpoint expects a Body_edit_service_account_api_key_v1_service_accounts__service_account_user_id__api_keys__api_key_id__patch.

- `is_enabled` (BodyEditServiceAccountApiKeyV1ServiceAccountsServiceAccountUserIdApiKeysApiKeyIdPatchIsEnabled, optional, default: no_update) — APIキーを有効または無効にするかどうか。
- `name` (string, optional, nullable) — 使用するXI APIキーの名前（識別目的でのみ使用します）。
- `permissions` (BodyEditServiceAccountApiKeyV1ServiceAccountsServiceAccountUserIdApiKeysApiKeyIdPatchPermissions, optional, default: no_update) — XI APIの権限。
- `character_limit` (BodyEditServiceAccountApiKeyV1ServiceAccountsServiceAccountUserIdApiKeysApiKeyIdPatchCharacterLimit, optional, nullable, default: no_update) — XI APIキーの文字数上限。指定すると、このAPIキーの使用量は選択した値n文字／月に制限されます。この月間上限に達した後、料金が発生するリクエストは失敗します。
- `allowed_ips` (BodyEditServiceAccountApiKeyV1ServiceAccountsServiceAccountUserIdApiKeysApiKeyIdPatchAllowedIps, optional, default: no_update) — このAPIキーの使用を許可するIPアドレスまたはCIDR範囲のリスト。各エントリには、CIDR範囲（例：'10.0.0.0/24'）またはIPアドレス単体（/32または/128に正規化）が指定できます。作成時は、省略するかnullを渡すとすべてのIPを許可します。更新時は、省略すると許可リストを変更せず、"clear"を渡すと削除します。
- `third_party_disable_allowed` (BodyEditServiceAccountApiKeyV1ServiceAccountsServiceAccountUserIdApiKeysApiKeyIdPatchThirdPartyDisableAllowed, optional, default: no_update) — このキーの保持者がself-disableエンドポイントを介してこのキーを無効化できるかどうか。作成時には、省略するかnullを渡すとワークスペースのデフォルトが使用されます（エンタープライズ以外のプランでは有効、エンタープライズプランでは無効）。更新時には、省略すると変更されず、"clear"を渡すとワークスペースのデフォルトにリセットされます。self-disableアクセスが有効なワークスペースでのみ適用されます。
- `tts_concurrency_limit` (BodyEditServiceAccountApiKeyV1ServiceAccountsServiceAccountUserIdApiKeysApiKeyIdPatchTtsConcurrencyLimit, optional, nullable, default: no_update) — このAPIキーで同時に実行できるテキスト読み上げ／スピーチtoスピーチリクエストの最大数。エンタープライズのお客様のみ利用できます。
- `dubbing_concurrency_limit` (BodyEditServiceAccountApiKeyV1ServiceAccountsServiceAccountUserIdApiKeysApiKeyIdPatchDubbingConcurrencyLimit, optional, nullable, default: no_update) — このAPIキーで同時に実行できる吹き替えリクエストの最大数。エンタープライズのお客様のみ利用できます。
- `music_concurrency_limit` (BodyEditServiceAccountApiKeyV1ServiceAccountsServiceAccountUserIdApiKeysApiKeyIdPatchMusicConcurrencyLimit, optional, nullable, default: no_update) — このAPIキーで同時に実行できる音楽生成リクエストの最大数。エンタープライズのお客様のみ利用できます。

## Response

### 200

成功レスポンス。

- `any`

## Errors

### 422 Unprocessable Entity Error

検証エラー

- `detail` (list of ValidationError, optional)

## Types

### BodyEditServiceAccountApiKeyV1ServiceAccountsServiceAccountUserIdApiKeysApiKeyIdPatchIsEnabled

APIキーを有効または無効にするかどうか。

### BodyEditServiceAccountApiKeyV1ServiceAccountsServiceAccountUserIdApiKeysApiKeyIdPatchPermissions

XI APIの権限。

### BodyEditServiceAccountApiKeyV1ServiceAccountsServiceAccountUserIdApiKeysApiKeyIdPatchCharacterLimit

XI APIキーの文字数上限。指定すると、このAPIキーの使用量は選択した値n文字／月に制限されます。この月間上限に達した後、料金が発生するリクエストは失敗します。

### BodyEditServiceAccountApiKeyV1ServiceAccountsServiceAccountUserIdApiKeysApiKeyIdPatchAllowedIps

このAPIキーの使用を許可するIPアドレスまたはCIDR範囲のリスト。各エントリには、CIDR範囲（例：'10.0.0.0/24'）またはIPアドレス単体（/32または/128に正規化）が指定できます。作成時は、省略するかnullを渡すとすべてのIPを許可します。更新時は、省略すると許可リストを変更せず、"clear"を渡すと削除します。

### BodyEditServiceAccountApiKeyV1ServiceAccountsServiceAccountUserIdApiKeysApiKeyIdPatchThirdPartyDisableAllowed

このキーの保持者がself-disableエンドポイントを介してこのキーを無効化できるかどうか。作成時には、省略するかnullを渡すとワークスペースのデフォルトが使用されます（エンタープライズ以外のプランでは有効、エンタープライズプランでは無効）。更新時には、省略すると変更されず、"clear"を渡すとワークスペースのデフォルトにリセットされます。self-disableアクセスが有効なワークスペースでのみ適用されます。

### BodyEditServiceAccountApiKeyV1ServiceAccountsServiceAccountUserIdApiKeysApiKeyIdPatchTtsConcurrencyLimit

このAPIキーで同時に実行できるテキスト読み上げ／スピーチtoスピーチリクエストの最大数。エンタープライズのお客様のみ利用できます。

### BodyEditServiceAccountApiKeyV1ServiceAccountsServiceAccountUserIdApiKeysApiKeyIdPatchDubbingConcurrencyLimit

このAPIキーで同時に実行できる吹き替えリクエストの最大数。エンタープライズのお客様のみ利用できます。

### BodyEditServiceAccountApiKeyV1ServiceAccountsServiceAccountUserIdApiKeysApiKeyIdPatchMusicConcurrencyLimit

このAPIキーで同時に実行できる音楽生成リクエストの最大数。エンタープライズのお客様のみ利用できます。

### ValidationError

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

### ValidationErrorLocItems

## Examples

**Request**

```json
{}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/service-accounts/service_account_user_id/api-keys/api_key_id"

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/service-accounts/service_account_user_id/api-keys/api_key_id';
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/service-accounts/service_account_user_id/api-keys/api_key_id"

	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/service-accounts/service_account_user_id/api-keys/api_key_id")

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/service-accounts/service_account_user_id/api-keys/api_key_id")
  .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/service-accounts/service_account_user_id/api-keys/api_key_id', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/service-accounts/service_account_user_id/api-keys/api_key_id");
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/service-accounts/service_account_user_id/api-keys/api_key_id")! 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()
```