Clone private file into a new blank file

Question, not sure if possible and struggling with this:

Having an internal company file, say a “template” file…is it possible (via a private plugin) to copy/clone etc the “template” file structure into a new empty file? (pages + pages contents, instances…everything).

My approach to this (without any coding yet) would be to call the Figma API with the “template” file ID, and, from the JSON response, try to (clone?) each page.

I have tried calling the API like that and the “template” file response from API comes as page nodes marked with type “CANVAS” instead of “PAGE” as I would expect.

How to proceed from here?, if possible.