Create Site From Template using SharePoint 2013 Workflow

Create Site From Template using SharePoint 2013 Workflow

SharePoint sites are often created for new customers, projects, and events. While it is possible to create each new site manually, having an automated process greatly reduces user training and effort.

In previous versions of SharePoint, creating sites from a workflow required deploying custom actions. However, with the new Call HTTP Web Service action in SharePoint 2013, it is possible to apply some tricks and achieve the same result using only SharePoint Designer.

Creating a new site using only 2013 SharePoint Designer

Follow the tutorial below to deploy a “no-code” site creation workflow to your on-premise or SharePoint Online / Office 365 environment.

The steps look technical, but it is not necessary to understand all the details to make it work.

  1. Create a new SharePoint 2013 workflow. It is best to create this as a list workflow.

    For example, you could have the workflow create a new site every time a new customer is added to a customer list.
  1. Create the following string variables:
  • RequestURL – set this to the following: https://<parent_site_url>/_api/web/webinfos/add (replace <parent_site_url> with the URL where you want to create the subsite):
  • Title - the title of the new site. This could come from the list item.
  • Description – description of the new site.
  • SiteURL – URL stub of the new site. Your new site will be created at https://<parent_site_url>/<SiteUrl>/
  • SiteTemplate – GUID of the site template. To use the default team template, set this to 'sts'. To use a custom template, see the bottom of this post.

  1. Build the following dictionary variables: (using the Build Dictionary action).

There are four dictionaries, you should build them in in the order below.

Note that each entry within a dictionary is in the form of Name = Value.

You must set the correct 'Type' for each of these Name-Value pairs otherwise the action will not work.


Name Type Value
Accept String application/json;odata=verbose
Content-Type String application/json;odata=verbose


Name Type Value
Type String SP.WebInfoCreation

parameters (Screenshot for this one is below. Language 1033 is for English)

Name Type Value
__metadata Dictionary Variable: metadata
Url String Variable: SiteURL
Title String Variable: Title
Description String Variable: Description
Language Number 1033
WebTemplate String Variable: SiteTemplate
UseUniquePermissions Boolean False


Name Type Value
parameters Dictionary Variable: parameters

These dictionary definitions come from the SharePoint REST API.

See the end of this MSDN page which includes a similar example in JavaScript.

  1. Publish the Workflow and exit SharePoint Designer.
  1. Enable App Permissions by going to Site->Site Settings->Site Actions->Site Features.

    Find the feature "Workflows can use app permissions" and click Activate.

  1. Get the App Identifier. Goto the Site->Site Settings->App Permissions.

    Copy everything between the last | and the first @.

  1. Set App Permissions.

    Append /_layouts/15/appinv.aspx to your site URL to visit the hidden App Permissions page.

    Enter the App ID from above and click lookup.

    Then, enter the following permission Request XML.

    Click Create, and when prompted, Trust It.

    This will give your workflow full control over the entire site collection.

<AppPermissionRequests><AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="FullControl"/></AppPermissionRequests>

  1. Create an App Step.

    Re-open the workflow in SharePoint designer and you should see that "App Step" is now available.

    Add an App Step at the end of the workflow.

  1. Add the Call HTTP Web Service Action within the App Step.

    Right-click on the action and set the properties as shown below.

    Create the new variable ResponseContent.

  1. Publish the workflow a final time.

    Run your workflow and your site should be created at the URL you defined above.

    Once you've successfully tested it, you can modify the rest of the workflow to include the correct title, add approval tasks, etc.

Finding the SiteTemplate GUID

The quickest way to get the GUID of a site template is to start creating a new site. When prompted to select the template open the “Custom” tab so that your template is shown. Press F12 in IE to open the developer bar and search for the template name.

You want the option value that looks like {84659096-89AD-4CC4-B1E2-5048DE9EDA46}#ProjectSiteTemplate.


If you have trouble making the HTTP call work, I recommend the following troubleshooting tactics:

  1. Log the RequestURL immediately before you make the HTTP request.
  1. Log the ResponseCode immediately after the HTTP request.
  1. Email yourself the ReponseContent. (Note: you must email it to yourself, as the ResponseContent is usually too long for the workflow history list).

Learn more about DMC's SharePoint Workflow services.

Contact Us for help on implementing your own workflow processes with SharePoint. 


# Carloz
For anyone struggling with the {"error":{"code":"-2146232832, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"\"https:\/\/ contains invalid character ':'."}}}

It most likely is coming from the siteURL.

The siteURL does not need to be a URL it just needs to be the subsite URL ender name.

For example I should set my siteURL to "awesome"

Hope that makes sense.

Jason Robesyn
# Jason Robesyn
First of all great tutorial it works great when i use the workflow on site collection level.
Sadly it won't work if i use the exact same workflow on a subsite. I really need to use this workflow on a subsite so that i can create a subsite for each project.
I've been struggling with this for days now but i can't seem to find a solution.
Somebody got some advice on how this could be rersolved?
Dan Gibson
# Dan Gibson
I've had this running for a while now without issue, but i've just started getting the following error. Can anyone help? Can't work it out. i know i've not removed any author column. I'm thinking it might be some wider change to SharePoint. So far i've tracked the issue down to this.

Response Content {"odata.error":{"code":"-2147024809, System.ArgumentException","message":{"lang":"en-US","value":"Column 'Authors' does not exist. It may have been deleted by another user. https:\/\/\/sites\/NC\/clients\/dgtest321 "}}}
# Rob
Hi David, tnx fot the solution it works great.
I want to create unique permissions on the site that I create.
I set the UseUniquePermissions on true, but how can I add/create groups for the site?
I am looking forward for youre answer.

With kind regards Rob
Gayatri Rajput
# Gayatri Rajput

When I try to create new subsite using REST there are Response Code was BadRequest And Not created new subsite in sitecollection
How to fixed this issue?

Jordan Homsy-Harris
# Jordan Homsy-Harris
Hey TomC and Juan,

TomC, your issue is indeed caused caused by not using two underscores in the front of the metadata parameter. You need to use "__metadata" not "_metadata" when constructing the dictionary.

As for yours, Juan, it could come from any number of issues. I would probably start by reinstalling the Spanish language pack and seeing where it installs (following MSDN should help with that: It could also be that the ID for Spanish is not 1034 on your sever. In WSS it was 1034 ( but in O365 it is 3082 (, so you should identify where your language files for es-es are located.
# Juan
Hi TomC,

i have a different error but maybe yours is because you have put 1 _metada when actually there a 2 __metadata etc etc.

I have the error below. Im trying to create a custom sub-site in spanish instead of use 1033 (US-EN) i choose 1034 which is the code for spanish but when the wf finish i get this error:

{"error":{"code":"-2130575266, Microsoft.SharePoint.SPException","message":{"lang":"es-ES","value":"No se admite el idioma en el servidor."}}} No se admite el idioma en el servidor = the language is not admitted by the server

# TomC
Hello all,

I know this post is a few years old but I'm hoping someone sees this!
I'm having trouble with the same error a few people seem to be having with the _metadata issue. See error details below.

The property '_metadata' does not exist on type 'SP.WebInfoCreationInformation'. Make sure to only use property names that are defined by the type."

Here is my request that is being sent


I was wondering if someone who has got it working could reply with their request data like mine above so I could compare it?
Or if anyone can see something wrong to let me know.

Thanks in advance!
# Jarle
Thanks for a nice tutorial

Is there a way to sett the subsite to inherret links in top bar and side bar?
# Nancy
I'm also getting this, which seems not to make any sense...

Response Code: InternalServerError
Response Content: {"error":{"code":"-2146232832, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"\"https:\/\/\/site\/NewSite\" contains invalid character ':'."}}}

Is the colon in the http:// not supposed to be there for some reason?
# Nancy
As someone else indicated above, I get the same error:

<?xml version="1.0" encoding="utf-8" ?>
- <m:error xmlns:m="">
<m:code>-1, Microsoft.SharePoint.Client.ClientServiceException</m:code>
<m:message xml:lang="en-US">The HTTP method 'GET' cannot be used to access the resource 'Add'. The operation type of the resource is specified as 'Default'. Please use correct HTTP method to invoke the resource.</m:message>

Any insight on why this is?

(Thank you SO much for this post- I am really hoping I can get it to work!!)
# Jürgen
Hi I have problems to create the APP Step,
I activated the WorkflowAppPermission feature, this worked

But when i try to create the Set App Permissions. Append /_layouts/15/appinv.aspx i dont know this is right.

Here my example:
<AppPermissionRequests><AppPermissionRequest Scope="" Right="FullControl"/></AppPermissionRequests>

I created the app permissions and trust it.

But when i open the designer and open the workflow, the app step ist deactivated.

I thinke in the app permissions is my fault, can sombody help me.
Thanks a lot
# Anshu
My workflow is generated from VS 2012 and it cannot be opened from SPD. Is there a way to add a "App step" in VS.
# Ray
I receive the following error:

{"error":{"code":"-2147024713, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"The Web site address \"\/sites\/sitecollection\/projects\/demosite\" is already in use."}}}

That site does not exist under the project site I want to create it under (do not understand why I keep getting this error) - I have even tried putting different characters and numbers for the siteurl.
# waqas
__metadata Dictionary Variable: metadata problem solved
do not copy "Variable: metadata" use fx to find workflowvarible metadata
# Alex
Hello, i am using Sharepoint 2013 Online and I have used this description to create a workflow for creating Project subwebsites dinamically. Everything works fine but after a week, the creation of the subwebsite crashes with the RespondCode "BadRequest" and the RespondContent:

"{"error":{"code":"-1, Microsoft.Data.OData.ODataException","message":{"lang":"de-DE","value":"Ein Typ mit dem Namen \"SP.WebInfoCreation\" konnte vom Modell nicht aufgelöst werden. Wenn ein Modell verfügbar ist, muss jeder Typname in einen gültigen Typ aufgelöst werden können."}}}

(german language)

The comment of Adam D. ( helped me to fix this issue by removing the entry "__metadata" with the value "SP.WebInfoCreation" from the Parameter dictionary. I don't know why everything works fine now, especially not it works befor.

Thank you
# Mary
Hi All - I have the same problem as TomH above. When I save the last two dictionaries which include dictionary variables - SP does not save the variables in that dictionary. (It seems that I cannot save dictionaries that have dictionary variables).
A resolution for this would be appreciated.
Excellent article and it works perfectly and have to follow the steps perfectly.

Now my requirement is to have the unique permission on new site and add the user to Site Owner in new site. please let me know if possible and how to achieve it. Thanks.
# Daws
Hi All,
Try to use the lookup to get the variables, this way it will save the build dictionary. Hope this helps.
# #TomH
Hi folks,
I have a similar problem to some folks have mentioned earlier. I cannot save the last 2 dictionaries. I enter the data as indicated above and the Build Dictionary command will not save them, I have attempted this many times with the same result. I thought it might be a Sharepoint Designer problem so I created a random dictionary and it saved ok. Does anyone have a solution for this?

Adam D
Hi again,

I think I can provide another fix here for everybody - as I was implementing this the third time I came across error code: -1. (See error output at bottom).

The issue occurs when one of the data types in your dictionaries is incorrect. In my workflow, when I added the "parameters" dictionary in "requestDictionary", I set it to a String type rather than a Dictionary type. So to resolve the problem, just ensure your data type is correct on every single Dictionary key/value pair. Take special care to make sure the dictionaries you reference are set to the "dictionary" type and NOT String.

The error is:

{"error":{"code":"-1, Microsoft.Data.OData.ODataException","message":{"lang":"en-US","value":"An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartObject' node was expected."}}}

Hope that helps, Adam.
Adam D
Great writeup - I had the old "__metadata" not existing issue (Sharepoint Online).

I simply removed __metadata from the request dictionary. Works. Seen no problems yet.

Will update this comment if an issue occurs.

The error reads like this:

"{"odata.error":{"code":"-1, Microsoft.Data.OData.ODataException","message":{"lang":"en-US","value":"The property '__metadata' does not exist on type 'SP.WebInfoCreationInformation'. Make sure to only use property names that are defined by the type."}}}"
I get log on mail:
Unauthorized on Log for the ResponseCode,
app permissions seems good..
how can I check additionally on SharePoint online
# Somen
I am unable to get rid of this error,

<?xml version="1.0" encoding="utf-8" ?>
- <m:error xmlns:m="">
<m:code>-1, Microsoft.SharePoint.Client.ClientServiceException</m:code>
<m:message xml:lang="en-US">The HTTP method 'GET' cannot be used to access the resource 'Add'. The operation type of the resource is specified as 'Default'. Please use correct HTTP method to invoke the resource.</m:message>

I checked multiple time and found that I am using the correct HTTP matched the same with your post.

Can you please help?
# Jeremy
I know this has been posted a few times but cant seem to find a solution anywhere for it.

When entering metadata in the parameters it wont work it 1 _ or 2 __. Does anyone have a solution for this?

# LogicalJester
I configured this workflow on an existing sharepoint site collection and it worked like a dream.

I then decided my project needed to be in its own site collection so deleted everything and started again.

On the second attempt I was getting "BadRequest" response code when creating the site.

After carefully checking all the settings I eventually noticed that it was a double underscore before metadata in the parameters dictionary...
# Prashanth
Do i need to be site collection admin to perform this step as i noticed next time i open up doesnt show the tags.

Set App Permissions. Append /_layouts/15/appinv.aspx
and i am having https;//sitecollections/sites/

# Albert

We are using SharePoint Online and use a custom list for site requests. A user creates an item where he provides the name of a site, a description and the URL. The workflow then starts and it should create a sub site using a custom template.

I followed all the steps and the workflow completes without errors in SharePoint but it doesn't create the sub site.

I added a step in the workflow to e-mail me the responsecontent and this is the error that I am getting:

responsecontent: {"error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-EN","value":"Access denied. You are not authorized to perform this action or access this resource."}}}

I've been trying to solve this for days with the help of some colleagues and we cannot figure out where we don't have access as we are global admins in our SharePoint tenant.

Could you please help me out here? Do you think that this could be an issue with the permissions that the app gets and that it uses some kin of generic/system account that has not sufficient permissions to perform the workflow?

Any help is more than welcome.

Thanks for your time!


# R
When I try to set
Name Type Value
parameters Dictionary parameters

it never saves it. when i reopen it shows blank and contents are not there no matter how many time i type it in.
can anyone tell where the problem is.

# Ben
Can we set unique permissions boolean to true, and have the workflow set specific site permissions? Thanks!
# Jozef

I know this is old post, just would like to know if anyone knows the solution for variable "__metadata" that is not saved while building dictionary

Thank You
# Nestor
I got this message {"odata.error":{"code":"-1, Microsoft.Data.OData.ODataException","message":{"lang":"es-ES","value":"La propiedad '__metadata' no existe en el tipo 'SP.WebInfoCreationInformation'. Asegúrese de que solo usa nombres de propiedad que se definen por el tipo."}}}
# Rich
I've run through the instructions twice and get the same error. I had it email me the Response Content URL and Header. Below is what I get:

Response Content: {"error":{"code":"-1, Microsoft.Data.OData.ODataException","message":{"lang":"en-US","value":"An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartObject' node was expected."}}}

Request URL: http://sssence.sharepoint.local/wgp/itprojectlibrary/_api/web/webinfos/add

Request Header: {"Accept":"application\/json;odata=verbose","Content-Type":"application\/json;odata=verbose"}

The thing I notice is in the Request header it's putting "application\/json;odata=verbose" when in the workflow I'm putting "application/json;odata=verbose" per the instructions. The workflow is putting in an extra "\" even though it's not in the string I'm putting in.

Any help would be appreciated!

# Peter
I have the same error like Mike, any suggestions?

{"error":{"code":"-1, Microsoft.Data.OData.ODataException","message":{"lang":"en-US","value":"An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartObject' node was expected."}}}

Thanks a lot.
# Fredrik
Awesome post, very well explained - works like a charm! Thank you
Tracie Jones
# Tracie Jones
Hi There
I am also getting the ResponseContent error like Neal Hicks,
{"error":{"code":"-1, Microsoft.SharePoint.Client.UnknownError","message":{"lang":"en-US","value":"Unknown Error"}}}
Does anyone have a solution please?
Terry Smith
# Terry Smith
Excellent post thanks.

When setting up the HTTP web service call at step 9, click on Advanced Properties to set the requestHeaders.
Rajapalagiri U
# Rajapalagiri U
Hi ,
Thanks for the post, I need to implement the same for multiple site collections, I tried using by accessing other site collections by https://../_api/contextinfo/ and able to get the form digest value(X-Request value), but unable to pass that to https://_api/web/webinfos/add.
Please share if you have any ideas on this.

Ned Scheetz
# Ned Scheetz
For some odd reason, I can not get the dictionary to accept the __metadata value. It will accept all other definitions, but just deletes the __metadata definition. I am using 2 underscores (have tried 1 as well) but it won't accept.
Torben Johansen
# Torben Johansen
Thank you for a great post. Just a few hints to others:

1. If you are using a different language than English, remember to set the language correctly. ie. 1030 for Danish instead of 1033 for English

2. If you get strange internal errors - it might be your site template contains Spaces. ie. If you have saved your site as a template called "My Template" you should instead save it Again as "MyTemplate". Your WebTemplate value will then look like "{352471C7-5C8B-4E15-B1FF-FBF5F106EDE5}#MyTemplate" without any Spaces or special characters.

Oh, and by the way: Your site will always use its own navigation. You will need to go into Site Settings and manually inherit the top link bar if this is what you need. You can add a "Send email" with a link directly to the Navigation settings page to remind your user to do this - but unfortunately the web service does not support setting this.
# IK
Thanks for description, I followed all the steps and my workflow successfully created Site!
Neal Hicks
# Neal Hicks
Hello everyone!

First, I want to thank the poster for taking the time to upload such a detailed write up of the whole process. I also want to thank everyone in advance for their time and support with the issue I am running into.

So I have done everything detailed up above, but for some reason the site is not getting provisioned.

I have had the specifics of each parameter/variable emailed to me, and it looks like this:

responseContent: {"error":{"code":"-1, Microsoft.SharePoint.Client.UnknownError","message":{"lang":"en-US","value":"Unknown Error"}}}
metadata: {"Type":"SP.WebInfoCreation"}
requestDictionary: {"parameters":null}
requestHeaders: {"Accept":"application\/json;odata=verbose","Content-Type":"application\/json;odata=verbose"}
ResponseCode: InternalServerError
SiteTemplate: sts
SiteURL: testsite
Title: Test Site

I am trying to figure out what is going wrong. It seems that the parameters variable is somehow null?
Does anyone have any ideas as to what is going wrong here?

Thank you once again for your help!
# Raj
Can we use it for creating a Site Collection via workflow. Can you give your thoughts on this requirement please.
# Django
Really like this understandable solution with a very nice hands-on explanation.

My question is about the parameters part: where (how) can I fand the additional parameters?
You are using Url / Title up until UseUniquePermissions but how about the Global Navigation Inheritance?
# Lisa
Are there any changes required to get this to work in SP Online using a site collection other than the base site collection? I'm using the base site in the request header, then using "sites//" to the SiteURL. The workflow seems to be getting stuck in the API call, so I haven't been able to get the response for troubleshooting.
# Will
This is brilliant.

Thank you for sharing!
# Mike
Thanks for your post - would be quite useful for me if I get it working. I've emailed myself the responseContent and got this message: {"error":{"code":"-1, Microsoft.Data.OData.ODataException","message":{"lang":"en-US","value":"An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartObject' node was expected."}}}

apparently a value isn't correct. I strongly assume it has something to do with the requestHeaders variable as it says something else is expected. Do you think you could help here? Would appreciate that.
Tasneem Nomani
# Tasneem Nomani
Can we create incoming email for the document library in the site template?

Since sites will be different, each site library should have different email address.
Can we do this in designer workflow?
G'day there, thanks for the great post, it is working great. Do you know of any way to give the creator of the list item FULL Control Permissions of the site that gets created?


Alex Dean
Pure genius. all a bit cumbersome and rather "hardcore" approach, but it works, uses SharePoint best practices and the sharepoint API and is very fast.

One thing to note... if you're planning on dynamically creating the site url based on some user input, then setting the field in the list to Enforce Unique Values will help.
Don't even try to do that on the Title field. You can not enforce any site column to be unique. only columns defined directly on the list.
# Remco
Hello David,

Thx for the blog.
Now the site is created, but now I want to add some users to the groups.

I have tried it with a similar workflow with the following :
url = /_api/web/sitegroups(8)/users
parameter "LoginName" = i:0#.f|membership|
but i get the error "NotAcceptable"

Can you help me on this one?

Thx. Remco
Ed Dumas
# Ed Dumas
Excellent post. Thanks.

One note of clarification for other readers - the "__metadata" variable is preceded by 2 underscore characters.
# David
Hi Rene,

Step 10 mentions that you should create the new variable responseContent. It does not need to be filled prior to the HTTP call. Designer should also prompt you to create the (dictionary) variable when you are adding the step.

We are not using the ResponseHeaders field in this workflow, so you can leave it blank as shown in the screenshot or create a dummy variable.

Let me know if you have any other questions!
Rene Alvarez
# Rene Alvarez

I'm trying to reproduce your solution, however in the 10th step you are using a "responseContent" variable that does not exists.
Also, I'm assuming that "requestHeaders" should not be used in "ResponseHeaders".


Post a comment

Name (required)

Email (required)

Enter the code shown above:

Related Blog Posts