Showing results for 
Search instead for 
Did you mean: 

Merge SharePoint documents using Microsoft Flow or Azure Logic Apps

In one of my previous blog post, I created a Flow to Merge Multiple documents into Single PDF. So the question may arise in your mind as to why am I writing another blog post on Merge? 


This post shows how to use the Muhimbi REST API and the Microsoft Flow HTTP action which will help you Merge all documents within a SharePoint Online document library to a single PDF. If the document is not already in PDF Format it will convert the file as part of the merging process.


The main reason for using the above approach is better performance, as we are going to send all the Merge files – by their URL – in a single HTTP request, rather than looping through the documents one at a time. An additional benefit is that this request only takes up a single Muhimbi Operation, so is a lot more economical, and it gets around the file size limitations in Flow.


A prerequisite is that both the source files and destination file will need to be located in SharePoint Online. Also, Muhimbi’s SharePoint Online App must be installed in the SharePoint Online Site Collection, AND be linked to the same subscription as the Muhimbi (Flow) subscription.



Before you begin, please make sure the following prerequisites are in place:

From a High level our Flow will look like:

Let’s have some fun and build a Flow!


Step 1:


  • For this demo, we will use “Recurrence” Flow Trigger and configure it to run once a day. Note: For testing purposes, I have used this trigger, but in real-world situations, any other SharePoint Online trigger can be used.


Step 2:


  • Add the SharePoint Online Get files (properties only) action and select 
    the path to the SharePoint Online folder.
  • This action will retrieve the list of files to merge

Using “Get files (properties only)” you can also filter down to the items that match a condition. For e.g. You can use ODATA orderBy query for specifying the order of entries or specify the total number of entries to retrieve. For more details see.


Step 3:


  • Initialize the variables with reference to the screenshot below:

Note: I have used this convoluted approach with 3 variables as – at the time of writing – Flow does not allow ‘self-referencing’ when setting the value of a variable. Please vote for this Flow Idea



Step 4:


  • Add the Apply to each loop and set it to the “value” field, output of the SharePoint Online Get files (properties only) action.


Note: Steps 5, 6 and 7 all need to be inserted inside the ‘Apply to each’ loop.


Step 5:


  • Set variable(Server relative URL).

We will build the path to the file to merge or URL of web page to convert. (e.g. /sites/Finance/Shared Documents/Some Folder/Some file.docx). 


  • To keep it simple let’s hardcode the first half of the file URL. /sites/<Site-collection-name>/
  • Use the “Folder path” variable output of the SharePoint Online Get files (properties only) action.
  • “File name with extension” output of the SharePoint Online Get files (properties only) action.

The Next variables ;true:”Name” are optional. They are used to create the Bookmark.


For more details see below:


  • Include bookmarks (‘true’ in the example above): The source file may already include PDF Bookmarks, or may be able to generate such bookmarks as part of the conversion process, e.g. an MS-Word file. Specify true to copy these bookmarks to the merged PDF file, or false to strip out any bookmarks. This value is optional
  • Bookmark name: The name of the PDF bookmark to use for the specified file. This is typically used to specify the file name, as we do in this demo, but you can specify any text such as the Title field of the SharePoint file.

Step 6:


  • In this Step, we will create the Merge String. i.e. on each loop it will concatenate the Temporary String with Server relative URL.
  • Set variables Merge String variable with reference to the screenshot below.


Step 7:


  • Set the variable Tempory Sting to Merge String with reference to the screenshot below.


Step 8:


  • Add the HTTP action outside the apply each loop.


Method: POST


URI: (Muhimbi Merge Endpoint)



  • API_key: Your Muhimbi API Key.
  • Content-Type: application/json.


  "fail_on_error": true,
  "use_async_pattern": true,
  "sharepoint_file": {
    "site_url": "",  
    "source_file_url": "@{variables('Merge String')}",
    "destination_file_url": "/sites/site-collection-name/Librarname/filename.pdf"
  "document_start_page": "Starts on the default page"

To better understand the JSON Body see Muhimbi Github Merge sample code.


Your Merge Flow is now ready. Thanks for reading…

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Blog site: MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: and twitter I also write at, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – Youtube channel -