Claude Platform Docs

从服务账号中移除工作区

WorkspaceRemoveResponse organization().serviceAccounts().workspaces().remove(params, requestOptions = RequestOptions.none())
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
WorkspaceRemoveParams params
String serviceAccountId⁠Path parameter

ID of the service account.

Optional<String> workspaceId⁠Path parameter

ID of the workspace.

Returns
class WorkspaceRemoveResponse { type = "service_account_workspace_member_deleted"; serviceAccountId; workspaceId; }
JsonValue type = "service_account_workspace_member_deleted"
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.

从服务账号中移除工作区
package com.anthropic.example;

import com.anthropic.client.AnthropicClient;
import com.anthropic.client.okhttp.AnthropicOkHttpClient;
import com.anthropic.models.organization.serviceaccounts.workspaces.WorkspaceRemoveParams;
import com.anthropic.models.organization.serviceaccounts.workspaces.WorkspaceRemoveResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        AnthropicClient client = AnthropicOkHttpClient.fromEnv();

        WorkspaceRemoveParams params = WorkspaceRemoveParams.builder()
            .serviceAccountId("service_account_id")
            .workspaceId("workspace_id")
            .build();
        WorkspaceRemoveResponse workspace = client.organization().serviceAccounts().workspaces().remove(params);
    }
}
Returns Examples
Response 200
{
  "service_account_id": "service_account_id",
  "type": "service_account_workspace_member_deleted",
  "workspace_id": "workspace_id"
}