MS Teams – Team – Copy Team
MS Teams – Team – Copy Team
Create a copy of a Team.
Action details
| Property | Value |
|---|---|
| Action label | MS Teams – Team – Copy Team |
| Category | CloudTools |
| Apex class and method | CopyMSTeamsTeam.copyTeam |
| Input type | CopyMSTeamsTeam.CopyMSTeamsTeamInput |
| Output type | List<CopyMSTeamsTeam.CopyMSTeamsTeamOutput> |
| Authorization | Microsoft 365 connector; check endpoint support for delegated and application access. |
| Microsoft Graph request | POST /teams/{teamId}/clone |
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.Create, Directory.ReadWrite.All, Group.ReadWrite.All |
| Application | Team.Create, Directory.ReadWrite.All, Group.ReadWrite.All |
Endpoints: /teams/{teamId}/clone. Group and Directory permissions are listed for backward compatibility.
See the Microsoft operation and permissions reference.
Inputs
| Input | Apex field | Type | Required | Description |
|---|---|---|---|---|
| Team Id | teamId | String | Yes | Source MS Teams team identifier |
| Display Name | displayName | String | Yes | Display name for the copied team |
| Description | description | String | No | Description for the copied team |
| Mail Nickname | mailNickname | String | No | Mail nickname for the copied team |
| Parts To Clone | partsToCloneCsv | String | No | Comma-separated values from apps,tabs,settings,channels,members. Defaults to all. |
| Visibility | visibility | String | No | Optional team visibility: public or private |
| Classification | classification | String | No | Optional group classification |
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 one operation result after the request completes. Inspect its documented fields. Failures throw an exception rather than returning a success=false result.
| Output | Apex field | Type | Description |
|---|---|---|---|
| Success | success | Boolean | Whether the copy request was accepted |
| Message | message | String | Result message |
| AsyncLocationUrl | asyncLocationUrl | String | Value from response Location header for operation polling |
Behavior and limits
The implementation accepts HTTP status codes from 200 through 399. Success means the request was accepted by this check; it does not prove an asynchronous operation finished.
Retain asyncLocationUrl from the Location header and poll the operation status. Do not treat success=true as completed team creation, archiving, or cloning.
Parts To Clone defaults to apps,tabs,settings,channels,members. The connector validates and deduplicates these names; visibility accepts public or private. Clone completion does not imply that messages or files were copied.
Use in Flow
Add MS Teams – Team – Copy Team 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.CopyMSTeamsTeam.CopyMSTeamsTeamInput request =
new Apptigent.CopyMSTeamsTeam.CopyMSTeamsTeamInput();
request.teamId = '893075dd-2487-4122-925f-022c42e20265';
request.displayName = 'Library Assist';
request.description = 'Self help community for library';
request.mailNickname = 'libassist';
request.partsToCloneCsv = 'apps,tabs,settings,channels,members';
request.visibility = 'public';
request.classification = 'medium';
List<Apptigent.CopyMSTeamsTeam.CopyMSTeamsTeamOutput> results =
Apptigent.CopyMSTeamsTeam.copyTeam(
new List<Apptigent.CopyMSTeamsTeam.CopyMSTeamsTeamInput>{ request }
);
System.debug(results);
Use in a Lightning Web Component
Use copyMSTeamsTeam 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 |
|---|---|
teamId | request.teamId |
displayName | request.displayName |
description | request.description |
mailNickname | request.mailNickname |
partsToCloneCsv | request.clonePartsCsv |
visibility | request.visibility |
classification | request.classification |
teamsActionExample.js
import { LightningElement } from 'lwc';
import { copyMSTeamsTeam } 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.teamId = '893075dd-2487-4122-925f-022c42e20265';
request.displayName = 'Library Assist';
request.description = 'Self help community for library';
request.mailNickname = 'libassist';
request.clonePartsCsv = 'apps,tabs,settings,channels,members';
request.visibility = 'public';
request.classification = 'medium';
this.result = await copyMSTeamsTeam(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 one mapped object or null. 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. |