Mendix Support Engineer @Saurabh Hirve helped me.
It is possible to create documents in the right folder by passing the folder to the createIn method of the document type, e.g.:
const folder = model.allFolders().find(f => f.name === "TargetFolderName");
const nanoflow = microflows.Nanoflow.createIn(folder);
It works well in my project.