Claude Platform Docs

从服务账户移除工作区

$client->beta->organization->serviceAccounts->workspaces->remove(string workspaceID, string serviceAccountID, ?list<AnthropicBeta> betas): WorkspaceRemoveResponse
DELETE/v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id}

需要具有 org:admin 作用域的 OAuth 访问令牌,可通过 ant auth login --scope org:admin 或工作负载身份联合规则获取;不接受 Admin API 密钥。请参阅使用 Admin API 管理 WIF

从工作区中移除服务账号。

这是 DELETE /workspaces/{workspace_id}/service_accounts/{service_account_id} 的镜像,从服务账号一侧寻址。移除是幂等的(即使成员资格已被移除也返回 200)。对隐式默认工作区成员资格执行 DELETE 会返回 200,但这是空操作,成员资格仍然保留;删除显式的默认工作区行会恢复为隐式的 workspace_user 成员资格。已归档的工作区返回 400。

Parameters
serviceAccountID: string

ID of the service account.

workspaceID: string

ID of the workspace.

betas?:optional list<AnthropicBeta>

Optional header to specify the beta version(s) you want to use.

Returns
class WorkspaceRemoveResponse { $type = 'service_account_workspace_member_deleted'; $serviceAccountID; $workspaceID; }
"service_account_workspace_member_deleted" type
string serviceAccountID

Tagged service account ID (svac_...) named in the delete request. Removal is idempotent; see the endpoint description for the implicit-membership no-op.

string workspaceID

Tagged workspace ID (wrkspc_...) named in the delete request.

从服务账户移除工作区
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

$client = new Client(apiKey: 'my-anthropic-api-key');

$workspace = $client->beta->organization->serviceAccounts->workspaces->remove(
  'workspace_id',
  serviceAccountID: 'service_account_id',
  betas: [AnthropicBeta::MESSAGE_BATCHES_2024_09_24],
);

var_dump($workspace);
Returns Examples
Response 200
{
  "service_account_id": "service_account_id",
  "type": "service_account_workspace_member_deleted",
  "workspace_id": "workspace_id"
}