How to apply a site template

Site templates were formerly known as site designs. Microsoft has recently added some new ones in SharePoint Online. In this article I will show you how you can apply one to a site from Power Automate.

What is a site template?

A site template contains a consistent set of actions called site scripts. Site scripts can be things like applying a theme, setting the regionals settings of your site or adding a new library. A site template can be applied to existing sites. You can either use the ones provided by Microsoft or create one yourself.

Below is a list of the Microsoft Site Templates have provided at this point in time (23-07-2021). You can use the GUID of the template you want to use later on in the Power Automate flow.

TitleGUIDSupported Web Templates
Department73495f08-0140-499b-8927-dd26a546f26aCommunication Site (68)
Event planning9522236e-6802-4972-a10d-e98dc74b3344Team Site (64)
Leadership connectioncd4c26b2-b231-419a-8bb4-9b1d9b83aef6Communication Site (68)
Project managementf0a3abf4-afe8-4409-b7f3-484113dee93eTeam Site (64)
Training and courses695e52c9-8af7-4bd3-b7a5-46aca95e1c7eTeam Site (64)
Training and development team64aaa31e-7a1e-4337-b646-0b700aa9a52cTeam Site (64)
Learning centralb8ef3134-92a2-4c9d-bca6-c2f14e79fe98Communication Site (68)
New employee onboarding2a23fa44-52b0-4814-baba-06fef1ab931eCommunication Site (68)
Crisis management905bb0b4-01e8-4f55-b73c-f07f08aee3a4Communication Site (68)
Team collaborationc8b3137a-ca4c-48a9-b356-a8e7987dd693Team Site (64)
Blankf6cc5403-0d63-442e-96c0-285923709ffcCommunication Site (68)
Showcase6142d2a0-63a5-4ba0-aede-d9fefca2c767Communication Site (68)
Topic96c933ac-3698-44c7-9f4a-5fd17d71af9eCommunication Site (68)
SharePoint Online Site Templates overview with GUIDs

How did you find those GUIDs?

I found these Site Templates and its GUIDs by using a REST API method, GetSiteDesigns. The only thing you need to do is add ?store=1 at the end. Below is screenshot of that request in a Power Automate flow action.

getsitetemplatesmicrosoft

How can you create your own?

It is also possible to create your own custom site templates. First of all you need to created the site scripts can via JSON files. These site scripts can be added to one or multiple site templates. You can deploy the site templates and site scripts to your tenant via PowerShell or the REST API.

1. Create a site script and add it via the Add-SPOSiteScript cmdlet to your tenant via SharePoint Online PowerShell.
Replace the principal value by the user or group you want to use to add to the owners.

2. Use the ID from the output to create a Site Design via the Add-SPOSiteDesign cmdlet. 68 is the id of a Communication site btw.

addspositedesign_example

Apply the Site Template via Power Automate

In this flow we will automatically apply a site template to a site collection. In our example we are using the custom site template we created earlier, Test Communication Site. The GUID of this custom site template is 9e8294b4-551f-4777-bc17-b7fdaf773144. Make sure you use the correct GUID when setting up your flow.

1. Add a Manually trigger a flow action.

2. Add a Send an HTTP request to SharePoint action. Select your the target site for the Site Address field. Use the AddSiteDesignTaskToCurrentWeb method in the URI. Also make sure you use the id of the site template you want to use in your body.

addsitedesigntasktocurrentweb

That should be it from a configuration point of view. Now just manually run it and the site template should be applied to your target site.

Happy testing!

You may also like...

6 Responses

  1. As a final step with ApplySiteDesign it should be possible to apply the site design to the existing site collection.

  2. Dennis says:

    @Karl Gerd Schneider, yes that would also be possible. However, the ApplySiteDesign is kind of considered as the older method of applying site designs, because of 30 action limitation.

    I prefer the AddSiteDesignTaskToCurrentWeb method because that doesn’t have that same limitation and is also asynchronous. Beau Cameron has written a nice blogpost about this: https://beaucameron.com/2019/01/10/invoking-a-site-design-task-using-rest/

  3. Jose says:

    Hello Denis, thank you very much for the publication. I am trying to apply a template to a sub site and a new site collection, but in both cases it gives me an error: status 400 Unexpected response from the service
    clientRequestId
    any ideas?

  4. Oliver Wakefield says:

    I’m struggling to apply a site design using the method above with a default Site Template e.g. Event planning. I get a 404 error when trying to apply. I can get a custom one to be applied.

  5. Dennis says:

    Hi Jose,

    Afaik applying a template to a subsite is not supported, this are only templates for site collections. My guess is that this is the reason why you are getting a HTTP 400 response is a bad request.

    If you are still struggling with applying a template to a site collection let me know. I would suggest to place a thread on Power Automate community and you can also mention me on there. This way either me (or somebody else on the forums can help you out with your issue).
    https://powerusers.microsoft.com/t5/Microsoft-Power-Automate/ct-p/MPACommunity

    The benefit of that forum is that have a bit more space to share a description of your issue and screenshots.

  6. Dennis says:

    Hi Oliver,

    I have looked into it, might be a new issue with the AddSiteDesignTaskToCurrentWeb method.

    Can you try the ApplySiteDesign method instead? Below is an example

    Url
    /_api/Microsoft.SharePoint.Utilities.WebTemplateExtensions.SiteScriptUtility.ApplySiteDesign

    Example Body payload
    {
    "siteDesignId": "9522236e-6802-4972-a10d-e98dc74b3344",
    "webUrl": "https://contoso.sharepoint.com/sites/sitename",
    "store": 1
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.