CRM API: Products and their Associations; Which objects associate with a product?

SOLVE
danhammari
Contributor

I am confused by the API documentation for CRM Objects of type Product.

https://developers.hubspot.com/docs/api/crm/products

 

The Overview tab for the Product object states the following:

Associations between products and other objects
- Products don’t support any associations.

And yet, the API Endpoints tab on the same page clearly indicates that Products have a PUT method and a DELETE method for managing product associations:

Associate a product with another object
- PUT /crm/v3/objects/products/{productId}/associations/{toObjectType}/{toObjectId}/{associationType}
Remove an association between two products
- DELETE /crm/v3/objects/products/{productId}/associations/{toObjectType}/{toObjectId}/{associationType}

So it seems that there is a framework for possibly associating products with other products and maybe even with other CRM objects. Where can I find a list of associationType constants that I can use with Product objects?

 

I tried using the Associations Types endpoint to fetch a list of associations I can use with products:

GET /crm/v3/associations/products/products/types
GET /crm/v3/associations/products/line_items/types
GET /crm/v3/associations/products/deals/types

The only response I ever received was the following:

HTTP 200
{ "results": [] }

So are there really no possible product associations at this time?

Will there be possible product associations in the future?

Will I be able to model product kits and product bundles?

 

Sincerely,

Dan

0 Upvotes
1 Accepted solution

Accepted Solutions
danhammari
Solution
Contributor

Ah, I see the distinction now. It breaks with the expected pattern that other CRM objects use. With other objects, you create two objects and then associate them with each other by defining an association relationship using object types and direction. Following this pattern, I was expecting to create a Line Item object and a Product object and then formalize a relationship between the two using the associations API.

 

Instead, the Line Item object is tightly coupled to the Product object. I must first create a Product object, then while creating the Line Item object I must embed a reference to the Product object's id within the Line Item object itself:

POST /crm/v3/objects/line_items
- { "properties": { "name": "line item name", "hs_product_id": "123456", ... } }

 

I can then use the normal associations pattern to bridge from a Line Item object to other CRM objects. Indeed, when I call the API to fetch possible associations I find the definitions that will allow me to bridge between a Line Item object and a Deal object or Quote object:

GET /crm/v3/associations/line_items/deals/types
GET /crm/v3/associations/line_items/quotes/types

 

Perhaps in the future HubSpot will be able to allow us to define complex product kits and product bundles that consist of combinations of other products. In the meanwhile, I think I have the tools to create a simple Product object, embed it in a Line Item object, then associate that Line Item object with a Quote object or a Deal object.

View solution in original post

2 Replies 2
dennisedson
Community Manager

@danhammari 

Think of the products as a catalog.  When you pull one from the catalog, it changes from a product to a line item.   The line item is then what is associated.

I get where you are coming from, though.  Would be worth submitting that last question as an idea and if you could add a use case, all the better.

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
0 Upvotes
danhammari
Solution
Contributor

Ah, I see the distinction now. It breaks with the expected pattern that other CRM objects use. With other objects, you create two objects and then associate them with each other by defining an association relationship using object types and direction. Following this pattern, I was expecting to create a Line Item object and a Product object and then formalize a relationship between the two using the associations API.

 

Instead, the Line Item object is tightly coupled to the Product object. I must first create a Product object, then while creating the Line Item object I must embed a reference to the Product object's id within the Line Item object itself:

POST /crm/v3/objects/line_items
- { "properties": { "name": "line item name", "hs_product_id": "123456", ... } }

 

I can then use the normal associations pattern to bridge from a Line Item object to other CRM objects. Indeed, when I call the API to fetch possible associations I find the definitions that will allow me to bridge between a Line Item object and a Deal object or Quote object:

GET /crm/v3/associations/line_items/deals/types
GET /crm/v3/associations/line_items/quotes/types

 

Perhaps in the future HubSpot will be able to allow us to define complex product kits and product bundles that consist of combinations of other products. In the meanwhile, I think I have the tools to create a simple Product object, embed it in a Line Item object, then associate that Line Item object with a Quote object or a Deal object.

View solution in original post