# How can I upload file to a ticket using API.

**URL:** <https://community.hubspot.com/t/how-can-i-upload-file-to-a-ticket-using-api/17113>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [November 8, 2019, 7:42am UTC](https://community.hubspot.com/t/how-can-i-upload-file-to-a-ticket-using-api/17113 "2019-11-08T07:42:36Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jackcoldrick](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jackcoldrick/32/5119_2.png) [@jackcoldrick](https://community.hubspot.com/u/jackcoldrick)\
**Post date:** [November 8, 2019, 12:09pm UTC](https://community.hubspot.com/t/how-can-i-upload-file-to-a-ticket-using-api/17113/2 "2019-11-08T12:09:13Z")

</div>

Hi [@kundan\_ziplyne](https://community.hubspot.com/t5/user/viewprofilepage/user-id/110047),

To associate a file with a ticket or any object for that matter you would need to do the following:

1) Upload a file to the file manager using the “[upload a new file](https://developers.hubspot.com/docs/methods/files/post_files)” endpoint. This will return a response containing meta data for the file. The most important of which is the “id” of the file. We need to use that in the next step.

2) Create an engagement using the “[create an engagement](https://developers.hubspot.com/docs/methods/engagements/create_engagement)” endpoint and use the file ID returned previously in the “associations” array in your request. This will result in a file being associated to the specific object. Below is an example of the payload:

```auto
{
 "engagement": {
 "active": true,
 "ownerId": 1,
 "type": "NOTE", 
 "timestamp": 1409172644778
 },
 "associations": {
 "contactIds": [],
 "companyIds": [],
 "dealIds": [],
 "ownerIds": [],
 "ticketIds": [28164303] <-- ID OF THE OBJECT IN HUBSPOT
 },
 "attachments": [
 {
 "id": 4964093251 <-- ID OF THE FILE IN HUBSPOT
 }
 ],
 "metadata": {
 "body": ""
 }
}

```

I hope this helps!

---

_[View the full topic](https://community.hubspot.com/t/how-can-i-upload-file-to-a-ticket-using-api/17113)._
