# Is there REST resource for uploading and assigning Attachments to Posts?

**URL:** https://meta.discourse.org/t/is-there-rest-resource-for-uploading-and-assigning-attachments-to-posts/360953
**Category:** Support
**Created:** [April 8, 2025, 7:23pm UTC](https://meta.discourse.org/t/is-there-rest-resource-for-uploading-and-assigning-attachments-to-posts/360953 "2025-04-08T19:23:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![hat\_trick](https://avatars.discourse-cdn.com/v4/letter/h/898d66/32.png) [@hat\_trick](https://meta.discourse.org/u/hat_trick)
#### Post date: [April 8, 2025, 7:23pm UTC](https://meta.discourse.org/t/is-there-rest-resource-for-uploading-and-assigning-attachments-to-posts/360953/1 "2025-04-08T19:23:49Z")

</div>

Hi,

1. My attachments are pdf, images, etc.

2. I did not find an Attachment parameter in the Post resource.

3. 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?

TIA.

---

<div class="post-metadata">

### Author: ![SaraDev](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saradev/32/335139_2.png) [@SaraDev](https://meta.discourse.org/u/SaraDev)
#### Post date: [May 5, 2025, 10:12pm UTC](https://meta.discourse.org/t/is-there-rest-resource-for-uploading-and-assigning-attachments-to-posts/360953/3 "2025-05-05T22:12:03Z")

</div>

There is no “attachments” field on the Post API directly. To attach an upload to a post you would need to:

1. 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`.

1. 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:

```markdown
[filename.pdf|attachment](upload://abcDEF123.pdf)

```

Or for images:

```markdown
![alt text](upload://abcDEF123.png)

```

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:

- [How to upload a file via API and get it’s URL?](https://meta.discourse.org/t/how-to-upload-a-file-via-api-and-get-its-url/123732)
- [How to associate a new upload with a previous post via the API](https://meta.discourse.org/t/how-to-associate-a-new-upload-with-a-previous-post-via-the-api/70369)

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [June 4, 2025, 10:12pm UTC](https://meta.discourse.org/t/is-there-rest-resource-for-uploading-and-assigning-attachments-to-posts/360953/4 "2025-06-04T22:12:39Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
