You can only do a synchronous upload as a staff user, see Image upload with synchronous true for new users for details.
Some more information
if you want the url back, you will have to listen to the “/uploads/*” channels via the Message Bus.
https://meta.discourse.org/t/using-the-discourse-api-to-post-with-uploaded-files/29833/11