Line Items batch endpoint merging instances

Hello Everyone, I came across an annoying problem on the line items batch end point.

I’m importing line items from salesforce into hubspot, and when there are multiple instances of the same product associated with the same deal, the api do a ‘merge’ adding just one line item in reference of that product.

Example:

Product Name: Xproduct

Product SKU: Xprod1

Oppty ID : oppty1

Deal ID: 1234

Xproduct is inserted in Hubspot as an product object, carrying the same attributes as in Salesforce.

An Salesforce oppty ‘oppty1’ has three instances of Xproduct. When I try to batch insert three instances of Xproduct associated with deal ‘1234’, the result is only one instance of Xproduct, and the response returns the insertion of only one line item object. The endpoint does a ‘merge’, merging the three instances into one, so to speak.

I really dont know why this happens, I’m still on dev stage so I was able to spot it out. Its gonna be quite problematic when working with big volumes of data.

Anyone knows anything about that?

Thanks in advance!

Hi @arenodi,
Thank you for asking the Community!
I’m sorry to hear about your experience regarding this. I can see how it can be frustrating.
I understand that you are using this endpoint “Line Items” but when importing the line items from Salesforce into HubSpot, you don’t want them to be merged.
I found these documentations that might be of interest.
- Get a line item by ID
- Line items overview
I’d like to ask our Top Experts about this: Hi @MBERARD, @Teun and @Thomas_Rousseau do you have suggestions to help @arenodi, please?
If anybody else has anything to add and/or share, please feel free to join in the conversation :slightly_smiling_face:

Thank you very much and have a great day!
Best,
Bérangère

This behavior is quite annoying. I’m trying to split a deal’s line items into multiple invoices based on future billing date. Some deals contain multiple occurrences of the same product/quantity for the same invoice because they are separate services that happen to be delivered within the same time period.

The behavior of the batch API is discarding the “duplicate” items, forcing me to use the non-batch API instead.

Hi there @eterobby !

I’d recommend trying the workaround of using the single line items create endpoint for these cases. You can also try differentiating the line items by adding a unique name or description per record (e.g., service period or delivery phase), which may prevent the merge behavior.

If you’d like to see this handled differently at the API level, the Ideas Forum is the best place to submit it, especially with your invoice splitting use case spelled out.

Cassie, Community Manager

Hi Cassie,

Thank you for your response and the link to the Ideas Forum.

Unless and until the API behavior is changed, I think it would at least be worth documenting that the batch create API behaves this way. It’s quite surprising to submit an array with 3 records in inputs and receive a successful response where results contains only 2.

The existing documentation at Create a batch of line items - HubSpot docs and CRM API | Line items - HubSpot docs don’t mention this behavior at all, and they definitely should.

Fortunately, as I updated my script to include an appropriate hs_position_on_quote value for each item to preserve the expected order, I found that having a unique value for this property worked around this behavior, enabling me to use the batch API after all. This value was apparently also needed to avoid issues with the ensuing Hubspot->QuickBooks invoice sync process as well.

I’ve found years ago that the batch API will ignore multiple entries if they are exactly the same.

A huge pain to figure out and, as you noted, not really documented anywhere (except here in the Forum). I ended up just having a notes field or modifying the subject/name of the object slightly (eg, X of Y) to avoid having to deal with this issue.