Manage Workspace Members

Use the AI Studio SDK to invite members and update their roles. The member ID returned from an invitation serves as the handover reference for reading member details and making subsequent role updates.

Task workflow

First select the target workspace, then invite a member using one contact identifier. Email and phone invitations remain pending until accepted; when using a GitHub username, existing catalog users return a member ID immediately, while unmatched users return an empty ID until their first sign-in.

After obtaining a member ID, you can read member details, update roles, change status, or remove members. Role update requests do not return member details in the response, so a follow-up read is required for confirmation.

Prerequisites

Required item

How to obtain

Role on this page

Authenticated client

Created during the initial connection setup.

Access workspace resources.

Workspace ID

Obtained from workspace creation, listing, or operator selection.

Define the scope of member operations.

Member name and one contact identifier

Provided by an administrator.

Invite the member.

Assigned roles and default role

Selected by an administrator according to access policies.

Define the access scope for invitations or role updates.

Invite a member

The following example invites a member by email and stores the returned member ID. Provide exactly one identifier among email, phone number, and GitHub username; the role set must include the default role.

import os

import moi_product_sdk as sdk

client = sdk.new_with_personal_access_token(
    os.environ["PRODUCT_API_BASE_URL"],
    os.environ["PRODUCT_API_KEY"],
)
workspace = client.workspace("<workspace-id>")
default_role_id = 1
invitation = workspace.invite_member(
    "<member-name>",
    default_role_id,
    sdk.with_user_email("<member-email>"),
    sdk.with_user_role_ids(default_role_id),
)
member_id = invitation.id
print(member_id)
package main

import (
	"context"
	"fmt"
	"os"

	sdk "github.com/matrixorigin/matrixflow/sdk/go-sdk"
)

func main() {
	ctx := context.Background()
	client, err := sdk.NewWithPersonalAccessToken(
		os.Getenv("PRODUCT_API_BASE_URL"),
		os.Getenv("PRODUCT_API_KEY"),
	)
	if err != nil {
		panic(err)
	}
	workspace, err := client.Workspace("<workspace-id>")
	if err != nil {
		panic(err)
	}
	const defaultRoleID = 1
	invitation, err := workspace.InviteMember(
		ctx,
		"<member-name>",
		defaultRoleID,
		sdk.WithUserEmail("<member-email>"),
		sdk.WithUserRoleIDs(defaultRoleID),
	)
	if err != nil {
		panic(err)
	}
	fmt.Println(invitation.GetId())
}

An empty member ID indicates that follow-up member update operations cannot yet proceed. Wait until the user completes sign-in or accepts the invitation, then obtain the active ID from the member list or member details.

Confirm member roles

After updating roles using the member ID obtained in the previous step, read the member details to confirm the change. A role update response only indicates request completion; when subsequent logic depends on the access scope, verify against the newly read member information.

member = workspace.member(member_id)
role_id = 1
member.set_roles([role_id], role_id)
member_info = member.info()
print(member_info)
member, err := workspace.Member(memberID)
if err != nil {
	panic(err)
}
roleID := 1
if err := member.SetRoles(ctx, []int{roleID}, roleID); err != nil {
	panic(err)
}
memberInfo, err := member.Info(ctx)
if err != nil {
	panic(err)
}
_ = memberInfo

Select the current role for the Go client

The Go client allows configuring the current active role for a specific workspace upon client creation. The role ID must be a positive decimal integer without leading zeros; this configuration applies only to requests targeting that workspace. Python currently does not provide an equivalent client-level configuration.

client, err := sdk.NewWithPersonalAccessToken(
	os.Getenv("PRODUCT_API_BASE_URL"),
	os.Getenv("PRODUCT_API_KEY"),
	sdk.WithWorkspaceCurrentRoleID("<workspace-id>", "<role-id>"),
)
if err != nil {
	panic(err)
}
_ = client

Next steps

Last updated on