> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tensorone.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Team Management

> Invite, manage, and organize team members with role-based access control

Manage your TensorOne team members, including invitations, role assignments, and access control. Organize your team with flexible permission models and collaboration tools.

## List Team Members

Retrieve all team members and their roles.

```bash
curl -X GET "https://api.tensorone.ai/v2/accounts/team/members" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

### Response

```json
{
    "members": [
        {
            "id": "usr_1234567890abcdef",
            "email": "alice@example.com",
            "name": "Alice Johnson",
            "username": "alice.johnson",
            "avatar": "https://cdn.tensorone.ai/avatars/usr_1234567890abcdef.jpg",
            "role": "admin",
            "permissions": ["read", "write", "execute", "manage_team"],
            "status": "active",
            "joinedAt": "2024-01-15T10:30:00Z",
            "lastActive": "2024-03-20T14:15:00Z",
            "invitedBy": "usr_owner123456789",
            "department": "Engineering",
            "title": "Senior ML Engineer"
        },
        {
            "id": "usr_fedcba0987654321",
            "email": "bob@example.com",
            "name": "Bob Smith",
            "username": "bob.smith",
            "avatar": "https://cdn.tensorone.ai/avatars/usr_fedcba0987654321.jpg",
            "role": "developer",
            "permissions": ["read", "write", "execute"],
            "status": "active",
            "joinedAt": "2024-02-01T09:00:00Z",
            "lastActive": "2024-03-19T16:45:00Z",
            "invitedBy": "usr_1234567890abcdef",
            "department": "Data Science",
            "title": "ML Researcher"
        },
        {
            "id": "usr_invitation_pending",
            "email": "charlie@example.com",
            "name": null,
            "username": null,
            "avatar": null,
            "role": "viewer",
            "permissions": ["read"],
            "status": "pending",
            "invitedAt": "2024-03-18T11:20:00Z",
            "invitedBy": "usr_1234567890abcdef",
            "invitationExpires": "2024-03-25T11:20:00Z"
        }
    ],
    "total": 3,
    "roles": {
        "owner": 1,
        "admin": 1,
        "developer": 1,
        "viewer": 0,
        "pending": 1
    }
}
```

## Invite Team Member

Send an invitation to join your team.

```bash
curl -X POST "https://api.tensorone.ai/v2/accounts/team/members/invite" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "newmember@example.com",
    "role": "developer",
    "department": "Engineering",
    "title": "AI Engineer",
    "message": "Welcome to our TensorOne team! Excited to have you aboard."
  }'
```

### Request Schema

```json
{
    "email": "string (required, valid email address)",
    "role": "string (required, 'admin', 'developer', 'viewer')",
    "department": "string (optional, max 100 characters)",
    "title": "string (optional, max 100 characters)",
    "message": "string (optional, max 500 characters)",
    "permissions": "array (optional, custom permissions)",
    "expiresIn": "string (optional, '1d', '7d', '30d', default: '7d')"
}
```

### Available Roles

* **owner**: Full access to all resources and billing (cannot be assigned)
* **admin**: Full access to resources and team management
* **developer**: Create and manage endpoints, clusters, and resources
* **viewer**: Read-only access to resources and usage

### Response

```json
{
    "invitation": {
        "id": "inv_1234567890abcdef",
        "email": "newmember@example.com",
        "role": "developer",
        "status": "sent",
        "expiresAt": "2024-03-27T14:30:00Z",
        "inviteUrl": "https://console.tensorone.ai/invite/inv_1234567890abcdef",
        "department": "Engineering",
        "title": "AI Engineer"
    },
    "message": "Invitation sent successfully"
}
```

## Update Team Member

Update a team member's role, permissions, or details.

```bash
curl -X PUT "https://api.tensorone.ai/v2/accounts/team/members/usr_1234567890abcdef" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "role": "admin",
    "department": "Engineering Leadership",
    "title": "Principal ML Engineer"
  }'
```

### Request Schema

```json
{
    "role": "string (optional, 'admin', 'developer', 'viewer')",
    "permissions": "array (optional, custom permissions)",
    "department": "string (optional, max 100 characters)",
    "title": "string (optional, max 100 characters)",
    "status": "string (optional, 'active', 'suspended')"
}
```

### Response

Returns the updated member object with the same structure as the list response.

## Remove Team Member

Remove a team member from your organization.

```bash
curl -X DELETE "https://api.tensorone.ai/v2/accounts/team/members/usr_1234567890abcdef" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

### Response

```json
{
    "id": "usr_1234567890abcdef",
    "status": "removed",
    "removedAt": "2024-03-20T16:00:00Z",
    "message": "Team member removed successfully"
}
```

> [!WARNING]
>
> Removing a team member immediately revokes their access to all resources. Consider transferring ownership of their
> resources before removal.

## Resend Invitation

Resend a pending invitation to a team member.

```bash
curl -X POST "https://api.tensorone.ai/v2/accounts/team/invitations/inv_1234567890abcdef/resend" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

### Response

```json
{
    "invitation": {
        "id": "inv_1234567890abcdef",
        "email": "newmember@example.com",
        "status": "resent",
        "expiresAt": "2024-03-27T16:00:00Z",
        "resentAt": "2024-03-20T16:00:00Z"
    },
    "message": "Invitation resent successfully"
}
```

## Cancel Invitation

Cancel a pending invitation.

```bash
curl -X DELETE "https://api.tensorone.ai/v2/accounts/team/invitations/inv_1234567890abcdef" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

### Response

```json
{
    "invitation": {
        "id": "inv_1234567890abcdef",
        "status": "cancelled",
        "cancelledAt": "2024-03-20T16:00:00Z"
    },
    "message": "Invitation cancelled successfully"
}
```

## Get Team Member Details

Retrieve detailed information about a specific team member.

```bash
curl -X GET "https://api.tensorone.ai/v2/accounts/team/members/usr_1234567890abcdef" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

### Response

```json
{
    "member": {
        "id": "usr_1234567890abcdef",
        "email": "alice@example.com",
        "name": "Alice Johnson",
        "username": "alice.johnson",
        "avatar": "https://cdn.tensorone.ai/avatars/usr_1234567890abcdef.jpg",
        "role": "admin",
        "permissions": ["read", "write", "execute", "manage_team"],
        "status": "active",
        "joinedAt": "2024-01-15T10:30:00Z",
        "lastActive": "2024-03-20T14:15:00Z",
        "department": "Engineering",
        "title": "Senior ML Engineer",
        "activity": {
            "endpointsCreated": 25,
            "clustersManaged": 8,
            "totalExecutions": 1250,
            "lastLogin": "2024-03-20T14:15:00Z"
        },
        "resources": {
            "ownedEndpoints": 12,
            "ownedClusters": 3,
            "sharedEndpoints": 8
        }
    }
}
```

## Get Team Activity

Retrieve team activity and collaboration metrics.

```bash
curl -X GET "https://api.tensorone.ai/v2/accounts/team/activity" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -G -d "period=30d"
```

### Response

```json
{
    "period": "30d",
    "summary": {
        "totalMembers": 15,
        "activeMembers": 12,
        "newMembers": 3,
        "totalActivity": 2450,
        "collaborationScore": 8.5
    },
    "memberActivity": [
        {
            "userId": "usr_1234567890abcdef",
            "name": "Alice Johnson",
            "role": "admin",
            "activity": {
                "logins": 28,
                "endpointExecutions": 145,
                "resourcesCreated": 8,
                "collaborations": 12
            }
        }
    ],
    "teamCollaboration": {
        "sharedEndpoints": 35,
        "crossTeamProjects": 8,
        "knowledgeSharing": 42
    },
    "trends": {
        "activityGrowth": "+15.2%",
        "memberEngagement": 0.87,
        "retentionRate": 0.94
    }
}
```

## Bulk Operations

Perform bulk operations on multiple team members.

```bash
curl -X POST "https://api.tensorone.ai/v2/accounts/team/members/bulk" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "update_role",
    "members": [
      "usr_1234567890abcdef",
      "usr_fedcba0987654321"
    ],
    "data": {
      "role": "developer"
    }
  }'
```

### Available Operations

* `update_role`: Update role for multiple members
* `update_department`: Update department for multiple members
* `suspend`: Suspend multiple members
* `reactivate`: Reactivate suspended members

### Response

```json
{
    "operation": "update_role",
    "results": [
        {
            "userId": "usr_1234567890abcdef",
            "status": "success",
            "updated": true
        },
        {
            "userId": "usr_fedcba0987654321",
            "status": "success",
            "updated": true
        }
    ],
    "summary": {
        "total": 2,
        "successful": 2,
        "failed": 0
    }
}
```

## Code Examples

### Python SDK

```python
from tensorone import TensorOneAPI

client = TensorOneAPI(api_key="your_api_key")

# List all team members
members = client.accounts.team.members.list()
for member in members:
    print(f"{member.name} ({member.role}) - {member.status}")

# Invite new team member
invitation = client.accounts.team.members.invite(
    email="newdev@example.com",
    role="developer",
    department="Engineering",
    title="Senior ML Engineer",
    message="Welcome to our AI team!"
)
print(f"Invitation sent: {invitation.invite_url}")

# Update team member role
updated_member = client.accounts.team.members.update(
    user_id="usr_1234567890abcdef",
    role="admin",
    department="Engineering Leadership"
)

# Get member details with activity
member_details = client.accounts.team.members.get(
    user_id="usr_1234567890abcdef"
)
print(f"Member activity: {member_details.activity.total_executions} executions")

# Remove team member
client.accounts.team.members.remove("usr_inactive123")

# Bulk update roles
bulk_result = client.accounts.team.members.bulk_update(
    operation="update_role",
    member_ids=["usr_123", "usr_456"],
    data={"role": "developer"}
)
print(f"Bulk update: {bulk_result.summary.successful} successful")

# Get team activity
activity = client.accounts.team.get_activity(period="30d")
print(f"Team collaboration score: {activity.summary.collaboration_score}")
```

### JavaScript SDK

```javascript
import { TensorOneAPI } from "@tensorone/sdk";

const client = new TensorOneAPI("your_api_key");

// List team members
const members = await client.accounts.team.members.list();
members.forEach((member) => {
    console.log(`${member.name} (${member.role}) - ${member.status}`);
});

// Invite new team member
const invitation = await client.accounts.team.members.invite({
    email: "designer@example.com",
    role: "viewer",
    department: "Design",
    title: "UX Designer",
    message: "Join our design collaboration!",
});
console.log(`Invitation sent: ${invitation.inviteUrl}`);

// Update team member
const updatedMember = await client.accounts.team.members.update("usr_1234567890abcdef", {
    role: "admin",
    title: "Lead Engineer",
});

// Get team member details
const memberDetails = await client.accounts.team.members.get("usr_1234567890abcdef");
console.log(`Last active: ${memberDetails.lastActive}`);

// Resend invitation
await client.accounts.team.invitations.resend("inv_1234567890abcdef");

// Cancel invitation
await client.accounts.team.invitations.cancel("inv_old_invitation");

// Bulk operations
const bulkResult = await client.accounts.team.members.bulkUpdate({
    operation: "update_department",
    members: ["usr_123", "usr_456"],
    data: { department: "AI Research" },
});

// Get team activity
const activity = await client.accounts.team.getActivity({ period: "30d" });
console.log(`Active members: ${activity.summary.activeMembers}`);
```

## Error Responses

### 400 Bad Request

```json
{
    "error": "INVALID_EMAIL",
    "message": "Invalid email address format",
    "details": {
        "field": "email",
        "value": "invalid-email"
    }
}
```

### 403 Forbidden

```json
{
    "error": "INSUFFICIENT_PERMISSIONS",
    "message": "Only admins can manage team members",
    "details": {
        "requiredRole": "admin",
        "currentRole": "developer"
    }
}
```

### 404 Not Found

```json
{
    "error": "MEMBER_NOT_FOUND",
    "message": "Team member not found",
    "details": {
        "userId": "usr_nonexistent123"
    }
}
```

### 409 Conflict

```json
{
    "error": "MEMBER_ALREADY_EXISTS",
    "message": "User is already a team member",
    "details": {
        "email": "existing@example.com",
        "currentRole": "developer"
    }
}
```

### 422 Unprocessable Entity

```json
{
    "error": "CANNOT_REMOVE_OWNER",
    "message": "Cannot remove the account owner",
    "details": {
        "userId": "usr_owner123456789",
        "role": "owner"
    }
}
```

## Best Practices

### Team Organization

* Use clear role hierarchy: owner → admin → developer → viewer
* Set appropriate department and title information for better organization
* Regular review of team member permissions and access levels

### Invitation Management

* Use personalized invitation messages to improve acceptance rates
* Set appropriate expiration times for invitations
* Monitor and follow up on pending invitations

### Access Control

* Follow principle of least privilege when assigning roles
* Regularly audit team member permissions
* Use custom permissions for fine-grained access control

### Team Collaboration

* Monitor team activity to identify collaboration opportunities
* Use team analytics to optimize resource allocation
* Encourage knowledge sharing through shared resources

## Use Cases

### Onboarding New Team Members

```python
def onboard_new_hire(email, name, department, title):
    # Send invitation with welcome message
    invitation = client.accounts.team.members.invite(
        email=email,
        role="developer",
        department=department,
        title=title,
        message=f"Welcome {name} to TensorOne! We're excited to have you join our {department} team."
    )

    # Set up initial resources
    # Create welcome endpoint for testing
    welcome_endpoint = client.endpoints.create(
        name=f"{name.lower()}-welcome-endpoint",
        template_id="tpl_hello_world"
    )

    return invitation
```

### Team Reorganization

```python
def reorganize_teams():
    # Get all members
    members = client.accounts.team.members.list()

    # Bulk update departments
    engineering_members = [m.id for m in members if "engineer" in m.title.lower()]
    client.accounts.team.members.bulk_update(
        operation="update_department",
        member_ids=engineering_members,
        data={"department": "Engineering"}
    )

    # Update research team
    research_members = [m.id for m in members if "research" in m.title.lower()]
    client.accounts.team.members.bulk_update(
        operation="update_department",
        member_ids=research_members,
        data={"department": "AI Research"}
    )
```

### Access Audit

```python
def audit_team_access():
    members = client.accounts.team.members.list()

    for member in members:
        # Check last activity
        if member.last_active < datetime.now() - timedelta(days=90):
            print(f"Inactive member: {member.name} ({member.last_active})")

        # Check permissions
        if member.role == "admin" and member.activity.total_executions < 10:
            print(f"Admin with low activity: {member.name}")

        # Review resource ownership
        details = client.accounts.team.members.get(member.id)
        if details.resources.owned_endpoints > 20:
            print(f"Member with many resources: {member.name}")
```

### Team Performance Analytics

```python
def analyze_team_performance():
    activity = client.accounts.team.get_activity(period="30d")

    # Calculate team metrics
    avg_activity = activity.summary.total_activity / activity.summary.active_members
    engagement_rate = activity.summary.active_members / activity.summary.total_members

    print(f"Team Engagement: {engagement_rate:.1%}")
    print(f"Average Activity: {avg_activity:.1f}")
    print(f"Collaboration Score: {activity.summary.collaboration_score}/10")

    # Identify top performers
    top_performers = sorted(
        activity.member_activity,
        key=lambda m: m.activity.collaborations,
        reverse=True
    )[:5]

    print("Top Collaborators:")
    for member in top_performers:
        print(f"  {member.name}: {member.activity.collaborations} collaborations")
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.