# Deleting a line item using ExternalObjectId

**URL:** <https://community.hubspot.com/t/deleting-a-line-item-using-externalobjectid/26882>\
**Category:** APIs & Integrations\
**Created:** [October 16, 2020, 8:11pm UTC](https://community.hubspot.com/t/deleting-a-line-item-using-externalobjectid/26882 "2020-10-16T20:11:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Resanehlab](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/resanehlab/32/24246_2.png) [@Resanehlab](https://community.hubspot.com/u/Resanehlab)\
**Post date:** [October 16, 2020, 8:11pm UTC](https://community.hubspot.com/t/deleting-a-line-item-using-externalobjectid/26882/1 "2020-10-16T20:11:06Z")

</div>

Hi,  
I’m trying to develop an integration from an e-commerce platform to HubSpot using HubSpot eCommerce bridge API. I use a unique ExternalObjectId for any object in sync messages. All fine but how can I get a synced object in HubSpot by its ExternalObjectId? There is no request endpoint which takes a parameter as ExternalObjectId and returns the corresponding object. My current problem is that I want to delete some line items from a deal but it can’t be done by sync messages because as the document says “Please note: that the DELETE action type will not remove the object from HubSpot, it will prevent it from syncing in the future.” I can’t delete them by sync messages and also I don’t have their object Id in HubSpot to delete them using the delete line item endpoint documented [Accounts Dashboard | HubSpot](https://legacydocs.hubspot.com/docs/methods/line-items/delete-line-item). So, what can I do to delete some line items from a deal?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [October 19, 2020, 7:35pm UTC](https://community.hubspot.com/t/deleting-a-line-item-using-externalobjectid/26882/2 "2020-10-19T19:35:10Z")

</div>

Hey @Resanehlab !

Going to tag in @umakantmwb and @himanshurauthan here! They make the web better 😃

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [October 20, 2020, 4:55am UTC](https://community.hubspot.com/t/deleting-a-line-item-using-externalobjectid/26882/3 "2020-10-20T04:55:08Z")

</div>

Thanks for mentioning @dennisedson !

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [October 20, 2020, 4:54am UTC](https://community.hubspot.com/t/deleting-a-line-item-using-externalobjectid/26882/4 "2020-10-20T04:54:43Z")

</div>

Hi @Resanehlab !  
Yes there is no direct api to delete an object using ExternalObjectId for now.  
But your requirement of deleting line item from deal can be achieved by using - [get](https://developers.hubspot.com/docs/api/crm/deals)[deal](https://developers.hubspot.com/docs/api/crm/deals) line items associations by using **deal id** and **associations=line\_items,** In response you’ll get line items details with line item id, you can filter out the line items you want to delete/update and perform the action usin line item id.  
Hope this helps!  
Himanshu

---

<div class="post-metadata">

**Author:** ![Resanehlab](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/resanehlab/32/24246_2.png) [@Resanehlab](https://community.hubspot.com/u/Resanehlab)\
**Post date:** [October 20, 2020, 9:46am UTC](https://community.hubspot.com/t/deleting-a-line-item-using-externalobjectid/26882/5 "2020-10-20T09:46:45Z")

</div>

Hi Himanshu,

Thanks for the reply but as I mentioned before, I’m using HubSpot eCommerce bridge API and I only have the ExternalObjectId for any object. I don’t have any information and idea about the object ids in HubSpot like deal Id for every deal. How can I access the deal Id for a deal when I sync orders to deals using HubSpot sync messages?

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [October 23, 2020, 3:49am UTC](https://community.hubspot.com/t/deleting-a-line-item-using-externalobjectid/26882/6 "2020-10-23T03:49:29Z")

</div>

Hey @Resanehlab ,  
You can search the deal using the ExternalObjectId, i am supposing that if you are using the eComm bridge api you are creating deal for order or passing the ExternalObjectId in **ip\_\_ecomm\_bridge\_\_order\_number**.

using [search api](https://developers.hubspot.com/docs/api/crm/search) you can get the deal ID using the ExternalObjectId.

Thanks,  
Himanshu

---

<div class="post-metadata">

**Author:** ![Resanehlab](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/resanehlab/32/24246_2.png) [@Resanehlab](https://community.hubspot.com/u/Resanehlab)\
**Post date:** [October 24, 2020, 1:44pm UTC](https://community.hubspot.com/t/deleting-a-line-item-using-externalobjectid/26882/7 "2020-10-24T13:44:35Z")

</div>

Thanks. Now I can get a deal with its corresponding ExternalObjectId but when I try to get line items associated with a deal through the CRM Associations API [https://api.hubapi.com/crm-associations/v1/associations/dealId/HUBSPOT\_DEFINED/19](https://api.hubapi.com/crm-associations/v1/associations/dealId/HUBSPOT_DEFINED/19)

I’m getting this response: “Error 405 Method Not Allowed”

Am I missing something?

Thanks!

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [October 26, 2020, 3:48am UTC](https://community.hubspot.com/t/deleting-a-line-item-using-externalobjectid/26882/8 "2020-10-26T03:48:50Z")

</div>

Hey @Resanehlab !  
I recommend you to please migrate on v3 and using this endpoint you can get the line items [https://api.hubapi.com/crm/v3/objects/deals/dealId?associations=line\_items](https://developers.hubspot.com/docs/api/crm/deals)

Thanks,  
Himanshu
