Hello,
I’m new to the platform and have a little problem with line item associations. As I understand, line items get associations to the specific product automatically when they are created, don’t they? But when I’m trying to send a get request to see mentioned associations - I receive an empty response. Because of this, I was wondering wether I am using right url:
https://api.hubapi.com/crm/v3/objects/line_items/{line_item_id}/associations/products
Thank you in advance for your help.
Hey, @G_Gorgiladze
Welcome to our community! Thanks for the great question.
Can you tell us more about your use case? I don’t think you’re doing anything wrong per se, I think this endpoint isn’t retuning an error or helpful messaging. Line items are an “instance” of a Product. So Line Items can have an association to Deals, for example. And Products can have the same, but Line Items are not associated to Products in the same manner.
I would use the v4 Associations endpoints unless you need to use v3 for a specific reason. I get the same result when looking for association labels:
GET https://api.hubapi.com/crm/v4/associations/line_item/products/labels
Response
{
"results": []
}
In contrast, if we go Line Items > Deals we get a response we’d expect:
GET https://api.hubapi.com/crm/v4/associations/line_item/deals/labels
Response
{
"results": [
{
"category": "HUBSPOT_DEFINED",
"typeId": 20,
"label": null
}
]
}
This bit from the Product API documentation adds a more context –
“Associate products
Products themselves can’t be associated with other CRM objects. However, to associate a product’s information with a deal or a quote, you can create a line item based on that product. Line items are individual instances of products, and are a separate object from products so that you can tailor the goods and services on a deal or quote as needed without needing to update the product itself.”
I hope this helps get you moving forward! — Jaycee
I don’t believe the accepted reply is 100% complete. You can in fact use `https://api.hubapi.com/crm/v4/objects/line_items/<id>?properties=hs_product_id` to obtain the hs_product_id that was originally copied from.
This very useful - and note something else; it also COPIES all metadata from the original product, including custom fields! However note that it also is a snapshot of the CURRENT information so if you update the Product’s metadata , the information in the Line Item is unchanged. This makes sense, BUT it’s not particularly obvious (it took me a lot of trial and error to figure this out).
@Jaycee_Lewis did I get anything wrong?
Hey hey @JDavisT
Thanks for your hard work. I tried your example and it works for me ![]()
Request
GET https://api.hubapi.com/crm/v4/objects/line_items/11276447266?properties=hs_product_id
Reply
{
"id": "11276447266",
"properties": {
"createdate": "2024-09-25T16:27:15.297Z",
"hs_lastmodifieddate": "2024-09-25T16:42:24.484Z",
"hs_object_id": "11276447266",
"hs_product_id": "1234567890"
},
"createdAt": "2024-09-25T16:27:15.297Z",
"updatedAt": "2024-09-25T16:42:24.484Z",
"archived": false
}
Thanks for the improved solution! You rock
— Jaycee