Claude Platform Docs

列出服务账号所属的工作区

client.Organization.ServiceAccounts.Workspaces.List(ctx, serviceAccountID, query) (*PageCursor[ServiceAccountWorkspaceMember], error)
GET/v1/organizations/service_accounts/{service_account_id}/workspaces

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

列出服务账号所属的工作区。

每个条目都包含服务账号在该工作区中的 workspace_role。请使用 limit 和 next_page 游标进行分页。当服务账号没有显式的默认工作区成员资格时,隐式(implicit: true)成员资格将作为第一页的第一个条目返回;当 limit=1 时,第一页最多可能返回 2 个条目(隐式条目加上一个显式成员资格),以便生成分页游标。仅当服务账号处于活动状态时才会返回成员资格。在没有 page 游标的情况下,已归档的服务账号将返回空列表。与任何活动成员资格都不匹配的 page 游标将返回 400 无效请求错误。当成员资格被移除、工作区被删除或服务账号被归档时,游标将不再匹配。请从第一页重新开始分页以恢复。

Parameters
serviceAccountID string⁠Path parameter

ID of the service account.

query OrganizationServiceAccountWorkspaceListParams
Limit param.Opt[int64] OptionalQuery parameter

Number of results per page.

minimum1
maximum100
Page param.Opt[string] OptionalQuery parameter

Opaque cursor from a previous response's next_page.

Returns
type ServiceAccountWorkspaceMember struct { Type: "service_account_workspace_member"; CreatedByActorID; Implicit; /* 3 more */ }
Type ServiceAccountWorkspaceMember
defaultservice_account_workspace_member
CreatedByActorID string

Tagged ID (user_.../svac_...) of the actor who created this membership.

Implicit bool

True when this is the implicit default-workspace membership every service account has when no explicit membership exists. Implicit memberships have role workspace_user and cannot be removed.

ServiceAccountID string

Tagged service account ID (svac_...).

WorkspaceID string

Tagged workspace ID (wrkspc_...).

WorkspaceRole WorkspaceRole

Role of the service account in this workspace. Service accounts cannot hold the workspace_billing role.

One of the following:
const WorkspaceRoleWorkspaceAdmin WorkspaceRole = "workspace_admin"
const WorkspaceRoleWorkspaceBilling WorkspaceRole = "workspace_billing"
const WorkspaceRoleWorkspaceDeveloper WorkspaceRole = "workspace_developer"
const WorkspaceRoleWorkspaceRestrictedDeveloper WorkspaceRole = "workspace_restricted_developer"
const WorkspaceRoleWorkspaceUser WorkspaceRole = "workspace_user"
列出服务账号所属的工作区
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"),
	)
	page, err := client.Organization.ServiceAccounts.Workspaces.List(
		context.TODO(),
		"service_account_id",
		anthropic.OrganizationServiceAccountWorkspaceListParams{},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)
}
Returns Examples
Response 200
{
  "data": [
    {
      "created_by_actor_id": "created_by_actor_id",
      "implicit": true,
      "service_account_id": "service_account_id",
      "type": "service_account_workspace_member",
      "workspace_id": "workspace_id",
      "workspace_role": "workspace_admin"
    }
  ],
  "next_page": "next_page"
}