# Teams

## List members of a team

> Retrieves a paginated list of members belonging to a specific team. Returns detailed information about each member including:\
> &#x20;       \- User details (ID, email, name)\
> &#x20;       \- Role within the team (owner or member)\
> &#x20;       \- Join date and last activity\
> \
> &#x20;       Supports filtering by role and pagination via limit/offset. All authenticated users can view team member lists for teams they have access to. Team membership is verified based on the requesting user's permissions.

```json
{"openapi":"3.0.0","info":{"title":"sfp server","version":"51.3.0"},"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"JWT","type":"http","in":"header"}},"schemas":{"ListTeamMembersResponseDto":{"type":"object","properties":{"members":{"description":"List of team members","type":"array","items":{"$ref":"#/components/schemas/TeamMembershipDto"}},"total":{"type":"number","description":"Total number of members"}},"required":["members","total"]},"TeamMembershipDto":{"type":"object","properties":{"user_id":{"type":"string","description":"User ID"},"account_id":{"type":"string","description":"Team/account ID"},"email":{"type":"string","description":"Email of the user"},"first_name":{"type":"string","description":"First name of the user"},"last_name":{"type":"string","description":"Last name of the user"},"role":{"type":"string","description":"Role of the user in the team","enum":["owner","member"]},"created_at":{"type":"string","description":"Creation timestamp"}},"required":["user_id","account_id","email","role","created_at"]}}},"paths":{"/sfp/api/teams/{slug}/members":{"get":{"operationId":"TeamsController_listTeamMembers","summary":"List members of a team","description":"Retrieves a paginated list of members belonging to a specific team. Returns detailed information about each member including:\n        - User details (ID, email, name)\n        - Role within the team (owner or member)\n        - Join date and last activity\n\n        Supports filtering by role and pagination via limit/offset. All authenticated users can view team member lists for teams they have access to. Team membership is verified based on the requesting user's permissions.","parameters":[{"name":"slug","required":true,"in":"path","description":"Team slug","schema":{"type":"string"}},{"name":"limit","required":false,"in":"query","description":"Maximum number of members to return","schema":{"type":"number"}},{"name":"offset","required":false,"in":"query","description":"Offset for pagination","schema":{"type":"number"}},{"name":"role","required":false,"in":"query","description":"Filter by role","schema":{"enum":["owner","member"],"type":"string"}}],"responses":{"200":{"description":"List of team members retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListTeamMembersResponseDto"}}}},"400":{"description":"Bad request"},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden - Requires role: owner, member, application"}},"tags":["Teams"]}}}}
```

## Add a member to a team

> Adds a new member to an existing team with the specified role. This endpoint:\
> &#x20;       \- Creates team membership if user exists in the system\
> &#x20;       \- Assigns the specified role (owner or member)\
> &#x20;       \- Grants access to team resources based on role\
> &#x20;       \- Sends notification to the new member\
> &#x20;       \
> &#x20;       The user must already have an account in the system. Use the users endpoint to create new users first. Only team owners can add new members.

```json
{"openapi":"3.0.0","info":{"title":"sfp server","version":"51.3.0"},"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"JWT","type":"http","in":"header"}},"schemas":{"AddTeamMemberDto":{"type":"object","properties":{"email":{"type":"string","description":"Email of the user to add to the team"},"role":{"type":"string","description":"Role for the user in the team","enum":["owner","member"]}},"required":["email","role"]},"AddTeamMemberResponse":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the operation was successful"},"membership":{"description":"The created membership details","allOf":[{"$ref":"#/components/schemas/TeamMembershipDto"}]},"error":{"type":"string","description":"Error message if operation failed"}},"required":["success"]},"TeamMembershipDto":{"type":"object","properties":{"user_id":{"type":"string","description":"User ID"},"account_id":{"type":"string","description":"Team/account ID"},"email":{"type":"string","description":"Email of the user"},"first_name":{"type":"string","description":"First name of the user"},"last_name":{"type":"string","description":"Last name of the user"},"role":{"type":"string","description":"Role of the user in the team","enum":["owner","member"]},"created_at":{"type":"string","description":"Creation timestamp"}},"required":["user_id","account_id","email","role","created_at"]}}},"paths":{"/sfp/api/teams/{slug}/members":{"post":{"operationId":"TeamsController_addTeamMember","summary":"Add a member to a team","description":"Adds a new member to an existing team with the specified role. This endpoint:\n        - Creates team membership if user exists in the system\n        - Assigns the specified role (owner or member)\n        - Grants access to team resources based on role\n        - Sends notification to the new member\n        \n        The user must already have an account in the system. Use the users endpoint to create new users first. Only team owners can add new members.","parameters":[{"name":"slug","required":true,"in":"path","description":"Team slug","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddTeamMemberDto"}}}},"responses":{"201":{"description":"Member added successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddTeamMemberResponse"}}}},"400":{"description":"Bad request"},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden - Requires role: owner"}},"tags":["Teams"]}}}}
```

## Create a new team

> Creates a new team within the organization. Teams are used to:\
> &#x20;       \- Group users for collaborative access to resources\
> &#x20;       \- Manage permissions at a team level\
> &#x20;       \- Organize repositories, environments, and other resources\
> &#x20;       \
> &#x20;       The team slug must be unique and URL-friendly. The creating user automatically becomes a team owner. Only users with owner role can create new teams.

```json
{"openapi":"3.0.0","info":{"title":"sfp server","version":"51.3.0"},"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"JWT","type":"http","in":"header"}},"schemas":{"CreateTeamDto":{"type":"object","properties":{"name":{"type":"string","description":"The name of the team"},"slug":{"type":"string","description":"The slug for the team URL"},"description":{"type":"string","description":"Optional description of the team"}},"required":["name","slug"]},"CreateTeamResponse":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the operation was successful"},"team":{"description":"The created team","allOf":[{"$ref":"#/components/schemas/TeamDto"}]},"error":{"type":"string","description":"Error message if operation failed"}},"required":["success"]},"TeamDto":{"type":"object","properties":{"id":{"type":"string","description":"The unique identifier of the team"},"name":{"type":"string","description":"The name of the team"},"slug":{"type":"string","description":"The slug for the team URL"},"description":{"type":"string","description":"Description of the team"},"primary_owner_user_id":{"type":"string","description":"The user ID of the primary owner"},"email":{"type":"string","description":"The email address associated with the team"},"created_at":{"type":"string","description":"Creation timestamp"}},"required":["id","name","slug","primary_owner_user_id","email","created_at"]}}},"paths":{"/sfp/api/teams":{"post":{"operationId":"TeamsController_createTeam","summary":"Create a new team","description":"Creates a new team within the organization. Teams are used to:\n        - Group users for collaborative access to resources\n        - Manage permissions at a team level\n        - Organize repositories, environments, and other resources\n        \n        The team slug must be unique and URL-friendly. The creating user automatically becomes a team owner. Only users with owner role can create new teams.","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTeamDto"}}}},"responses":{"201":{"description":"Team created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTeamResponse"}}}},"400":{"description":"Bad request"},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden - Requires role: owner"}},"tags":["Teams"]}}}}
```

## Delete a team

> Permanently deletes a team and all its associations. This action:\
> &#x20;       \- Removes all team memberships\
> &#x20;       \- Disassociates team from repositories and resources\
> &#x20;       \- Removes team-specific permissions and access\
> &#x20;       \- Cannot be undone\
> &#x20;       \
> &#x20;       All team resources must be reassigned or deleted before team deletion. Only users with owner role can delete teams. The last team in an organization cannot be deleted.

```json
{"openapi":"3.0.0","info":{"title":"sfp server","version":"51.3.0"},"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"JWT","type":"http","in":"header"}},"schemas":{"DeleteTeamResponse":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the operation was successful"},"error":{"type":"string","description":"Error message if operation failed"}},"required":["success"]}}},"paths":{"/sfp/api/teams/{slug}":{"delete":{"operationId":"TeamsController_deleteTeam","summary":"Delete a team","description":"Permanently deletes a team and all its associations. This action:\n        - Removes all team memberships\n        - Disassociates team from repositories and resources\n        - Removes team-specific permissions and access\n        - Cannot be undone\n        \n        All team resources must be reassigned or deleted before team deletion. Only users with owner role can delete teams. The last team in an organization cannot be deleted.","parameters":[{"name":"slug","required":true,"in":"path","description":"Team slug","schema":{"type":"string"}}],"responses":{"200":{"description":"Team deleted successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteTeamResponse"}}}},"400":{"description":"Bad request"},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden - Requires role: owner"}},"tags":["Teams"]}}}}
```

## Remove a member from a team

> Removes a member from a team, revoking their access to team resources. This action:\
> &#x20;       \- Removes team membership immediately\
> &#x20;       \- Revokes access to all team repositories and resources\
> &#x20;       \- Removes team-specific permissions\
> &#x20;       \- Does not delete the user account\
> &#x20;       \
> &#x20;       Team must maintain at least one owner. Users cannot remove themselves if they are the last owner. Only team owners can remove members.

```json
{"openapi":"3.0.0","info":{"title":"sfp server","version":"51.3.0"},"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"JWT","type":"http","in":"header"}},"schemas":{"RemoveTeamMemberResponse":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the operation was successful"},"error":{"type":"string","description":"Error message if operation failed"}},"required":["success"]}}},"paths":{"/sfp/api/teams/{slug}/members/{email}":{"delete":{"operationId":"TeamsController_removeTeamMember","summary":"Remove a member from a team","description":"Removes a member from a team, revoking their access to team resources. This action:\n        - Removes team membership immediately\n        - Revokes access to all team repositories and resources\n        - Removes team-specific permissions\n        - Does not delete the user account\n        \n        Team must maintain at least one owner. Users cannot remove themselves if they are the last owner. Only team owners can remove members.","parameters":[{"name":"slug","required":true,"in":"path","description":"Team slug","schema":{"type":"string"}},{"name":"email","required":true,"in":"path","description":"Member email","schema":{"type":"string"}}],"responses":{"200":{"description":"Member removed successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoveTeamMemberResponse"}}}},"400":{"description":"Bad request"},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden - Requires role: owner"}},"tags":["Teams"]}}}}
```

## Update a team member's role

> Changes the role of an existing team member. Available roles:\
> &#x20;       \- owner: Full team management permissions, can add/remove members\
> &#x20;       \- member: Access to team resources but no management permissions\
> &#x20;       \
> &#x20;       Role changes take effect immediately. Teams must maintain at least one owner. Users cannot demote themselves if they are the last owner. Only team owners can change member roles.

```json
{"openapi":"3.0.0","info":{"title":"sfp server","version":"51.3.0"},"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"JWT","type":"http","in":"header"}},"schemas":{"AddTeamMemberResponse":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the operation was successful"},"membership":{"description":"The created membership details","allOf":[{"$ref":"#/components/schemas/TeamMembershipDto"}]},"error":{"type":"string","description":"Error message if operation failed"}},"required":["success"]},"TeamMembershipDto":{"type":"object","properties":{"user_id":{"type":"string","description":"User ID"},"account_id":{"type":"string","description":"Team/account ID"},"email":{"type":"string","description":"Email of the user"},"first_name":{"type":"string","description":"First name of the user"},"last_name":{"type":"string","description":"Last name of the user"},"role":{"type":"string","description":"Role of the user in the team","enum":["owner","member"]},"created_at":{"type":"string","description":"Creation timestamp"}},"required":["user_id","account_id","email","role","created_at"]}}},"paths":{"/sfp/api/teams/{slug}/members/{email}/role":{"put":{"operationId":"TeamsController_updateTeamMemberRole","summary":"Update a team member's role","description":"Changes the role of an existing team member. Available roles:\n        - owner: Full team management permissions, can add/remove members\n        - member: Access to team resources but no management permissions\n        \n        Role changes take effect immediately. Teams must maintain at least one owner. Users cannot demote themselves if they are the last owner. Only team owners can change member roles.","parameters":[{"name":"slug","required":true,"in":"path","description":"Team slug","schema":{"type":"string"}},{"name":"email","required":true,"in":"path","description":"Member email","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"role":{"type":"string","enum":["owner","member"],"description":"The new role for the team member"}},"required":["role"]}}}},"responses":{"200":{"description":"Member role updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddTeamMemberResponse"}}}},"400":{"description":"Bad request"},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden - Requires role: owner"}},"tags":["Teams"]}}}}
```
