How to insert an attachment programatically?

I’m working on a templater template, and would like the ability to request, as part of my template instantiation, a new attachment creation.
In my mind it sounds like a function that triggers the already-working obsidian attachment picker, and resolves with the vault path of the attachment, or rejects when cancelled.
Does something like that, or similar, exists? I could not find any mention to attachments in the typescript API.

Thanks in advanced