# Attaching Files to a Custom Object

**URL:** <https://community.hubspot.com/t/attaching-files-to-a-custom-object/92500>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [October 24, 2023, 6:49pm UTC](https://community.hubspot.com/t/attaching-files-to-a-custom-object/92500 "2023-10-24T18:49:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ABollinger](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/abollinger/32/76566_2.png) [@ABollinger](https://community.hubspot.com/u/ABollinger)\
**Post date:** [October 24, 2023, 6:49pm UTC](https://community.hubspot.com/t/attaching-files-to-a-custom-object/92500/1 "2023-10-24T18:49:32Z")

</div>

Attaching files to custom objects seamlessly integrates documentation within your data flow, ensuring relevant information is just a click away. In this comprehensive guide, we’ll unveil the step-by-step process to efficiently attach files to a custom object in HubSpot.

## Step 1: Get the Associated Id

**API Documentation** : [CRM Associations](https://developers.hubspot.com/docs/api/crm/associations)

**API Method** : GET

`https://api.hubapi.com/crm/v4/associations/{fromObjectType}/{toObjectType}/labels `

For our purpose, we want to associate NOTES to a CUSTOM OBJECT ID:

`https://api.hubapi.com/crm/v4/associations/notes/{custom_object_id}/labels`

Expected Response

`{"results": [{"category": "USER_DEFINED","typeId": 999, "label": null}]}`

Save the **typeId** value from the response. We’ll need it for later steps.

## Step 2: Upload the File

**API Documentation** : [Files API](https://developers.hubspot.com/docs/api/files/files)

**API Method** : POST

`https://api.hubapi.com/files/v3/files `

While making the POST request, ensure you attach a file using the file key. Additionally, specify the folderId (can be any value) and provide any options as a JSON object.

Upon successfully posting the file, you should receive a 201 response containing a JSON object. Extract the **id** value from this object as we’ll be using it in the next step.

## Step 3: Create a Note

Files are integrated into HubSpot via notes. Thus, creating a note is essential for our goal.

**API Documentation** : [CRM Notes](https://developers.hubspot.com/docs/api/crm/notes)

**API Method** : POST

`https://api.hubspot.com/crm/v3/objects/notes `

Send the following raw JSON in the body:

`{"properties":{"hs_timestamp": "{put_timestamp_here}","hubspot_owner_id":"{put_owner_id_here}","hs_attachment_ids":"{use the id from Step 2}","hs_note_body":"This is a test note and can be anything"}}`

On successful execution, you’ll get a 201 response with a JSON object. Keep the id from this object handy for the next step.

## Step 4: Associate the Note to the Record

Finally, we need to associate the note we created with the actual record in HubSpot.

**API Documentation** : [CRM Notes](https://developers.hubspot.com/docs/api/crm/notes)

**API Method** : PUT

`https://api.hubspot.com/crm/v3/objects/notes/{{note_id_from_step3}/associations/{custom_object_id}/{the_id_of_the_specific_record}/{typeId_from_step1} `

If everything worked correctly, you should receive a 200 OK response, confirming that the file has been successfully attached to the custom object in HubSpot.

By following these steps, you can efficiently integrate and attach files to any custom object in HubSpot using the platform’s v3 APIs. Happy integrating!

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [October 24, 2023, 9:31pm UTC](https://community.hubspot.com/t/attaching-files-to-a-custom-object/92500/2 "2023-10-24T21:31:19Z")

</div>

Hi, @ABollinger 👋 Thank you very much for taking the time to put this together! — Jaycee

---

<div class="post-metadata">

**Author:** ![ABollinger](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/abollinger/32/76566_2.png) [@ABollinger](https://community.hubspot.com/u/ABollinger)\
**Post date:** [October 24, 2023, 10:55pm UTC](https://community.hubspot.com/t/attaching-files-to-a-custom-object/92500/3 "2023-10-24T22:55:31Z")

</div>

Very happy to help! We spent a few hours getting it working.

---

<div class="post-metadata">

**Author:** ![MKaneko](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@MKaneko](https://community.hubspot.com/u/MKaneko)\
**Post date:** [October 25, 2023, 6:10pm UTC](https://community.hubspot.com/t/attaching-files-to-a-custom-object/92500/4 "2023-10-25T18:10:26Z")

</div>

Hi,

Would you happen to know if you are using any specific scopes? I’ve done approximately the same thing for a deal, and I can see the note be associated in postman, but when I go to the deal I see that the attachment has been deleted. Any thoughts?

---

<div class="post-metadata">

**Author:** ![ABollinger](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/abollinger/32/76566_2.png) [@ABollinger](https://community.hubspot.com/u/ABollinger)\
**Post date:** [October 26, 2023, 11:26pm UTC](https://community.hubspot.com/t/attaching-files-to-a-custom-object/92500/5 "2023-10-26T23:26:03Z")

</div>

What do you mean when you say deleted? There should be a note and the attachment in the sidebar.
