New Team request for Teams using Flow (and Graph API)

Whilst Flow does have some integration with Microsoft Teams, one missing feature is the ability to create a Team in Microsoft Teams (you can create Channels, messages etc.).

With recent additions to Graph API, you can create a Team using a template and a Graph API call. This API call can be used within a flow. In this scenario, I’m going to create a flow to create a Team. This will work like so:

  1. A user (who cannot create a Team on their own) sends a request to have a new Team created for them. They will request a Team name and description.
  2. The team that is responsible for these requests will approve or deny the request.
  3. If the request is approved, a Team is then created using the user submitted details. The requester is also added as a Team owner.
  4. With the Team created, the requester can manage the Team and add other members to it.


Before starting, you will need to ensure you have the following:

  • Access to an Office 365 tenant with administrative access to Azure AD
  • Access to create flows in Microsoft Flow
  • Access to create a Form in Office 365

In addition, you need to have created an Azure AD application with the Group.ReadWrite.All and User.Read Application permissions (see Step 1 of this post for instructions on how to create an Azure AD application).

With the Azure AD application created, make sure you have the Application ID, Directory ID and Secret to hand as these will be needed later.

Step 1 - Create a Form

Whilst there are various methods to get the data into Flow, for ease of use I’ve created a Form to capture the request.

Go to and create a Form. It should ask two text-based questions - Team Name and Team Description.

Make a note of the URL to use the form under the Share button.

Step 2 - Create a Flow

Go to and go to My flows. Select New > Create from blank to create a new flow.

Don’t use any triggers and select Create from blank

Under the search box, search for Forms and select Microsoft Forms. Select When a new response is submitted. You may get asked to sign in. Once signed in, select the Form Id that you just created.

The next step in the flow is to create some variables. These variables are the application (client) id, directory (tenant) id and secret you should have from the creating the Azure AD application. Create 3 variables like below.

Now, select New step and search Apply to each. Select List of response notifications to apply to each.

Select Add an action and search for Forms again and select Get response details.

Select the Form Id as the Form you created earlier. The Response Id is List of response notifications Response id.

Add another action and search for Approval and select Start an approval. Fill in the approval similar to below.

Next, you need to add a condition based on whether the request is approved or rejected. Select Add an action and search for Conditon. Fill in condition as below.

Next, we need to set the behaviour based on the response. If yes (approved), it will create a Team. Under yes, search for HTTP action and select it. This is a Graph API call to get the requester’s user id (as you need this to create the Team). Complete the HTTP as follows:

The HTTP request will create a JSON output. Within this is the id of the user. To extract it, we need to parse the JSON into variables. Add another action called Parse JSON and populate like below.

The Schema need to be in this format:

    "type": "object",
    "properties": {
        "@@odata.context": {
            "type": "string"
        "id": {
            "type": "string"

Once you have the user id as a variable, you can create another HTTP action to create the Team.

  • Method to POST
  • URI to
  • Header to content-type = **application/**json
  • Body something like below. I’ve gone with the standard template, but others can be used. The requester is added as the owner, but you could also add other users. {
    [email protected]”: “",
    “displayName”: “@{body(‘Get_response_details’)?[‘ra11f0c6dc8c041d085b70ed5802f2d30’]}”,
    “description”: “@{body(‘Get_response_details’)?[‘r5fafbc603e5a4ee38eaa3f13e36b4b1d’]}”,
    [email protected]”: [
  • Authentication to Active Directory OAuth
  • Authority to
  • Tenant to the directory_id variable you created
  • Audience to
  • Client ID to the application_id variable you created
  • Credential Type to Secret
  • Secret to the secret variable you created

The next action I added after this was a Condition that if the group was created (status code 202).

Status code (from ‘HTTP 2’) is equal to 202

If yes (the team was created), I’ve added an action (in my case Send an email) to notify the requester and approver.

You could also mirror above if the group was not created or rejected, but I’m not going to repeat those steps.

The flow is now complete, an overview of my flow looks like this.

Step 3 - Test the Flow

With the flow created, it can now be tested. Go back to the Form and submit a new Team.

The approval team will receive an email with the request.

The request is approved.

The requester is notifed of the Team creation.

The Team is there to be used by the requester.

And there you have it, automated Team creation based on requests.