Duplicate project using API


I am trying to automate the creation of projects using a script.

However, I am struggling to setup custom roles and some automatic tasks using the API.

Is there a way to duplicate a pre existing project using the API? This would make my life much easier.

For what I have read there is no default way of doing so. I’m new to php so some of the code is beyond me. If I could get at least some pointers in how to enable/create an api function that did this I would be grateful.