MS Teams – Team – Get Teams
MS Teams – Team – Get Teams
Get the list of teams a user is a member of.
Action details
| Property | Value |
|---|---|
| Action label | MS Teams – Team – Get Teams |
| Category | CloudTools |
| Apex class and method | GetMSTeamsTeams.getTeams |
| Input type | GetMSTeamsTeams.GetMSTeamsTeamsInput |
| Output type | List<List<MSTeamsTeam>> |
| Authorization | Microsoft 365 connector; check endpoint support for delegated and application access. |
| Microsoft Graph request | GET /users/{userId}/joinedTeams |
Prerequisites and permissions
Configure a CloudTools Connector with Connector Type set to Microsoft 365. Complete Microsoft sign-in for OAuth Delegated (Authorization Code). For endpoints supporting OAuth Application (Client Credentials), grant application permissions and administrator consent. The identity must have access to the selected resource. See Creating an Entra ID App and Integration Connectors for setup.
The action permission provider declares these alternatives. They are not cumulative requirements, and not all are least privileged. Confirm endpoint restrictions and any resource-specific consent requirements in the Microsoft reference.
| Permission type | Declared alternatives |
|---|---|
| Delegated | Team.ReadBasic.All, AgentIdUser.ReadWrite.All, AgentIdUser.ReadWrite.IdentityParentedBy, Directory.Read.All, Directory.ReadWrite.All, TeamSettings.Read.All, TeamSettings.ReadWrite.All, User.Read.All, User.ReadWrite.All |
| Application | Team.ReadBasic.All, TeamSettings.Read.All, TeamSettings.ReadWrite.All |
Endpoints: /users/{userId}/joinedTeams. Group and Directory permissions are listed for backward compatibility.
See the Microsoft operation and permissions reference.
Inputs
| Input | Apex field | Type | Required | Description |
|---|---|---|---|---|
| User Id | userId | String | Yes | Microsoft user identifier or UPN |
Supply a nonempty list with a non-null first request. This implementation processes only the first request and does not bulk-process Flow interviews. Global inputs do not expose connectorId; Flow and subscriber Apex use CloudTools connector selection. Use Microsoft Graph IDs, not Salesforce IDs or browser links. Resolve dynamic values before invoking this action.
Outputs
Returns an outer list containing one collection of MSTeamsTeam items. A missing or unmappable collection produces an empty inner list. The outer list does not correspond to every input request.
| Output | Apex field | Type | Description |
|---|---|---|---|
| Id | id | String | Unique identifier of the team |
| Display Name | displayName | String | Display name of the team |
| Description | description | String | Description of the team |
| Created Date Time | createdDateTime | String | Created timestamp for the team |
| Internal Id | internalId | String | Internal identifier for the team |
| Classification | classification | String | Classification label for the team |
| Specialization | specialization | String | Specialization for the team |
| Visibility | visibility | String | Visibility of the team |
| Web URL | webUrl | String | Link to the team in Teams |
| Is Archived | isArchived | Boolean | Whether the team is archived |
| Tenant Id | tenantId | String | Tenant identifier for the team |
| OData Type | odataType | String | OData type for the team |
| Additional Properties | additionalProperties | List<DynamicObject> | Additional properties from user-defined query |
Behavior and limits
Only the returned value collection is mapped; this action does not follow or expose @odata.nextLink. A result may contain only the first page.
Use in Flow
Add MS Teams – Team – Get Teams where supported. Use a Microsoft 365 application connector configured as Set as default for Flow automations only if the endpoint supports the required application operation. Delegated connections are not supported for CloudTools Flow automation. Supply required values, retain outputs, and add fault handling.
Use in custom Apex
This subscriber-org example uses the Apptigent namespace. Replace example identifiers and values before use. Configure the connector, arrange authorization first, run in a context permitting callouts, and handle exceptions and empty results.
Apptigent.GetMSTeamsTeams.GetMSTeamsTeamsInput request =
new Apptigent.GetMSTeamsTeams.GetMSTeamsTeamsInput();
request.userId = 'd7b45f12-8a16-4a1f-95f1-dfde7f2af91b';
List<List<Apptigent.MSTeamsTeam>> results =
Apptigent.GetMSTeamsTeams.getTeams(
new List<Apptigent.GetMSTeamsTeams.GetMSTeamsTeamsInput>{ request }
);
System.debug(results);
Use in a Lightning Web Component
Use getMSTeamsTeams from msTeamsConnectorLib through MSTeamsConnectorController. Set request.connectorId to select a configured connector. These c/ imports apply in the same namespace. The controller uses a shared request DTO; its field names differ from the global invocable input.
| Global input | LWC request mapping |
|---|---|
userId | request.userId |
teamsActionExample.js
import { LightningElement } from 'lwc';
import { getMSTeamsTeams } from 'c/msTeamsConnectorLib';
export default class TeamsActionExample extends LightningElement {
result = null;
errorMessage = '';
isRunning = false;
completed = false;
async handleRun() {
if (this.isRunning || this.completed) return;
this.isRunning = true;
this.errorMessage = '';
try {
const request = { connectorId: 'REPLACE_WITH_CONNECTOR_RECORD_ID' };
request.userId = 'd7b45f12-8a16-4a1f-95f1-dfde7f2af91b';
this.result = await getMSTeamsTeams(request);
this.completed = true;
} catch (error) {
this.errorMessage = error.requiresInteractiveAuthorization
? 'Sign in to Microsoft for the connector, then try again.'
: error.message || 'The Teams action failed.';
} finally {
this.isRunning = false;
}
}
}
teamsActionExample.html
<template>
<lightning-button label="Run action" onclick={handleRun}
disabled={isRunning}></lightning-button>
<p role="alert">{errorMessage}</p>
</template>
The library resolves to an array of mapped objects. rawJson serializes the mapped Apex model rather than the untouched Microsoft response. Message body, membership roles, and nested properties can be flattened or serialized in JavaScript DTOs.
Use getMSTeamsAuthorizationState, beginMSTeamsAuthorization, and createMSTeamsOAuthMessageHandler to arrange delegated sign-in. The library normalizes errors but does not automatically sign in or retry. Reset completed for a new deliberate operation. Inspect resource state before retrying a mutation with an uncertain outcome.
Error handling and troubleshooting
| Symptom | What to check |
|---|---|
| Required fields error | Supply a nonempty request list, a non-null first request, and required or conditionally required values. For LWC, check controller mappings. |
| Authorization or access denied | Check selected connector, delegated versus application support, consent, Teams app installation where required, and access to the resource. |
| Resource not found | Check team, channel, chat, message, membership, and app installation IDs; these are distinct identifiers. |
| Missing data | Check pagination, query support, empty-response behavior, and documented model mapping. |
| Operation rejected | Inspect the Microsoft error, endpoint restrictions, supported properties, message authorization limits, and notification configuration. |