The Best Way to Create Content Type in SharePoint Using Power Automate

I recently worked with a client who needed to organize their SharePoint library better. They wanted to group documents by specific types, like contracts, invoices, and reports, each with its own set of metadata. Instead of creating separate libraries for each type, we used content types.

In this tutorial, I will tell you how to create content types in SharePoint using Power Automate. Additionally, we will discuss how to add a site column to a content type by using REST API calls and how to delete a content type from SharePoint using Power Automate.

Create Content Type in SharePoint Using Power Automate

Now, follow the steps below to create a content type in SharePoint using Power Automate.

I will create a site content type named ‘Project Document. Additionally, we will create a new group or category named ‘Project Management Group’ using a Power Automate REST API call.

1. In Power Automate, click the Instant Cloud flow, enter the Flow name, and choose the trigger flow (i.e., manually trigger a flow).

Power Automate sharepoint content types

2. Then add a Send an HTTP request to SharePoint action from sharePoint Connector with the below parameter:

  • Site Address: Select the SharePoint site address for creating the Content Type
  • Method: Select “POST” as the method
  • URI: Provide the below URI:
_api/web/contenttypes
  • Header: Use the headers below to make REST API calls to SharePoint:
Accept: application/json;odata=verbose
Content-Type: application/json;odata=verbose
  • Body:  Provide the below JSON format:
{
  "__metadata": {
    "type": "SP.ContentType"
  },
  "Name": "Project Document",
  "Group": "Project Management Group",
  "Description": "A custom content type for project-related documents."
  }
}
how to create content type in sharepoint using Power Automate

Now, save the flow and run it. Once the flow runs successfully, click Site Settings -> under Web Designer Galleries and click Site Content Types. You will see the ‘Project Document’ site content type.

How to Create Content Type in SharePoint in Power Automate

Add Site Columns to SharePoint Content type using Power Automate

I will show you how to add a site column to a SharePoint content type using Power Automate.

Before I explain the steps, make sure you have a content type and site column. For this example, I am using the content type mentioned above and the site column listed below:

add Site Columns to SharePoint Content type using Power Automate

Now follow the below steps:

1. Create a new instant cloud flow that will manually trigger, then add a compose action to store the Content type ID. Check the screenshot below to get the Content type ID:

power automate content type

Copy the content type put in compose action input parameters:

how to create content type in sharepoint

2. Add the Initialize variable action to store the Site Column Name. In my case, the site column name is Customer ID:

sharepoint add to all content types using Power Automate

3. Add Send an HTTP request to SharePoint action to get the site column, then provide the below parameters:

  • Site Address: Select the SharePoint site address
  • Method: Select “Get” as the method
  • URI: Provide the below URI:
_api/web/fields/GetByInternalNameOrTitle('@{variables('varSiteColumnInternalName')}')
add Site Columns to SharePoint Content type in Power Automate

4. Then add compose action to store site column ID using the below expression:

body('Send_an_HTTP_request_to_SharePoint')?['d']?['id']
How to add Site columns to Share Point content type using Microsoft Power Automate

5. Add Send an HTTP request to SharePoint action to get the site ID, then provide the below parameters:

  • Site Address: Select the SharePoint site address
  • Method: Select “Get” as the method
  • URI: Provide the below URI:
_api/site?$select=Id
  • Headers: Provide the headers required to do the Rest API calls.
  Accept: application/json;odata=verbose
Add Site columns to site content type in SharePoint site using Ms Power Automate

6. Add compose action to store the site ID using the below expression:

body('Send_an_HTTP_request_to_SharePoint__')?['d']?['id']
Add Site columns to site content type in SharePoint site using Microsoft flow

7. Again, add Send an HTTP request to SharePoint action to add a site column in content type, then provide the below parameters:

  • Site Address: Select the SharePoint site address
  • Method: Select “POST” as the method
  • URI: Provide the below URI:
/_api/v2.1/sites/@{outputs('Compose_|_Site_ID')}/contentTypes/@{outputs('Compose_|_Content_type_ID')}/columns/add
  • Headers: Provide the headers like below, as it is required for the Rest API calls:
Accept: application/json;odata=verbose
Content-Type: application/json;odata=verbose
  • Body:  Provide the below JSON format:
{
"value":[
{
"id":"@{outputs('Compose_|_Site_Column_ID')}",
"pushDownChanges":true
}
]
}
Add Site columns to site content type in SharePoint site using flow

Save and run the flow to check if the site column gets added to the content type.

Add Site columns to site content type in SharePoint Online using Power automate flow

Delete Site Content Type From SharePoint Using Power Automate

To delete a SharePoint Content Type using Power Automate, we can use the Send an HTTP request to SharePoint action to call the REST API.

Create an Instant cloud flow and choose a trigger, such as ‘Manually trigger a flow.’ Then, add the ‘Send an HTTP request to SharePoint’ action and provide the following parameters:

  • Site Address: Select the SharePoint site Address.
  • Method: DELETE
  • Uri:
/_api/web/contenttypes('<ContentTypeID>')
  • Headers: Provide the headers like below, as it is required for the Rest API calls:
Accept: application/json;odata=verbose
Content-Type: application/json;odata=verbose
Delete Site Content Type From SharePoint using Power Automate

Save and test the flow. Once it runs, it will delete the specified content type from your SharePoint site.

How to Delete Site Content Type From SharePoint using Power Automate

Conclusion

In this tutorial, I covered how to create a content type in SharePoint using Power Automate, including creating a custom content type and grouping it under a specific category. I also explained how to add a site column to a content type using REST API calls and how to delete a content type from SharePoint.

You may also like:

  • >

    Build a High-Performance Project Management Site in SharePoint Online

    User registration Power Apps canvas app

    DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

    Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

    Power Platform Tutorial FREE PDF Download

    FREE Power Platform Tutorial PDF

    Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…