---
title: 用於終端客戶歸屬的使用者設定檔
url: https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles
description: 將 API 請求歸屬到您的平台所服務的終端客戶，讓安全強制措施可以只套用於單一設定檔，而非您的整個組織。
---

使用者設定檔（簡稱「設定檔」）會告訴 Anthropic 每個 API 請求是代表您的哪一位終端客戶發出的。如此一來，安全執法措施（例如限制或封鎖）便可以只套用於單一終端客戶，而非您的整個組織。發生這種情況時，您的其餘流量不會受到影響。

如果您經營平台或閘道，或轉售 API 存取權，您為終端客戶發送的請求都會以您的組織名義送達。Anthropic 會對 API 流量執行自動化的「safety classifiers」（安全分類器）。如果請求上沒有設定檔，單一終端客戶就可能觸發套用於您整個組織的強制措施。

您只需使用 `POST /v1/user_profiles` 為每位終端客戶註冊一次，並儲存其傳回的 `uprof_` ID。之後，在您代表該終端客戶發出的每個請求中，都在 `anthropic-user-profile-id` 標頭中傳送該 ID。

就其本身而言，設定檔不會改變計費或定價。 如果您使用 [Linked billing](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/oauth-apps/organization-billing-connections)，設定檔也是您用來識別要計費之客戶的方式。

## 決定誰需要設定檔

每位終端客戶只有一個設定檔，因此一家公司只有一個涵蓋整家公司的設定檔，而不是為公司中的每個人各建立一個。在您為該公司中任何人發出的每個請求上，都傳送該設定檔的 ID。若還要告訴 Anthropic 請求來自哪一個人，請參閱[識別公司內的一個人](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles#identify-individual-users-within-a-company)。

設定檔的 `access_type` 欄位會說明終端客戶是使用您的產品，還是向您購買 API 存取權（例如透過您的閘道）：

| 終端客戶 | `access_type` |
| ----- | ----- |
| 使用您的產品 | `application`（預設值，當您省略 `access_type` 時即會設定） |
| 是向您購買 API 存取權的公司 | `passthrough`（非預設值，因此您必須傳送） |

請勿為以下任一對象建立設定檔：

* **您自己的用量：** Anthropic 會將沒有設定檔 ID 的請求視為您自己的用量。請將該用量保留在獨立的組織中，如[開始之前](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles#before-you-begin)所述。
* **您組織中的工作區：** 設定檔屬於您的組織，而非工作區，因此該設定檔的 ID 可用於透過組織中任何工作區發出的請求。例外情況是透過[建立工作區](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/api/organization/workspaces/create)或[更新工作區](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/api/organization/workspaces/update)中的 `user_profile_id` 附加了不同設定檔的工作區。透過該工作區發出的每個推論請求都必須帶有所附加設定檔的 ID，API 會拒絕帶有其他 ID 或沒有 ID 的請求。

## 設定檔包含的內容以及 Anthropic 如何使用它

設定檔只包含您傳送的終端客戶相關資訊，以及 Anthropic 設定的任何[計畫狀態](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles-verification-portal#after-the-end-customer-links-the-profile)或強制措施狀態。它不包含對話內容。Anthropic 會使用您傳送的詳細資訊來歸屬請求、監控濫用行為、執行[使用政策](https://code.saschaberens.de/_h/www.anthropic.com/legal/aup)，以及啟用受信任存取計畫的申請與存取。Anthropic 不會驗證這些詳細資訊。

Anthropic 會依照[隱私權政策](https://code.saschaberens.de/_h/www.anthropic.com/legal/privacy)處理設定檔。

## 開始之前

您可以在下列其中一處建立和管理設定檔：

* Claude API 上的組織。
* [Claude Platform on AWS](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/claude-platform-on-aws) 上的組織。呼叫的主體需要具備[使用者設定檔 IAM 動作](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/api/claude-platform-on-aws-iam-actions#user-profiles)。
* [Claude Models on Google Cloud (Anthropic managed)](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/claude-models-on-google-cloud/anthropic-managed) 上的組織，您可以在該處建立、擷取、列出及更新設定檔。請使用最新版本的 [Claude Models on Google Cloud (Anthropic managed) SDK 用戶端](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/claude-models-on-google-cloud/anthropic-managed#install-an-sdk)，或直接呼叫[組織層級的基礎 URL](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/claude-models-on-google-cloud/anthropic-managed#making-requests)，並使用 Google Cloud 憑證而非 API 金鑰。

Claude Models on Google Cloud (Google managed) 和 Amazon Bedrock 上無法使用 `/v1/user_profiles` 端點。如果您的推論在這些平台上執行，請在 Claude API 或 Claude Platform on AWS 上的組織中建立設定檔。在 Amazon Bedrock 上，設定檔是否適用取決於模型。請參閱[在 Claude Models on Google Cloud (Google managed) 和 Amazon Bedrock 上歸屬請求](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles#attribute-requests-on-amazon-bedrock-and-google-cloud)。

如果您的推論執行於[託管在 Anthropic 上](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/claude-in-microsoft-foundry#hosting-options)的 [Microsoft Foundry](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/claude-in-microsoft-foundry) 部署，請在 Claude API 上的組織中建立您的設定檔。Anthropic 必須先將您的 Foundry 資源連結至該組織，您的 Foundry 請求才能使用這些設定檔 ID。如需申請此連結，請與您的 Anthropic 客戶團隊聯絡。`/v1/user_profiles` 端點不適用於 Microsoft Foundry。

請將您為終端客戶發送的流量保留在一個組織中，並將您自己的內部用量保留在另一個組織中。設定檔屬於組織而非工作區，因此在同一組織中使用不同的工作區是不夠的。只有用於終端客戶流量的組織需要使用者設定檔。若要在 Claude API 上建立另一個組織，請參閱 Claude 說明中心內[在 Claude Console 中建立和管理工作區](https://code.saschaberens.de/_h/support.claude.com/en/articles/9796807)的「How to create a new organization」章節。

範例使用 API 金鑰呼叫 Claude API。您不需要 [Admin API 金鑰](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/admin-api-keys)。在 Claude Platform on AWS 上，請使用其基礎 URL 和驗證方式。

## 為每位終端客戶建立設定檔

為每位您將其流量傳送至 Claude 的終端客戶建立一個設定檔。請在您的客戶導入流程中建立一次即可。`POST /v1/user_profiles` 並非「idempotent」（冪等）操作，因此每次呼叫都會建立新的設定檔，即使 `reference_id` 與現有設定檔相符也是如此。如果您已有尚未建立設定檔的終端客戶，請參閱本節稍後關於註冊現有客戶群的指引。

以下範例註冊一家向您購買 API 存取權的公司，因此該請求將 `access_type` 設為 `passthrough`。若是 `application` 設定檔，請省略 `access_type`。[決定誰需要設定檔](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles#decide-who-gets-a-profile)說明了應使用哪種存取類型。

<CodeGroup>
  ```bash cURL
  curl https://code.saschaberens.de/_h/api.anthropic.com/v1/user_profiles \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2026-10-21" \
    -H "content-type: application/json" \
    -d '{
      "name": "Acme Analytics, Inc.",
      "access_type": "passthrough",
      "external_user_details": {
        "reference_id": "cust-8f2a1c",
        "country": "US"
      }
    }'
  ```

  ```bash CLI
  ant user-profiles create \
    --name "Acme Analytics, Inc." \
    --access-type passthrough \
    --external-user-details '{reference_id: cust-8f2a1c, country: US}'
  ```

  ```python Python
  client = anthropic.Anthropic()

  profile = client.user_profiles.create(
      name="Acme Analytics, Inc.",
      access_type="passthrough",
      external_user_details={"reference_id": "cust-8f2a1c", "country": "US"},
  )

  print(profile.id)
  ```

  ```typescript TypeScript
  const client = new Anthropic();

  const profile = await client.userProfiles.create({
    name: "Acme Analytics, Inc.",
    access_type: "passthrough",
    external_user_details: { reference_id: "cust-8f2a1c", country: "US" }
  });

  console.log(profile.id);
  ```

  ```csharp C#
  AnthropicClient client = new();

  var profile = await client.UserProfiles.Create(new()
  {
      Name = "Acme Analytics, Inc.",
      AccessType = UserProfileAccessType.Passthrough,
      ExternalUserDetails = new()
      {
          ReferenceID = "cust-8f2a1c",
          Country = "US"
      }
  });

  Console.WriteLine(profile.ID);
  ```

  ```go Go
  client := anthropic.NewClient()

  profile, err := client.UserProfiles.New(context.Background(), anthropic.UserProfileNewParams{
  	Name:       anthropic.String("Acme Analytics, Inc."),
  	AccessType: anthropic.UserProfileAccessTypePassthrough,
  	ExternalUserDetails: anthropic.UserProfileExternalUserDetailsParams{
  		ReferenceID: anthropic.String("cust-8f2a1c"),
  		Country:     anthropic.String("US"),
  	},
  })
  if err != nil {
  	log.Fatal(err)
  }

  fmt.Println(profile.ID)
  ```

  ```java Java
  import com.anthropic.models.userprofiles.UserProfileAccessType;
  import com.anthropic.models.userprofiles.UserProfileCreateParams;
  import com.anthropic.models.userprofiles.UserProfileExternalUserDetailsParams;

  void main() {
      AnthropicClient client = AnthropicOkHttpClient.fromEnv();

      var params = UserProfileCreateParams.builder()
          .name("Acme Analytics, Inc.")
          .accessType(UserProfileAccessType.PASSTHROUGH)
          .externalUserDetails(UserProfileExternalUserDetailsParams.builder()
              .referenceId("cust-8f2a1c")
              .country("US")
              .build())
          .build();
      var profile = client.userProfiles().create(params);

      IO.println(profile.id());
      // ...
  }
  ```

  ```php PHP
  $client = new Client();

  $profile = $client->userProfiles->create(
      name: 'Acme Analytics, Inc.',
      accessType: 'passthrough',
      externalUserDetails: ['referenceID' => 'cust-8f2a1c', 'country' => 'US'],
  );

  echo $profile->id, PHP_EOL;
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  profile = client.user_profiles.create(
    name: "Acme Analytics, Inc.",
    access_type: :passthrough,
    external_user_details: { reference_id: "cust-8f2a1c", country: "US" }
  )

  puts profile.id
  ```
</CodeGroup>

回應即為新的設定檔：

```json
{
  "type": "user_profile",
  "id": "uprof_011CZkZCu8hGbp5mYRQgUmz9",
  "name": "Acme Analytics, Inc.",
  "access_type": "passthrough",
  "external_user_details": {
    "reference_id": "cust-8f2a1c",
    "onboarded_at": null,
    "account_status": null,
    "entity_type": null,
    "country": "US",
    "name_hash": null,
    "email_hash": null
  },
  "metadata": {},
  "programs": {
    "cyber": null
  },
  "created_at": "2026-03-15T10:00:00Z",
  "updated_at": "2026-03-15T10:00:00Z"
}
```

請將 `id` 儲存在您的客戶記錄中，並讓您的服務執行個體從該處讀取，而不是各自建立設定檔。您可以透過該 `id` 擷取、更新和刪除設定檔。`programs` 欄位為唯讀，歸屬不會使用它。它記錄終端客戶在 Anthropic 執行的每個計畫中的狀態。關於其值的意義，請參閱[哪些計畫適用於設定檔](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles-verification-portal#after-the-end-customer-links-the-profile)。[檢查 Anthropic 是否已限制或封禁某個設定檔](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles#check-whether-anthropic-has-restricted-or-banned-a-profile)說明了 `enforcement_status` 和 `enforcement_actions` 欄位。

組織中的設定檔數量沒有上限，但設定檔的建立受到速率限制。在大量註冊現有客戶群之前，請聯絡您的 Anthropic 客戶團隊。

### 要告訴 Anthropic 哪些終端客戶資訊

每個欄位都是選填的。您可以傳送 `name`、`metadata`，以及 `external_user_details` 中的這些欄位：`entity_type`、`country`、`reference_id`、`onboarded_at`、`account_status`、`name_hash` 和 `email_hash`。[建立設定檔](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/api/user_profiles/create)參考文件說明了每個欄位的類型、格式和長度限制。

設定欄位時請遵循以下規則：

* **未知的值：** 如果您不知道某個值，請省略它，而不是傳送預留位置值。您之後可以取代 `external_user_details` 中的值，但無法清除它。
* **名稱：** 在 `name` 中，請傳送終端客戶的真實名稱。若是公司，且您知道該公司的法定名稱，請傳送該名稱。
* **您無法分享的名稱和電子郵件地址：** 請省略 `name`，改為傳送 `external_user_details.name_hash`。對於電子郵件地址，請傳送 `external_user_details.email_hash`，因為設定檔沒有用於存放電子郵件地址本身的欄位。
* **國家：** 在 `country` 中，請傳送終端客戶的國家，而非您的國家。
* **您自己的 ID：** 在 `reference_id` 中，請傳送您為該終端客戶使用的穩定識別碼。它不必是唯一的。
* **雜湊值：** 請使用您選擇的函式自行計算雜湊值。這些雜湊值可讓 Anthropic 知道您的哪些設定檔具有相同的名稱或電子郵件地址。只有以相同方式計算的值才會相符，因此對於每個設定檔，請使用相同的函式，並以相同方式處理大小寫和空白。

## 歸屬每個請求

在您代表終端客戶發出的每個請求中，請於 `anthropic-user-profile-id` 標頭中傳送設定檔 ID。SDK 和 CLI 提供了一個會替您傳送此標頭的引數：`user_profile_id` (java: `userProfileId`; php: `userProfileID`; csharp, go: `UserProfileID`; cli: `--user-profile-id`)。

<CodeGroup>
  ```bash cURL
  curl https://code.saschaberens.de/_h/api.anthropic.com/v1/messages \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2026-10-21" \
    -H "anthropic-user-profile-id: $PROFILE_ID" \
    -H "content-type: application/json" \
    -d '{
      "model": "claude-opus-5-5",
      "max_tokens": 1024,
      "messages": [
        {"role": "user", "content": "Hello, Claude"}
      ]
    }'
  ```

  ```bash CLI
  ant messages create \
    --model claude-opus-5-5 \
    --max-tokens 1024 \
    --message '{role: user, content: "Hello, Claude"}' \
    --user-profile-id "$PROFILE_ID"
  ```

  ```python Python
  client = anthropic.Anthropic()

  message = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=1024,
      messages=[{"role": "user", "content": "Hello, Claude"}],
      user_profile_id=profile_id,
  )

  print(message)
  ```

  ```typescript TypeScript
  const client = new Anthropic();

  const message = await client.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 1024,
    messages: [{ role: "user", content: "Hello, Claude" }],
    user_profile_id: profileId
  });

  console.log(message);
  ```

  ```csharp C#
  AnthropicClient client = new();

  var parameters = new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 1024,
      Messages = [new UserMessageParam { Content = "Hello, Claude" }],
      UserProfileID = profileId
  };
  var message = await client.Messages.Create(parameters);

  Console.WriteLine(message);
  ```

  ```go Go
  client := anthropic.NewClient()

  message, err := client.Messages.New(context.Background(), anthropic.MessageNewParams{
  	Model:     anthropic.ModelClaudeOpus5_5,
  	MaxTokens: 1024,
  	Messages: []anthropic.MessageParam{
  		anthropic.NewUserMessage(anthropic.NewTextBlock("Hello, Claude")),
  	},
  	UserProfileID: anthropic.String(profileID),
  })
  if err != nil {
  	log.Fatal(err)
  }

  fmt.Println(message)
  ```

  ```java Java
  import com.anthropic.models.messages.MessageCreateParams;
  import com.anthropic.models.messages.Model;

  void main() {
      AnthropicClient client = AnthropicOkHttpClient.fromEnv();

      var params = MessageCreateParams.builder()
          .model(Model.CLAUDE_OPUS_5_5)
          .maxTokens(1024L)
          .addUserMessage("Hello, Claude")
          .userProfileId(profileId)
          .build();
      var message = client.messages().create(params);

      IO.println(message);
  }
  ```

  ```php PHP
  $client = new Client();

  $message = $client->messages->create(
      maxTokens: 1024,
      messages: [['role' => 'user', 'content' => 'Hello, Claude']],
      model: Model::CLAUDE_OPUS_5_5,
      userProfileID: $profileId,
  );

  echo json_encode($message, JSON_PRETTY_PRINT), PHP_EOL;
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  message = client.messages.create(
    model: Anthropic::Model::CLAUDE_OPUS_5_5,
    max_tokens: 1024,
    messages: [{ role: "user", content: "Hello, Claude" }],
    user_profile_id: profile_id
  )

  puts message
  ```
</CodeGroup>

此標頭在 [token 計數](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/token-counting)、[Message Batches](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/batch-processing) 和 [OpenAI SDK 相容性](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/cli-sdks-libraries/libraries/openai-sdk)請求上的運作方式相同。在批次上，它會套用於批次中的每個請求。

Claude API、Claude Platform on AWS、Claude Models on Google Cloud (Anthropic managed)，以及託管在 Anthropic 上的 Microsoft Foundry 部署，都會在每個請求上檢查 ID。如果 ID 格式錯誤或不屬於發送請求的組織，API 會傳回 `400` `invalid_request_error`。根據預設，這些平台只接受來自建立該設定檔之組織的請求所帶的設定檔 ID。這表示如果您以多個組織的名義發送流量，例如一個在 Claude API 上、一個在 Claude Platform on AWS 上，那麼來自未建立該設定檔之組織的請求也會收到相同的 `400`。對於託管在 Anthropic 上的 Microsoft Foundry 部署，每個設定檔 ID 都會收到這個 `400`，直到 Anthropic [將您的 Foundry 資源連結](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles#before-you-begin)至建立該設定檔的組織為止。

Message Batches 是例外：建立批次時只會檢查 ID 的格式。如果格式正確的 ID 不屬於發送批次的組織，批次仍會被建立，但其中的每個請求隨後都會失敗，並產生包含相同 `invalid_request_error` 的 `errored` 結果。

### 識別公司內的一個人

公司的設定檔識別的是該公司，而非發出請求的人員。如果請求來自您可以識別的某一個人，也請在 Messages 請求上將 [`metadata.user_id`](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/api/messages/create) 設定為該人員的識別碼。此欄位位於請求本身的 `metadata` 物件中，而非設定檔的 `metadata` 欄位中。該識別碼為選填，可協助 Anthropic 偵測單一人員的濫用行為。

### 在 Claude Models on Google Cloud (Google managed) 和 Amazon Bedrock 上歸屬請求

任一存取類型的設定檔 ID 也適用於 Claude Models on Google Cloud (Google managed)。在 Amazon Bedrock 上，它適用於下表之後列出的模型。您只會使用 Anthropic 組織的憑證來建立和管理設定檔。推論仍使用您現有的 AWS 或 Google Cloud 憑證。

| 平台 | 建立設定檔 | 傳送設定檔 ID 的位置 |
| ----- | ----- | ----- |
| Claude API | 是 | `anthropic-user-profile-id` 標頭 |
| [Claude Platform on AWS](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/claude-platform-on-aws) | 是 | `anthropic-user-profile-id` 標頭 |
| [Microsoft Foundry](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/claude-in-microsoft-foundry)，僅限託管在 Anthropic 上的部署 | 否。請在 Claude API 上建立設定檔，並[要求 Anthropic 連結您的 Foundry 資源](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles#before-you-begin)。 | `anthropic-user-profile-id` 標頭 |
| [Claude Models on Google Cloud (Anthropic managed)](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/claude-models-on-google-cloud/anthropic-managed) | 是 | `anthropic-user-profile-id` 標頭 |
| [Claude Models on Google Cloud (Google managed)](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/claude-models-on-google-cloud/google-managed) | 否。請在 Claude API 或 Claude Platform on AWS 上建立。 | `anthropic-user-profile-id` 標頭 |
| [Amazon Bedrock 中的 Claude (`bedrock-mantle`)](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/claude-in-amazon-bedrock) 和 [Amazon Bedrock 上的 Claude (`bedrock-runtime`)](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/claude-on-amazon-bedrock-legacy)，適用於此表格後列出的模型 | 否。請在 Claude API 或 Claude Platform on AWS 上建立。 | 請求主體中的 `user_profile_id` 欄位 |

設定檔適用於 [Amazon Bedrock 中的 Claude (`bedrock-mantle`)](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/claude-in-amazon-bedrock)，以及 [Amazon Bedrock 上的 Claude (`bedrock-runtime`)](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/claude-on-amazon-bedrock-legacy) 上的 `InvokeModel`，包括使用 `InvokeModelWithResponseStream` 的串流。下列清單中的模型並非每個都同時在這兩個端點上提供。請在以下這些模型的請求上傳送設定檔 ID：

* Claude 4.7 及更新的模型
* Claude Sonnet 4.6
* Claude Haiku 4.5

對於任何其他模型的請求，請勿包含該 ID，因為帶有該 ID 的請求可能會以 `400` 失敗。Amazon Bedrock 批次推論工作中也請勿包含它。沒有該 ID，這些請求仍可運作，但會在未歸屬的情況下通過。

`Converse` API 不支援使用者設定檔。

在 Amazon Bedrock 上，請將 ID 放在請求主體的最上層。以下範例顯示 `bedrock-mantle` 端點的請求主體：

```json
{
  "model": "anthropic.claude-opus-5-5",
  "max_tokens": 1024,
  "user_profile_id": "uprof_011CZkZCu8hGbp5mYRQgUmz9",
  "messages": [{ "role": "user", "content": "Hello, Claude" }]
}
```

如果您直接呼叫 `InvokeModel`，模型 ID 會放在請求的 URL 中（在 AWS SDK 中為 `modelId`），而非主體中。主體還需要 `anthropic_version` 欄位，例如 `"anthropic_version": "bedrock-2023-05-31"`。

如果您透過 `AnthropicBedrock` (csharp: `AnthropicBedrockClient`; go: `bedrock.WithLoadDefaultConfig()`; java: `BedrockBackend`; php: `Bedrock\Client`; ruby: `Anthropic::BedrockClient`) 呼叫 `InvokeModel`，[最新版本的 SDK](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/cli-sdks-libraries/overview#latest-versions) 會替您將[使用者設定檔引數](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles#attribute-each-request)放入請求主體。較早的版本可能會未將 ID 放入主體。此時請求會成功，但會在未歸屬的情況下通過。

對 Claude Sonnet 4.6 和 Claude Haiku 4.5 發出的 `InvokeModel` 請求，在最新版 SDK 所傳送的 API 版本上可能會以 `400` 失敗。對於這些模型，請繼續使用 SDK 的前一個主要版本。若要安裝該版本，請使用[安裝用於存取 Bedrock 的 SDK](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/claude-on-amazon-bedrock-legacy#install-an-sdk-for-accessing-bedrock) 中的命令。

如果您透過較早版本的 SDK 呼叫 `InvokeModel`，請使用 `extra_body` (typescript: `body`; php: `extraBodyParams`; java: `.putAdditionalBodyProperty()`; go: `option.WithJSONSet()`; csharp: `MessageCreateParams.FromRawUnchecked()`) 自行將 `user_profile_id` 加入主體。加入時必須保持主體的其餘部分完整。SDK 會根據主體的 `model`，以及（若您使用串流）`stream: true` 來建構 URL。

如果您從[發送請求](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/build-with-claude/claude-on-amazon-bedrock-legacy#making-requests)中的範例開始，請將其模型變更為[接受設定檔 ID 的模型](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles#attribute-requests-on-amazon-bedrock-and-google-cloud)之一。

請將您的雲端帳戶連結到建立您設定檔的 Anthropic 組織。在 Amazon Bedrock 上，請連結每個發送請求的 AWS 帳戶。在 Claude Models on Google Cloud (Google managed) 上，請連結每個發送請求的 Google Cloud 專案。對於每一個帳戶或專案，請依照以下步驟操作：

1. 該組織的管理員在 `portal.anthropic.com` 的 Verification Portal 中，於 **Linked accounts（已連結的帳戶）** 下開始連結。
2. 能夠管理該 AWS 帳戶或 Google Cloud 專案中 IAM 的人員執行入口網站提供的命令。
3. 管理員在入口網站中完成驗證。

適用於設定檔的計畫，只有在帳戶完成連結且入口網站將其顯示為 **Linked（已連結）** 之後，才會套用至該帳戶的請求。這些計畫包括終端客戶[將設定檔連結至其組織](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles-verification-portal)後，該終端客戶組織獲准參與的計畫；對於 Cyber Verification Program 存取層級，則還需終端客戶在入口網站中為該設定檔啟用這些層級。

Claude Models on Google Cloud (Google managed) 會檢查 ID 的格式，但不會查詢設定檔。Amazon Bedrock 在[接受設定檔 ID 的模型](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles#attribute-requests-on-amazon-bedrock-and-google-cloud)上也是如此。這兩個平台都會以 `400` 拒絕格式錯誤的 ID。兩者都接受任何格式正確的 ID，因此成功的回應並不代表該 ID 與某個設定檔相符。沒有 ID 的請求會在未歸屬的情況下通過，如果它觸發強制措施，該措施會套用於您的整個組織。

## 檢查 Anthropic 是否已限制或封禁某個設定檔

設定檔的 `enforcement_status` 和 `enforcement_actions` 欄位會回報 Anthropic 對終端客戶開啟中的「enforcement action」（執行措施）。執行措施是指限制或封禁。每個傳回設定檔的回應都包含這兩個欄位：建立、擷取、更新，以及清單中的每個設定檔。傳送這些請求時，請勿在 `anthropic-beta` 標頭中加入任何 `user-profiles-` 值，因為 `user-profiles-2026-09-04` 及更早的值會省略這些欄位。以下範例顯示擷取的設定檔上的這些欄位，其他欄位則予以省略：

```json
{
  "type": "user_profile",
  "id": "uprof_011CZkZCu8hGbp5mYRQgUmz9",
  "enforcement_status": "restricted",
  "enforcement_actions": [
    {
      "type": "restriction",
      "id": "enac_011CZkZEq4TnWb7xLfRgPm2v",
      "reason": "fraud_or_abuse",
      "action": null,
      "opened_at": "2026-10-02T19:30:00Z",
      "expires_at": null
    }
  ]
}
```

`enforcement_status` 以單一值總結開啟中的措施：

* `unrestricted`：沒有開啟中的措施。
* `restricted`：至少有一項措施開啟中，且其中沒有任何一項是封禁。
* `banned`：有一項封禁開啟中。

當措施開啟中時，Anthropic 會拒絕部分或全部帶有該設定檔 ID 的推論請求。

`enforcement_actions` 列出開啟中的措施，沒有任何措施時則為空。已結束的措施會從清單中移除。每項措施都有以下欄位：

* `type`：`restriction` 或 `ban`。
* `id`：措施的 ID，以 `enac_` 開頭。
* `reason`：Anthropic 開啟該措施的原因。其值為 `unsupported_region`、`fraud_or_abuse`、`high_harm`、`usage_policy_violation`、`account_compromise` 或 `unspecified` 之一。
* `action`：終端客戶可以採取哪些行動來解除該措施，若無法採取任何行動則為 `null`。
* `opened_at`：Anthropic 開啟該措施的時間。
* `expires_at`：措施自行結束的時間，若沒有結束日期則為 `null`。

若要檢查設定檔，請使用 [`GET /v1/user_profiles/{id}`](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/api/user_profiles/retrieve) 擷取它。若要找出有開啟中措施的設定檔，請使用 `enforcement_status[]=restricted` 和 `enforcement_status[]=banned` [列出您的設定檔](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/api/user_profiles/list)。若要在措施開啟或結束時收到事件，請參閱[組織 webhook](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/organization-webhooks)。若沒有事件，請將這兩個欄位與您上次看到的值進行比較。變更不一定會更新 `updated_at`。

這兩個欄位由 Anthropic 設定。如果建立或更新請求包含其中任一欄位，API 會傳回 `400`。`enforcement_status` 與 `external_user_details.account_status` 是分開的，後者記錄的是您自己對該帳戶的決定。

Anthropic 可能會新增值。請將無法辨識的 `enforcement_status` 視為 `restricted`，將無法辨識的 `type` 視為 `restriction`，將無法辨識的 `reason` 視為 `unspecified`，並將無法辨識的 `action` 視為 `null`。

在 Claude Platform on AWS 上，這兩個欄位不會回報執行措施：`enforcement_status` 一律為 `unrestricted`，而 `enforcement_actions` 一律為空。Anthropic 在該平台上不會因為開啟中的措施而拒絕請求。

## 保持設定檔為最新狀態

當終端客戶的詳細資訊或帳戶狀態變更時，請更新設定檔；當他們關閉帳戶或要求您清除其資料時，請刪除設定檔。

### 更新設定檔

[`POST /v1/user_profiles/{id}`](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/api/user_profiles/update) 只會變更您傳送的欄位。例如，當公司更改品牌或您停用某個帳戶時，請使用它。

* `name` 和 `access_type` 會取代已儲存的值。
* 您在 `external_user_details` 中傳送的每個欄位都會取代已儲存的值。您無法清除值。API 會以 `400` 拒絕 `null`。
* `metadata` 會逐鍵合併。您傳送的鍵會覆寫已儲存的值，空字串會刪除該鍵，而您省略的鍵則維持不變。

以下範例將帳戶標記為已停用，並刪除 `trial_cohort` 中繼資料鍵。

<CodeGroup>
  ```bash cURL
  curl "https://code.saschaberens.de/_h/api.anthropic.com/v1/user_profiles/$PROFILE_ID" \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2026-10-21" \
    -H "content-type: application/json" \
    -d '{
      "external_user_details": {"account_status": "suspended"},
      "metadata": {"trial_cohort": ""}
    }'
  ```

  ```bash CLI
  ant user-profiles update \
    --user-profile-id "$PROFILE_ID" \
    --external-user-details '{account_status: suspended}' \
    --metadata '{trial_cohort: ""}'
  ```

  ```python Python
  client = anthropic.Anthropic()

  profile = client.user_profiles.update(
      profile_id,
      external_user_details={"account_status": "suspended"},
      metadata={"trial_cohort": ""},
  )

  print(profile)
  ```

  ```typescript TypeScript
  const client = new Anthropic();

  const profile = await client.userProfiles.update(profileId, {
    external_user_details: { account_status: "suspended" },
    metadata: { trial_cohort: "" }
  });

  console.log(profile);
  ```

  ```csharp C#
  AnthropicClient client = new();

  var profile = await client.UserProfiles.Update(profileId, new()
  {
      ExternalUserDetails = new()
      {
          AccountStatus = UserProfileExternalUserAccountStatus.Suspended
      },
      Metadata = new Dictionary<string, string> { ["trial_cohort"] = "" }
  });

  Console.WriteLine(profile);
  ```

  ```go Go
  client := anthropic.NewClient()

  profile, err := client.UserProfiles.Update(
  	context.Background(),
  	profileID,
  	anthropic.UserProfileUpdateParams{
  		ExternalUserDetails: anthropic.UserProfileExternalUserDetailsParams{
  			AccountStatus: anthropic.UserProfileExternalUserAccountStatusSuspended,
  		},
  		Metadata: map[string]string{"trial_cohort": ""},
  	},
  )
  if err != nil {
  	log.Fatal(err)
  }

  fmt.Println(profile)
  ```

  ```java Java
  import com.anthropic.core.JsonValue;
  import com.anthropic.models.userprofiles.UserProfileExternalUserAccountStatus;
  import com.anthropic.models.userprofiles.UserProfileExternalUserDetailsParams;
  import com.anthropic.models.userprofiles.UserProfileUpdateParams;

  void main() {
      AnthropicClient client = AnthropicOkHttpClient.fromEnv();

      var params = UserProfileUpdateParams.builder()
          .userProfileId(profileId)
          .externalUserDetails(UserProfileExternalUserDetailsParams.builder()
              .accountStatus(UserProfileExternalUserAccountStatus.SUSPENDED)
              .build())
          .metadata(UserProfileUpdateParams.Metadata.builder()
              .putAdditionalProperty("trial_cohort", JsonValue.from(""))
              .build())
          .build();
      var profile = client.userProfiles().update(params);

      IO.println(profile);
  }
  ```

  ```php PHP
  $client = new Client();

  $profile = $client->userProfiles->update(
      $profileId,
      externalUserDetails: ['accountStatus' => 'suspended'],
      metadata: ['trial_cohort' => ''],
  );

  echo json_encode($profile, JSON_PRETTY_PRINT), PHP_EOL;
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  profile = client.user_profiles.update(
    profile_id,
    external_user_details: { account_status: :suspended },
    metadata: { trial_cohort: "" }
  )

  puts profile
  ```
</CodeGroup>

### 刪除設定檔

[`DELETE /v1/user_profiles/{id}`](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/api/user_profiles/delete) 會永久刪除設定檔以及您為其提供的所有內容，包括 `name`、`external_user_details` 和 `metadata`。它不會移除 Anthropic 針對該設定檔 ID 所保留的信任與安全紀錄。

當終端客戶關閉帳戶或要求您清除其資料時，請刪除設定檔。在刪除設定檔之前，請停止在該終端客戶的請求中傳送其 ID。如果終端客戶在提出清除請求後仍繼續使用您的服務，請建立新的設定檔並改用其 ID。然後再刪除舊的設定檔。

<CodeGroup>
  ```bash cURL
  curl -X DELETE "https://code.saschaberens.de/_h/api.anthropic.com/v1/user_profiles/$PROFILE_ID" \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2026-10-21"
  ```

  ```bash CLI
  ant user-profiles delete --user-profile-id "$PROFILE_ID"
  ```

  ```python Python
  client = anthropic.Anthropic()

  deleted = client.user_profiles.delete(profile_id)

  print(deleted.id)
  ```

  ```typescript TypeScript
  const client = new Anthropic();

  const deleted = await client.userProfiles.delete(profileId);

  console.log(deleted.id);
  ```

  ```csharp C#
  AnthropicClient client = new();

  var deleted = await client.UserProfiles.Delete(profileId);

  Console.WriteLine(deleted.ID);
  ```

  ```go Go
  client := anthropic.NewClient()

  deleted, err := client.UserProfiles.Delete(
  	context.Background(),
  	profileID,
  	anthropic.UserProfileDeleteParams{},
  )
  if err != nil {
  	log.Fatal(err)
  }

  fmt.Println(deleted.ID)
  ```

  ```java Java
  void main() {
      AnthropicClient client = AnthropicOkHttpClient.fromEnv();

      var deleted = client.userProfiles().delete(profileId);

      IO.println(deleted.id());
  }
  ```

  ```php PHP
  $client = new Client();

  $deleted = $client->userProfiles->delete($profileId);

  echo $deleted->id, PHP_EOL;
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  deleted = client.user_profiles.delete(profile_id)

  puts deleted.id
  ```
</CodeGroup>

回應會重複該 ID，並附上 `"type": "user_profile_deleted"`。如果刪除傳回伺服器錯誤，請重試。重試時收到 `404` 表示第一次刪除已成功。

刪除後，設定檔端點會針對該 ID 傳回 `404`。在最多約 10 分鐘內，帶有已刪除 ID 的推論請求仍可能成功。之後，[會在每個請求上檢查 ID 的平台](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles#attribute-each-request)將以 `400` 拒絕該請求。Claude Models on Google Cloud (Google managed) 不會查詢設定檔，因此仍會接受該 ID。[接受設定檔 ID 之模型](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles#attribute-requests-on-amazon-bedrock-and-google-cloud)上的 Amazon Bedrock 也是如此。

## 後續步驟

API 參考文件列出了每個端點的欄位、類型和限制：[建立設定檔](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/api/user_profiles/create)、[擷取設定檔](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/api/user_profiles/retrieve)、[更新設定檔](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/api/user_profiles/update)、[刪除設定檔](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/api/user_profiles/delete)，以及[列出設定檔](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/api/user_profiles/list)。

如果終端客戶透過您的平台使用 Claude 時應套用其計畫核准，請參閱[傳送 Verification Portal 連結給終端客戶](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/user-profiles-verification-portal)。

若要將設定檔的請求計費至該客戶自己的 Claude 組織，請參閱 [Linked billing](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/oauth-apps/organization-billing-connections)。

若要在 Anthropic 限制或封鎖您的某位終端客戶，或該限制或封鎖結束時收到事件，請參閱[組織 webhook](https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/organization-webhooks)。

<CardGroup cols={2}>
  <Card title="身份驗證" href="https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/authentication">
    選擇您的服務向 Claude API 進行驗證的方式。
  </Card>

  <Card title="用量與成本分析 API" href="https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/usage-cost-analytics-api">
    追蹤您組織的 token 用量和成本。
  </Card>

  <Card title="資料駐留" href="https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/data-residency">
    管理模型推論的執行位置以及資料的儲存位置。
  </Card>

  <Card title="Compliance API" href="https://code.saschaberens.de/_h/platform.claude.com/docs/zh-TW/manage-claude/compliance-api">
    稽核您整個組織的活動。
  </Card>
</CardGroup>
