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: