Create SharePoint sub site using Rest API

In this article you are able to see how to create sub site using Rest API.
We created a custom page and designed UI as per the below, Add this code in the script editor web part.
Create SharePoint Sub site using Client object model

<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
$(document).ready(function () {
 function bindButtonClick() {  
            $("#register").on("click", function() {  
                var name = $("#txtSiteTitle").val();  
                var id = $("#txtSiteDescription").val();  
                var URL = $("#txtSiteURL").val();
                if (name == '' || id == '' || URL == '') {  
                    alert("Please fill all fields...!!!!!!");  
                } else {  
function createSite()
      var siteTitle = $("#txtSiteTitle").val();  
            var siteDesc = $("#txtSiteDescription").val();  
            var siteUrl =  $("#txtSiteURL").val();
   url: "",
   type: "POST",
   headers: {
    "accept": "application/json;odata=verbose",
    "content-type": "application/json;odata=verbose",
    "X-RequestDigest": $("#__REQUESTDIGEST").val()
   data: JSON.stringify({
    'parameters': {
     '__metadata': {
      'type': 'SP.WebInfoCreationInformation'
     'Url': siteUrl ,
     'Title': siteTitle ,
     'Description': siteDesc ,
     'Language': 1033,
     'WebTemplate': 'sts',
     'UseUniquePermissions': false


    <div class="container">  
        <div class="main">  
            <form class="form" method="post" action="#">  
                <h2>Create Client sub Site</h2>
                 <label>Client Site Name :</label> <input type="text" name="dname" id="txtSiteTitle"> 
                 <label>Client Site Description:</label> <input type="text" name="demail" id="txtSiteDescription"> 
                 <label>Client Site URL: </label> <input type="text" name="durl" id="txtSiteURL">
                 <input type="button" name="register" id="register" value="Submit"> </form>  


Lakshmi Tulasi Jasti

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment


  1. Great article. When I try to execute I get an access denied error when creating the subsite. Any suggestions? I use SharePoint online as an site collection owner.
    Thanks, Mike