Claude Platform Docs

Create Workspace Member

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

Create Workspace Member

Parameters
workspaceID string

ID of the Workspace.

body BetaOrganizationWorkspaceMemberAddParams
UserID param.Field[string]

ID of the User.

WorkspaceRole param.Field[BetaNoBillingWorkspaceRole]

Role of the new Workspace Member. Cannot be workspace_billing.

Returns
type BetaWorkspaceMember struct{…}
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 BetaWorkspaceRole

Role of the Workspace Member.

One of the following:
const BetaWorkspaceRoleWorkspaceAdmin BetaWorkspaceRole = "workspace_admin"
const BetaWorkspaceRoleWorkspaceBilling BetaWorkspaceRole = "workspace_billing"
const BetaWorkspaceRoleWorkspaceDeveloper BetaWorkspaceRole = "workspace_developer"
const BetaWorkspaceRoleWorkspaceRestrictedDeveloper BetaWorkspaceRole = "workspace_restricted_developer"
const BetaWorkspaceRoleWorkspaceUser BetaWorkspaceRole = "workspace_user"

Create Workspace Member

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"),
	)
	betaWorkspaceMember, err := client.Beta.Organization.Workspaces.Members.Add(
		context.TODO(),
		"workspace_id",
		anthropic.BetaOrganizationWorkspaceMemberAddParams{
			UserID:        "user_01WCz1FkmYMm4gnmykNKUu3Q",
			WorkspaceRole: anthropic.BetaNoBillingWorkspaceRoleWorkspaceAdmin,
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", betaWorkspaceMember.UserID)
}
{
  "type": "workspace_member",
  "user_id": "user_01WCz1FkmYMm4gnmykNKUu3Q",
  "workspace_id": "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",
  "workspace_role": "workspace_admin"
}
Returns Examples
{
  "type": "workspace_member",
  "user_id": "user_01WCz1FkmYMm4gnmykNKUu3Q",
  "workspace_id": "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ",
  "workspace_role": "workspace_admin"
}