Add Content Type to List using Rest API in SharePoint Online/2013/2016

This Rest API SharePoint tutorial explains, how to add a content type to list using Rest API in SharePoint Online Office 365. The same rest API code will also work in SharePoint 2013 as well as SharePoint 2016.

Add a content type to SharePoint List using Rest API

In this example let us take a button and on click on the button, we will add the reservation content type to a custom list which is there in the site. Both the HTML code and the rest API code let us put inside a script editor web part which is there inside a web part page in SharePoint.

HTML Code:

<input type="button" id="btnSubmit" value="Add Content Type to List" />
<div id="divResults"></div>

Rest API Code:

Here if you will look at the code, we are adding a content type id like below:
“contentTypeId”: “0x0102004F51EFDEA49C49668EF9C6744C8CF87D”

In this particular example, the ID is the id of a reservation content type. To get any content type id, you can go to the site settings -> then Site Content Type. Then you can click on any of the content type and from the browser, you can get the content type id. You will see like below:


Below is the full rest api code.

<script src=""></script>

$(function () {

function bindButtonClick() {
$("#btnSubmit").on("click", function () {

function addContentType() {
var siteUrl = _spPageContextInfo.webAbsoluteUrl;
var fullUrl = siteUrl + "/_api/web/lists/GetByTitle('MyCompanyInfo')/ContentTypes/AddAvailableContentType";
url: fullUrl,
type: "POST",
data: JSON.stringify({
"contentTypeId": "0x0102004F51EFDEA49C49668EF9C6744C8CF87D"
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
success: onQuerySucceeded,
error: onQueryFailed

function onQuerySucceeded() {
$("#divResults").html("Content Type Added Successfully to List !!!");

function onQueryFailed() {

Once you Save the web part page, you can see a button will appear and on button click, it will add the particular content type to the list which looks like below:

add content type to sharepoint list using rest api

Now if you will open the SharePoint Online list, you can see the content type like below:

add content type to sharepoint online list using rest api

You may like following SharePoint Rest API tutorials:

This SharePoint tutorial explains, how we to add an existing content type to a custom list in SharePoint Online using Rest API. We can also use the same code to add a content type to SharePoint list using Rest API in SharePoint 2013/2016.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

  • >