Team Management API
Manage team members, permissions, and credits for enterprise organizations.
Team features are available only for enterprise subscription plans. These plans include multi-user support, credit sharing, and role-based access control.
Team Information
Get Team Info
Retrieve information about the current team project.
Endpoint: GET /v2/team/info
Curl Example:
curl -X GET https://api.luw.ai/v2/team/info \
-H "Authorization: Bearer LUW_API_TOKEN"
Response Example:
{
"status": true,
"is_team": true,
"plan": "ai_plan_m4",
"credits": {
"plan": "ai_plan_m4",
"monthly_allocation": 5000,
"used_this_month": 1234,
"remaining": 3766,
"usage_percentage": 24.7,
"days_left_in_month": 15
},
"members_count": 8,
"can_add_members": true,
"owner": "admin@company.com",
"user_level": "admin",
"user_id": 123
}
Team Members
List Team Members
Get all team members with their roles and permissions.
Endpoint: GET /v2/team/members
Note: Only users with admin (level 2) or owner (level 99) permissions receive the member list. Regular members receive an empty array.
Curl Example:
curl -X GET https://api.luw.ai/v2/team/members \
-H "Authorization: Bearer LUW_API_TOKEN"
Response Example (Admin/Owner View):
{
"status": true,
"members": [
{
"id": 123,
"email": "owner@company.com",
"role": "owner",
"level": 99,
"joined_at": "2024-01-10T10:00:00.000Z",
"added_by": null,
"is_confirmed": true
},
{
"id": 456,
"email": "john@company.com",
"role": "admin",
"level": 2,
"joined_at": "2024-01-15T10:30:00.000Z",
"added_by": "owner@company.com",
"is_confirmed": true
},
{
"id": 789,
"email": "jane@company.com",
"role": "member",
"level": 1,
"joined_at": "2024-01-20T14:00:00.000Z",
"added_by": "john@company.com",
"is_confirmed": false
}
]
}
Response Example (Member View):
{
"status": true,
"members": []
}
Add Team Member
Add a new member to your team. Requires admin or owner permissions.
Endpoint: POST /v2/team/members
Parameters:
email
(string, Required) - Email address of the new memberrole
(string, Optional) - Role assignment:member
oradmin
(default:member
)password
(string, Optional) - If provided, creates a new user account
Curl Example:
curl -X POST https://api.luw.ai/v2/team/members \
-H "Authorization: Bearer LUW_API_TOKEN" \
-d "email=newuser@company.com" \
-d "role=member"
Curl Example (Creating New User):
curl -X POST https://api.luw.ai/v2/team/members \
-H "Authorization: Bearer LUW_API_TOKEN" \
-d "email=newuser@company.com" \
-d "role=admin" \
-d "password=SecurePassword123"
Response Example:
{
"status": true
}
Remove Team Member
Remove a member from the team. Requires admin or owner permissions. Users can also remove themselves.
Endpoint: DELETE /v2/team/members/:user_id
Parameters:
user_id
(integer, Required) - User ID to remove
Response Example:
{
"status": true,
"message": "Member removed successfully",
"remove_self": false
}
Note: remove_self
will be true
if the user removed themselves from the team.
Error Response (Cannot Remove Owner):
{
"status": false,
"error": "Cannot remove owner"
}
Curl Example:
curl -X DELETE https://api.luw.ai/v2/team/members/789 \
-H "Authorization: Bearer LUW_API_TOKEN"
Update Member Role
Change a team member's role. Only the owner can perform this action.
Endpoint: PUT /v2/team/members/:user_id/role
Parameters:
user_id
(integer, Required) - User ID to updaterole
(string, Required) - New role:member
oradmin
Curl Example:
curl -X PUT https://api.luw.ai/v2/team/members/789/role \
-H "Authorization: Bearer LUW_API_TOKEN" \
-d "role=admin"
Response Example:
{
"status": true,
"message": "Role updated successfully"
}
Error Response:
{
"status": false,
"error": "Only owner can change roles"
}
Team Invitations
Send Team Invitation
Send an invitation to join the team. Requires admin or owner permissions.
Endpoint: POST /v2/team/send_invitation
Parameters:
email
(string, Required) - Email to inviterole
(string, Optional) - Role to assign:member
oradmin
(default:member
)
Curl Example:
curl -X POST https://api.luw.ai/v2/team/send_invitation \
-H "Authorization: Bearer LUW_API_TOKEN" \
-d "email=newuser@company.com" \
-d "role=member"
Response Example:
{
"status": true,
"invitation": {
"id": 123,
"email": "newuser@company.com",
"role": "member",
"token": "abc123xyz..."
}
}
Error Response (User Already Exists):
{
"status": false,
"error": "User already in team"
}
List Pending Invitations
View all pending team invitations. Requires admin or owner permissions.
Endpoint: GET /v2/team/pending_invitations
Curl Example:
curl -X GET https://api.luw.ai/v2/team/pending_invitations \
-H "Authorization: Bearer LUW_API_TOKEN"
Response Example:
{
"status": true,
"invitations": [
{
"id": 789,
"email": "pending@company.com",
"role": "member",
"invited_by": "admin@company.com",
"created_at": "2024-01-20T14:00:00.000Z"
}
]
}
Respond to Invitation
Accept or decline a team invitation.
Endpoint: POST /v2/team/respond_invitation
Parameters:
token
(string, Required) - Invitation tokenact
(string, Required) - Action:accept
ordecline
Curl Example:
curl -X POST https://api.luw.ai/v2/team/respond_invitation \
-H "Authorization: Bearer LUW_API_TOKEN" \
-d "token=abc123xyz" \
-d "act=accept"
Response Example (Accept):
{
"status": true,
"message": "Invitation accepted"
}
Response Example (Decline):
{
"status": true,
"message": "Invitation declined"
}
Error Response:
{
"status": false,
"error": "Invalid invitation"
}
Team Credits & Usage
Get Team Credits
View team credit balance and subscription details.
Endpoint: GET /v2/team/credits
Curl Example:
curl -X GET https://api.luw.ai/v2/team/credits \
-H "Authorization: Bearer LUW_API_TOKEN"
Response Example:
{
"status": true,
"credits": {
"plan": "ai_plan_m5",
"monthly_allocation": 9000,
"used_this_month": 4567,
"remaining": 4433,
"usage_percentage": 50.7,
"days_left_in_month": 12
}
}
Get Usage Breakdown
View detailed usage statistics per team member for the current month.
Endpoint: GET /v2/team/usage
Curl Example:
curl -X GET https://api.luw.ai/v2/team/usage \
-H "Authorization: Bearer LUW_API_TOKEN"
Response Example:
{
"status": true,
"usage_breakdown": [
{
"user_id": 456,
"email": "john@company.com",
"role": "admin",
"credits_used": 2340,
"last_activity": "2025-01-25T16:30:00.000Z",
"matched_metrics": [
{
"metric_id": 1064526,
"tokens": 8,
"created_at": "2025-01-25T12:15:52.121Z"
},
{
"metric_id": 1064470,
"tokens": 12,
"created_at": "2025-01-25T16:30:00.000Z"
}
]
},
{
"user_id": 789,
"email": "jane@company.com",
"role": "member",
"credits_used": 1227,
"last_activity": "2025-01-25T14:20:00.000Z",
"matched_metrics": [...]
}
],
"total_team_usage": 4567,
"debug_info": {
"total_tnext_metrics": 145,
"period": "January 2025",
"project_id": 1234,
"all_metrics": [...],
"team_user_ids": [456, 789]
}
}
Role Permissions
Role: Level
| Permissions
Owner: 99
| Full control, manage billing, delete team
Admin: 2
| Add/remove members, view usage, manage invitations
Member: 1
| Use team resources, view own usage
Error Responses
All endpoints may return these common errors:
Authentication Errors
json
{
"status": false,
"errors": {
"auth": ["Wrong credentials or expired token"]
}
}
Permission Errors
json
{
"status": false,
"error": "Insufficient permissions"
}
Team Errors
json
{
"status": false,
"error": "Not a team project"
}
json
{
"status": false,
"error": "Team member limit reached"
}
json
{
"status": false,
"error": "Project not found"
}
Member Management Errors
json
{
"status": false,
"error": "Cannot remove owner"
}
json
{
"status": false,
"error": "Member not found"
}
json
{
"status": false,
"error": "User already in team"
}
json
{
"status": false,
"error": "Invitation already exists"
}
Last updated