How to upload a file via API and get it's URL?

Also interested in this question
I can’t find a way to upload a file to Topic and Post via the API.
Perhaps someone can suggest a method.

UPD:
I figured it out, the method is described in the documentation and it works.

  1. Upload a file using “/uploads.json”, in response we get the Short URL of the uploaded file like “upload://ueNyWDEgHhXIuIdB472fy9T6.txt”
  2. We update the post with the second API request, adding a line like this to the very end of post[raw]:
    [filename.txt|attachment](upload://ueNyWlEgHhXIuIdB472fy9T6.txt) (1.83 KB)
6 Likes