New REST API Endpoints
Below is the list of all the new REST API endpoints added in the feature branchfeature/OND211-2329-Check-existing-REST-endponts-and-extend-with-new-requested-endpoints.
Team Management Endpoints
All team management endpoints are under the/tenant base path and require authentication.
1. Create Team
Endpoint:POST /tenant/create
Description: Create a new team (tenant). Requires authentication - any registered user can create a team.
Request Body:
{"name":"string (required, max 100 characters)","user_id":"string (optional, defaults to current authenticated user)","llm_id":"string (optional, defaults to system default)","embd_id":"string (optional, defaults to system default)","asr_id":"string (optional, defaults to system default)","parser_ids":"string (optional, defaults to system default)","img2txt_id":"string (optional, defaults to system default)","rerank_id":"string (optional, defaults to system default)","credit":"integer (optional, defaults to 512)"}Response: Returns created team information with ID, name, owner_id, and model IDs.
Status Codes:
200 - Team created successfully400 - Invalid request or user not found401 - Unauthorized - authentication required500 - Server error during team creation
2. Update Team
Endpoint:PUT /tenant/<tenant_id>
Description: Update team details. Only OWNER or ADMIN can update team information.
Path Parameters:
tenant_id (string, required) - Team ID
Request Body:
{"name":"string (optional, max 100 characters)","llm_id":"string (optional, must be added by the user)","embd_id":"string (optional, must be added by the user)","asr_id":"string (optional, must be added by the user)","img2txt_id":"string (optional, must be added by the user)","rerank_id":"string (optional, must be added by the user)","tts_id":"string (optional, must be added by the user)","parser_ids":"string (optional)","credit":"integer (optional)"}Response: Returns updated team information.
Status Codes:
200 - Team updated successfully400 - Invalid request401 - Unauthorized403 - Forbidden - not owner or admin404 - Team not found
3. Accept/Reject Team Invitation
Endpoint:PUT /tenant/update-request/<tenant_id>
Description: Accept or reject a team invitation. User must have INVITE role.
Path Parameters:
tenant_id (string, required) - Team ID
Request Body:
{"accept":"boolean (required) - true to accept, false to reject","role":"string (optional) - 'normal' or 'admin', only used when accept=true, defaults to 'normal'"}Response: Returns success status.
Status Codes:
200 - Invitation processed successfully400 - Invalid request401 - Unauthorized404 - Invitation not found
4. Add Users to Team
Endpoint:POST /tenant/<tenant_id>/users/add
Description: Add one or more users directly to a team. Only OWNER or ADMIN can add users. Users are added immediately without requiring invitation acceptance. Supports both single user and bulk operations.
Path Parameters:
tenant_id (string, required) - Team ID
Request Body:
{"users": ["string (email) or object with email and role", {"email":"string (required)","role":"string (optional) - 'normal', 'admin', or 'invite', defaults to 'normal'" } ]}Response:
{"added": [ {"id":"string","email":"string","nickname":"string","avatar":"string","role":"string" } ],"failed": [ {"email":"string","error":"string" } ]}Status Codes:
200 - Users added successfully (may include partial failures)400 - Invalid request401 - Unauthorized403 - Forbidden - not owner or admin
5. Remove User from Team
Endpoint:POST /tenant/<tenant_id>/user/remove
Description: Remove a user from a team. Only OWNER or ADMIN can remove users. Owners cannot be removed.
Path Parameters:
tenant_id (string, required) - Team ID
Request Body:
{"user_id":"string (required)"}Response:
{"user_id":"string","email":"string"}Status Codes:
200 - User removed successfully400 - Invalid request401 - Unauthorized403 - Forbidden - not owner or admin
6. Promote User to Admin
Endpoint:POST /tenant/<tenant_id>/admin/<user_id>/promote
Description: Promote a team member to admin role. Only team owners can promote members to admin. Cannot promote the team owner (owner role is permanent).
Path Parameters:
tenant_id (string, required) - Team IDuser_id (string, required) - User ID to promote to admin
Response: Returns success status and message.
Status Codes:
200 - User promoted to admin successfully400 - Invalid request or user not found401 - Unauthorized403 - Forbidden - not team owner404 - User not found in team
7. Demote Admin to Normal Member
Endpoint:POST /tenant/<tenant_id>/admin/<user_id>/demote
Description: Demote a team admin to normal member. Only team owners can demote admins. Cannot demote the team owner (owner role is permanent). Cannot demote yourself if you're the only admin/owner.
Path Parameters:
tenant_id (string, required) - Team IDuser_id (string, required) - User ID to demote from admin
Response: Returns success status and message.
Status Codes:
200 - Admin demoted to normal member successfully400 - Invalid request or user not found401 - Unauthorized403 - Forbidden - not team owner404 - User not found in team or not an admin
8. Get User Permissions
Endpoint:GET /tenant/<tenant_id>/users/<user_id>/permissions
Description: Get CRUD permissions for a team member. Only team owners or admins can view permissions.
Path Parameters:
tenant_id (string, required) - Team IDuser_id (string, required) - User ID to get permissions for
Response:
{"dataset": {"create":"boolean","read":"boolean","update":"boolean","delete":"boolean" },"canvas": {"create":"boolean","read":"boolean","update":"boolean","delete":"boolean" }}Status Codes:
200 - Permissions retrieved successfully401 - Unauthorized403 - Forbidden - not team owner or admin404 - User not found in team
9. Update User Permissions
Endpoint:PUT /tenant/<tenant_id>/users/<user_id>/permissions
Description: Update CRUD permissions for a team member. Only team owners or admins can update permissions. Owners and admins always have full permissions and cannot be restricted.
Path Parameters:
tenant_id (string, required) - Team IDuser_id (string, required) - User ID to update permissions for
Request Body:
{"permissions": {"dataset": {"create":"boolean (optional)","read":"boolean (optional)","update":"boolean (optional)","delete":"boolean (optional)" },"canvas": {"create":"boolean (optional)","read":"boolean (optional)","update":"boolean (optional)","delete":"boolean (optional)" } }}Response: Returns updated permissions object.
Status Codes:
200 - Permissions updated successfully400 - Invalid request401 - Unauthorized403 - Forbidden - not team owner or admin, or trying to restrict owner/admin404 - User not found in team
User Management Endpoints
All user management endpoints are under the/user base path.
10. Create User
Endpoint:POST /user/create
Description: Create a new user. Requires authentication.
Request Body:
{"nickname":"string (required)","email":"string (required, valid email format)","password":"string (required, plain text or RSA-encrypted)","is_superuser":"boolean (optional, default: false)"}Response: Returns created user information (id, email, nickname).
Status Codes:
200 - User created successfully400 - Invalid request or email already exists401 - Unauthorized - authentication required500 - Server error during user creation
11. Update User
Endpoint:PUT /user/update
Description: Update an existing user. Users can only update their own account.
Request Body:
{"user_id":"string (optional, if email is provided)","email":"string (optional, used to identify user or as new_email if user_id provided)","new_email":"string (optional, new email address)","nickname":"string (optional)","password":"string (optional, encrypted)","is_superuser":"boolean (optional)"}Response: Returns updated user information.
Status Codes:
200 - User updated successfully400 - Invalid request or user not found403 - Forbidden - users can only update their own account500 - Server error during user update
12. List Users
Endpoint:GET /user/list
Description: List all users. Requires authentication. Supports pagination and email filtering.
Query Parameters:
page (integer, optional) - Page number for paginationpage_size (integer, optional) - Number of items per pageemail (string, optional) - Filter by email address
Response:
{"data": [ {"id":"string","email":"string","nickname":"string","is_superuser":"boolean" } ],"message":"string"}Status Codes:
200 - Users retrieved successfully401 - Unauthorized - authentication required500 - Server error during user listing
13. Delete User
Endpoint:DELETE /user/delete
Description: Delete a user. Users can only delete their own account. Requires authentication.
Request Body:
{"user_id":"string (optional, if email is provided)","email":"string (optional, if user_id is provided)"}Response: Returns success status and message.
Status Codes:
200 - User deleted successfully400 - Invalid request or user not found401 - Unauthorized - authentication required403 - Forbidden - users can only delete their own account500 - Server error during user deletion
Summary
Total New Endpoints: 13
- Team Management: 9 endpoints
- User Management: 4 endpoints
All endpoints include proper authentication, authorization checks, input validation, and comprehensive error handling. The endpoints follow RESTful conventions and include detailed API documentation in their docstrings.
Canvas Authentication & Authorization
A comprehensive canvas permission system has been added to control access to canvases (agent canvases and dataflow canvases) within teams.
Canvas Permission Model
Canvases can be shared with teams using the following fields:
permission: Can be"me" (private) or"team" (shared with team)shared_tenant_id: Optional field to specify which specific team the canvas is shared with (only used whenpermission is"team")
Canvas CRUD Permissions
Canvas permissions are managed through the same permission system as datasets. Each team member can have the following permissions for canvases:
create: Create new team canvasesread: View and run team canvasesupdate: Modify team canvasesdelete: Delete team canvases
Permission Hierarchy
- Canvas Owner: Always has full permissions (create, read, update, delete) on their own canvases
- Team Owners & Admins: Always have full permissions on all team canvases
- Normal Members: Permissions are controlled by the CRUD permissions set by team owners/admins (default: read-only)
Canvas Access Control
TheUserCanvasService.accessible() method checks permissions before allowing canvas operations:
- Ownership Check: If the user owns the canvas, access is always granted
- Team Permission Check: If the canvas has
permission="team", the system checks:- User is a member of the target team (either
shared_tenant_id or canvas owner's team) - User has the required CRUD permission (create/read/update/delete) for that team
- Private Canvas: If
permission="me", only the owner can access it
Canvas Endpoints with Permission Checks
The following canvas endpoints now enforce permission checks:
GET /canvas/get/<canvas_id> - Requiresread permissionPOST /canvas/set - Requirescreate permission for new team canvases,update permission for existing canvasesPOST /canvas/rm - Requiresdelete permissionPOST /canvas/completion - Requiresread permission (to run the canvas)POST /canvas/reset - Requiresupdate permissionPOST /canvas/debug - Requiresread permission
Canvas Sharing Workflow
Create Team Canvas:
- User must have
create permission in the target team - Set
permission="team" and optionallyshared_tenant_id to share with a specific team - If
shared_tenant_id is not provided, canvas is shared with the owner's default team
Access Team Canvas:
- User must be a member of the team the canvas is shared with
- User must have appropriate CRUD permission (
read to view,update to modify, etc.)
List Team Canvases:
- Users see their own canvases plus team canvases they have access to
- Filtering is based on team membership and
shared_tenant_id
Integration with Team Permissions API
Canvas permissions are managed through the same endpoints as dataset permissions:
GET /tenant/<tenant_id>/users/<user_id>/permissions - Returns canvas permissions along with dataset permissionsPUT /tenant/<tenant_id>/users/<user_id>/permissions - Updates canvas permissions along with dataset permissions
Example permissions structure:
{"dataset": {"create":false,"read":true,"update":false,"delete":false },"canvas": {"create":true,"read":true,"update":true,"delete":false }}
Notes
- All endpoints require authentication unless otherwise specified
- Team endpoints use role-based access control (OWNER, ADMIN, NORMAL, INVITE)
- User endpoints allow users to manage only their own accounts
- All endpoints return consistent JSON response format with
data,message, andcode fields - Model IDs must be added by the user before they can be used in team creation/updates
- Permissions system supports CRUD operations on datasets and canvases
- Canvas permissions are enforced at the API level for all canvas operations
- Canvas owners always have full permissions on their own canvases, regardless of team permissions
- Team owners and admins always have full permissions on all team canvases
Type of change
New REST API Endpoints
Below is the list of all the new REST API endpoints added in the feature branch
feature/OND211-2329-Check-existing-REST-endponts-and-extend-with-new-requested-endpoints.Team Management Endpoints
All team management endpoints are under the
/tenantbase path and require authentication.1. Create Team
Endpoint:
POST /tenant/createDescription: Create a new team (tenant). Requires authentication - any registered user can create a team.
Request Body:
{"name":"string (required, max 100 characters)","user_id":"string (optional, defaults to current authenticated user)","llm_id":"string (optional, defaults to system default)","embd_id":"string (optional, defaults to system default)","asr_id":"string (optional, defaults to system default)","parser_ids":"string (optional, defaults to system default)","img2txt_id":"string (optional, defaults to system default)","rerank_id":"string (optional, defaults to system default)","credit":"integer (optional, defaults to 512)"}Response: Returns created team information with ID, name, owner_id, and model IDs.
Status Codes:
200- Team created successfully400- Invalid request or user not found401- Unauthorized - authentication required500- Server error during team creation2. Update Team
Endpoint:
PUT /tenant/<tenant_id>Description: Update team details. Only OWNER or ADMIN can update team information.
Path Parameters:
tenant_id(string, required) - Team IDRequest Body:
{"name":"string (optional, max 100 characters)","llm_id":"string (optional, must be added by the user)","embd_id":"string (optional, must be added by the user)","asr_id":"string (optional, must be added by the user)","img2txt_id":"string (optional, must be added by the user)","rerank_id":"string (optional, must be added by the user)","tts_id":"string (optional, must be added by the user)","parser_ids":"string (optional)","credit":"integer (optional)"}Response: Returns updated team information.
Status Codes:
200- Team updated successfully400- Invalid request401- Unauthorized403- Forbidden - not owner or admin404- Team not found3. Accept/Reject Team Invitation
Endpoint:
PUT /tenant/update-request/<tenant_id>Description: Accept or reject a team invitation. User must have INVITE role.
Path Parameters:
tenant_id(string, required) - Team IDRequest Body:
{"accept":"boolean (required) - true to accept, false to reject","role":"string (optional) - 'normal' or 'admin', only used when accept=true, defaults to 'normal'"}Response: Returns success status.
Status Codes:
200- Invitation processed successfully400- Invalid request401- Unauthorized404- Invitation not found4. Add Users to Team
Endpoint:
POST /tenant/<tenant_id>/users/addDescription: Add one or more users directly to a team. Only OWNER or ADMIN can add users. Users are added immediately without requiring invitation acceptance. Supports both single user and bulk operations.
Path Parameters:
tenant_id(string, required) - Team IDRequest Body:
{"users": ["string (email) or object with email and role", {"email":"string (required)","role":"string (optional) - 'normal', 'admin', or 'invite', defaults to 'normal'" } ]}Response:
{"added": [ {"id":"string","email":"string","nickname":"string","avatar":"string","role":"string" } ],"failed": [ {"email":"string","error":"string" } ]}Status Codes:
200- Users added successfully (may include partial failures)400- Invalid request401- Unauthorized403- Forbidden - not owner or admin5. Remove User from Team
Endpoint:
POST /tenant/<tenant_id>/user/removeDescription: Remove a user from a team. Only OWNER or ADMIN can remove users. Owners cannot be removed.
Path Parameters:
tenant_id(string, required) - Team IDRequest Body:
{"user_id":"string (required)"}Response:
{"user_id":"string","email":"string"}Status Codes:
200- User removed successfully400- Invalid request401- Unauthorized403- Forbidden - not owner or admin6. Promote User to Admin
Endpoint:
POST /tenant/<tenant_id>/admin/<user_id>/promoteDescription: Promote a team member to admin role. Only team owners can promote members to admin. Cannot promote the team owner (owner role is permanent).
Path Parameters:
tenant_id(string, required) - Team IDuser_id(string, required) - User ID to promote to adminResponse: Returns success status and message.
Status Codes:
200- User promoted to admin successfully400- Invalid request or user not found401- Unauthorized403- Forbidden - not team owner404- User not found in team7. Demote Admin to Normal Member
Endpoint:
POST /tenant/<tenant_id>/admin/<user_id>/demoteDescription: Demote a team admin to normal member. Only team owners can demote admins. Cannot demote the team owner (owner role is permanent). Cannot demote yourself if you're the only admin/owner.
Path Parameters:
tenant_id(string, required) - Team IDuser_id(string, required) - User ID to demote from adminResponse: Returns success status and message.
Status Codes:
200- Admin demoted to normal member successfully400- Invalid request or user not found401- Unauthorized403- Forbidden - not team owner404- User not found in team or not an admin8. Get User Permissions
Endpoint:
GET /tenant/<tenant_id>/users/<user_id>/permissionsDescription: Get CRUD permissions for a team member. Only team owners or admins can view permissions.
Path Parameters:
tenant_id(string, required) - Team IDuser_id(string, required) - User ID to get permissions forResponse:
{"dataset": {"create":"boolean","read":"boolean","update":"boolean","delete":"boolean" },"canvas": {"create":"boolean","read":"boolean","update":"boolean","delete":"boolean" }}Status Codes:
200- Permissions retrieved successfully401- Unauthorized403- Forbidden - not team owner or admin404- User not found in team9. Update User Permissions
Endpoint:
PUT /tenant/<tenant_id>/users/<user_id>/permissionsDescription: Update CRUD permissions for a team member. Only team owners or admins can update permissions. Owners and admins always have full permissions and cannot be restricted.
Path Parameters:
tenant_id(string, required) - Team IDuser_id(string, required) - User ID to update permissions forRequest Body:
{"permissions": {"dataset": {"create":"boolean (optional)","read":"boolean (optional)","update":"boolean (optional)","delete":"boolean (optional)" },"canvas": {"create":"boolean (optional)","read":"boolean (optional)","update":"boolean (optional)","delete":"boolean (optional)" } }}Response: Returns updated permissions object.
Status Codes:
200- Permissions updated successfully400- Invalid request401- Unauthorized403- Forbidden - not team owner or admin, or trying to restrict owner/admin404- User not found in teamUser Management Endpoints
All user management endpoints are under the
/userbase path.10. Create User
Endpoint:
POST /user/createDescription: Create a new user. Requires authentication.
Request Body:
{"nickname":"string (required)","email":"string (required, valid email format)","password":"string (required, plain text or RSA-encrypted)","is_superuser":"boolean (optional, default: false)"}Response: Returns created user information (id, email, nickname).
Status Codes:
200- User created successfully400- Invalid request or email already exists401- Unauthorized - authentication required500- Server error during user creation11. Update User
Endpoint:
PUT /user/updateDescription: Update an existing user. Users can only update their own account.
Request Body:
{"user_id":"string (optional, if email is provided)","email":"string (optional, used to identify user or as new_email if user_id provided)","new_email":"string (optional, new email address)","nickname":"string (optional)","password":"string (optional, encrypted)","is_superuser":"boolean (optional)"}Response: Returns updated user information.
Status Codes:
200- User updated successfully400- Invalid request or user not found403- Forbidden - users can only update their own account500- Server error during user update12. List Users
Endpoint:
GET /user/listDescription: List all users. Requires authentication. Supports pagination and email filtering.
Query Parameters:
page(integer, optional) - Page number for paginationpage_size(integer, optional) - Number of items per pageemail(string, optional) - Filter by email addressResponse:
{"data": [ {"id":"string","email":"string","nickname":"string","is_superuser":"boolean" } ],"message":"string"}Status Codes:
200- Users retrieved successfully401- Unauthorized - authentication required500- Server error during user listing13. Delete User
Endpoint:
DELETE /user/deleteDescription: Delete a user. Users can only delete their own account. Requires authentication.
Request Body:
{"user_id":"string (optional, if email is provided)","email":"string (optional, if user_id is provided)"}Response: Returns success status and message.
Status Codes:
200- User deleted successfully400- Invalid request or user not found401- Unauthorized - authentication required403- Forbidden - users can only delete their own account500- Server error during user deletionSummary
Total New Endpoints: 13
All endpoints include proper authentication, authorization checks, input validation, and comprehensive error handling. The endpoints follow RESTful conventions and include detailed API documentation in their docstrings.
Canvas Authentication & Authorization
A comprehensive canvas permission system has been added to control access to canvases (agent canvases and dataflow canvases) within teams.
Canvas Permission Model
Canvases can be shared with teams using the following fields:
permission: Can be"me"(private) or"team"(shared with team)shared_tenant_id: Optional field to specify which specific team the canvas is shared with (only used whenpermissionis"team")Canvas CRUD Permissions
Canvas permissions are managed through the same permission system as datasets. Each team member can have the following permissions for canvases:
create: Create new team canvasesread: View and run team canvasesupdate: Modify team canvasesdelete: Delete team canvasesPermission Hierarchy
Canvas Access Control
The
UserCanvasService.accessible()method checks permissions before allowing canvas operations:permission="team", the system checks:shared_tenant_idor canvas owner's team)permission="me", only the owner can access itCanvas Endpoints with Permission Checks
The following canvas endpoints now enforce permission checks:
GET /canvas/get/<canvas_id>- RequiresreadpermissionPOST /canvas/set- Requirescreatepermission for new team canvases,updatepermission for existing canvasesPOST /canvas/rm- RequiresdeletepermissionPOST /canvas/completion- Requiresreadpermission (to run the canvas)POST /canvas/reset- RequiresupdatepermissionPOST /canvas/debug- RequiresreadpermissionCanvas Sharing Workflow
Create Team Canvas:
createpermission in the target teampermission="team"and optionallyshared_tenant_idto share with a specific teamshared_tenant_idis not provided, canvas is shared with the owner's default teamAccess Team Canvas:
readto view,updateto modify, etc.)List Team Canvases:
shared_tenant_idIntegration with Team Permissions API
Canvas permissions are managed through the same endpoints as dataset permissions:
GET /tenant/<tenant_id>/users/<user_id>/permissions- Returns canvas permissions along with dataset permissionsPUT /tenant/<tenant_id>/users/<user_id>/permissions- Updates canvas permissions along with dataset permissionsExample permissions structure:
{"dataset": {"create":false,"read":true,"update":false,"delete":false },"canvas": {"create":true,"read":true,"update":true,"delete":false }}Notes
data,message, andcodefieldsType of change