Claude Platform Docs

删除服务账号工作区成员

client.Organization.Workspaces.ServiceAccounts.Remove(ctx, serviceAccountID, body) (*OrganizationWorkspaceServiceAccountRemoveResponse, error)
DELETE/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}

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

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

移除操作是幂等的(即使成员关系已被移除,也会返回 200)。针对隐式默认工作区成员关系的 DELETE 请求会返回 200,但不执行任何操作,成员关系仍然保留;删除显式的默认工作区记录会恢复为隐式的 workspace_user 成员关系。已归档的工作区返回 400。

Parameters
serviceAccountID string⁠Path parameter

ID of the service account.

body OrganizationWorkspaceServiceAccountRemoveParams
WorkspaceID string⁠Path parameter

ID of the workspace.

Returns
type OrganizationWorkspaceServiceAccountRemoveResponse struct { Type: "service_account_workspace_member_deleted"; ServiceAccountID; WorkspaceID }
Type ServiceAccountWorkspaceMemberDeleted
defaultservice_account_workspace_member_deleted
ServiceAccountID string

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

WorkspaceID string

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

删除服务账号工作区成员
package main

import (
	"context"
	"fmt"

	"github.com/anthropics/anthropic-sdk-go"
	"github.com/anthropics/anthropic-sdk-go/option"
)

func main() {
	client := anthropic.NewClient(
		option.WithAPIKey("my-anthropic-api-key"),
	)
	serviceAccount, err := client.Organization.Workspaces.ServiceAccounts.Remove(
		context.TODO(),
		"service_account_id",
		anthropic.OrganizationWorkspaceServiceAccountRemoveParams{
			WorkspaceID: "workspace_id",
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", serviceAccount.ServiceAccountID)
}
Returns Examples
Response 200
{
  "service_account_id": "service_account_id",
  "type": "service_account_workspace_member_deleted",
  "workspace_id": "workspace_id"
}