The discussion addresses how to upload and associate attachments with posts in Discourse using the API. hat_trick asks about uploading files like PDFs and images and linking them to posts, noting the absence of an ‘attachments’ field in the Post resource. SaraDev clarifies that attachments aren’t directly part of the Post API. Instead, files must first be uploaded via the /uploads.json endpoint to get a short_url, which is then included in the post’s raw content using Markdown syntax (e.g., [filename.pdf|attachment](upload://abcDEF123.pdf)). This can be done when creating or editing a post. References are provided to related topics for further details.
I did not find an Attachment parameter in the Post resource.
I thought about using the Upload resource and specifying type=“composer”. But I do not see a way to associate the Upload to a Post. Or, is this the wrong resource to upload Attachments?
There is no “attachments” field on the Post API directly. To attach an upload to a post you would need to:
Upload the file (get the short URL).
First upload your attachment using the /uploads.json endpoint:
Endpoint: POST /uploads.json
The response will contain a short_url like upload://abcDEF123.pdf.
Edit/create the post to include that short URL, so Discourse recognizes and links the upload to that post. To assign the uploaded attachment to a Post, you need to include the upload short URL in the post’s raw content using Markdown. For an attachment, you can use this format:
[filename.pdf|attachment](upload://abcDEF123.pdf)
Or for images:

This can be done when creating a post (using POST /posts.json ) or editing an existing post (using PUT /posts/{id}.json ), by putting the markdown link in the raw field.
For reference, there are also a couple existing topics about this process here: