Claude Platform Docs

创建工作区成员

client.Organization.Workspaces.Members.Add(ctx, workspaceID, body) (*WorkspaceMember, error)
POST/v1/organizations/workspaces/{workspace_id}/members

创建工作区成员

Parameters
workspaceID string⁠Path parameter

ID of the Workspace.

body OrganizationWorkspaceMemberAddParams
UserID string

ID of the User.

Role of the new Workspace Member. Cannot be workspace_billing.

Returns
type WorkspaceMember struct { Type: "workspace_member"; UserID; WorkspaceID; WorkspaceRole }
Type WorkspaceMember

Object type.

For Workspace Members, this is always "workspace_member".

defaultworkspace_member
UserID string

ID of the User.

WorkspaceID string

ID of the Workspace.

WorkspaceRole WorkspaceRole

Role of the Workspace Member.

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"
Errors

Any method can also return the general HTTP errors.

ErrorCodeWorkspaceMemberLimitExceededHTTP status 400error code workspace_member_limit_exceeded

The workspace has reached the member limit that Anthropic set for it.

ErrorCodeSandboxEgressRestrictedHTTP status 403error code sandbox_egress_restricted

The request came from a Claude sandbox with restricted network access, which is not allowed to make this request. Send it from outside the sandbox, or from a sandbox with unrestricted network access.

创建工作区成员
package main

import (
	"context"
	"fmt"

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

func main() {
	client := anthropic.NewClient(
		option.WithAPIKey("my-anthropic-api-key"),
	)
	workspaceMember, err := client.Organization.Workspaces.Members.Add(
		context.TODO(),
		"workspace_id",
		anthropic.OrganizationWorkspaceMemberAddParams{
			UserID:        "user_01WxYzAbCdEfGhJkMnPqRsTu",
			WorkspaceRole: anthropic.NoBillingWorkspaceRoleWorkspaceAdmin,
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", workspaceMember.UserID)
}
Returns Examples
Response 200
{
  "type": "workspace_member",
  "user_id": "user_01WxYzAbCdEfGhJkMnPqRsTu",
  "workspace_id": "wrkspc_01AbCdEfGhJkLmNpQrStUvWx",
  "workspace_role": "workspace_admin"
}