I managed to impelment the "create document from template" using the example you provide on the documentation.
This gave me an URL that let me download the created document.
For my project, I need the document in PDF, so my next step is to convert it to PDF.
I tried to follow the same path for document creation but I receive a ERR_BAD_REQUEST
Could you if it works if you use only the second action in the code with a ready docx source file?
Probably there is something with the input in the second action.
I made some tests and I all worked Ok. At the end I noticed that I had a mistake on the FormData on the second call. I also managed to pass the first call URL response directly to the second call and it worked correctly.
Here is my final code with the "correction" highlighted in yellow.