# Deals API / params not clear

**URL:** <https://community.hubspot.com/t/deals-api-params-not-clear/50535>\
**Category:** APIs & Integrations\
**Tags:** object, professional\
**Created:** [January 28, 2022, 10:20am UTC](https://community.hubspot.com/t/deals-api-params-not-clear/50535 "2022-01-28T10:20:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![inouire](https://avatars.discourse-cdn.com/v4/letter/i/7ab992/32.png) [@inouire](https://community.hubspot.com/u/inouire)\
**Post date:** [January 28, 2022, 10:20am UTC](https://community.hubspot.com/t/deals-api-params-not-clear/50535/1 "2022-01-28T10:20:39Z")

</div>

Hi folks,

I’m working on the integration of Hubspot API. I want to link a Deal with some Products through the API, but the API doc does not tell me much about it.  
The doc tells me things about the endpoints, but not really about the possible values to use as params [https://developers.hubspot.com/docs/api/crm/deals](https://developers.hubspot.com/docs/api/crm/deals) \> Associate a deal with another object

In that precise case I don’t know what to put under “associationType”

I also had a look at the association API, [https://developers.hubspot.com/docs/api/crm/associations](https://developers.hubspot.com/docs/api/crm/associations)

But when I try this, GET [https://api.hubapi.com/crm/v3/objects/associations/product/deal/types?hapikey=xxxx](https://api.hubapi.com/crm/v3/objects/associations/product/deal/types?hapikey=xxxx)

Nothing is returned. Does that mean that we cannot link products and deals?

What am I missing? Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [January 28, 2022, 12:15pm UTC](https://community.hubspot.com/t/deals-api-params-not-clear/50535/2 "2022-01-28T12:15:35Z")

</div>

Hi @inouire ,

If you link a product to a deal, it becomes a line item. It has its own [API](https://developers.hubspot.com/docs/api/crm/line-items), so that should get you started.

---

<div class="post-metadata">

**Author:** ![inouire](https://avatars.discourse-cdn.com/v4/letter/i/7ab992/32.png) [@inouire](https://community.hubspot.com/u/inouire)\
**Post date:** [January 28, 2022, 2:54pm UTC](https://community.hubspot.com/t/deals-api-params-not-clear/50535/3 "2022-01-28T14:54:26Z")

</div>

Thank you @Teun for your reply.

I understand the concept, but it does not make sense when I look at the existing endpoints in API v3.  
I find no endpoint to “create” a line item directly. And I don’t understand which association to use to link a product to a deal (my initial question, GET [https://api.hubapi.com/crm/v3/objects/associations/product/deal/types?hapikey=xxxx](https://api.hubapi.com/crm/v3/objects/associations/product/deal/types?hapikey=xxxx) returns empty results, what association key should I use when I associate a product and a deal ?)

Strangely, I feel like it’s more logical in previous version of the API like this one [Accounts Dashboard | HubSpot](https://legacydocs.hubspot.com/docs/methods/line-items/create-line-item)

Thanks for your help

---

<div class="post-metadata">

**Author:** ![WaydeChristie1](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/waydechristie1/32/10224_2.png) [@WaydeChristie1](https://community.hubspot.com/u/WaydeChristie1)\
**Post date:** [February 1, 2022, 1:32am UTC](https://community.hubspot.com/t/deals-api-params-not-clear/50535/4 "2022-02-01T01:32:15Z")

</div>

Hi inouire,

To create a line item you need the CREATE endpoint here: [Accounts Dashboard | HubSpot](https://developers.hubspot.com/docs/api/crm/line-items).

Here’s an example POST body:

`{"name": "1 year implementation consultation","hs_product_id": "191902","hs_recurring_billing_period": "24","recurringbillingfrequency": "monthly","quantity": "2","price": "6000.00"}`

Ideally the line item should include a reference to a Hubspot product ID (“hs\_product\_id”), as line-items are a subset of products.

When the line item has been created the API will return the line item object ID. You’ll need this ID to then associate the line item with a deal.

You associate the line item with the deal using the"Associate a line item with another object" endpoint here: [Accounts Dashboard | HubSpot](https://developers.hubspot.com/docs/api/crm/line-items).

To do so, send a PUT request using this URL format:

[https://api.hubapi.com/crm/v3/objects/line\_items/{{yourline](https://api.hubapi.com/crm/v3/objects/line_items/%7Bline) item object id}}/associations/deal/{{your deal object ID}}/line\_item\_to\_deal (not including the curly brackets).

The “line\_item\_to\_deal” segment of the URL tells Hubspot how to associate the two objects. You can use this format for associating most objects. eg. Associating a deal to a contact uses this endpoint URL: [https://api.hubapi.com/crm/v3/objects/deals/](https://api.hubapi.com/crm/v3/objects/deals/){{deal ID}}/associations/contact/{{contactID}}/ **deal\_to\_contact**

You can also use the Associations API to **batch associate** multiple line items to a single deal - [Accounts Dashboard | HubSpot](https://developers.hubspot.com/docs/api/crm/associations)

The endpoint URL you’ll need for that is:

[https://api.hubapi.com/crm/v3/associations/line\_items/deals/batch/create](https://api.hubapi.com/crm/v3/associations/line_items/deals/batch/create)

And this is the body you’ll need to POST:

`{ "inputs": [{ "from": { "id": "{{line item ID}}" }, "to": { "id": "{{deal ID}}" }, "type": "line_item_to_deal" }, { "from": { "id": "{{another line item ID}}" }, "to": { "id": "{{deal ID}}" }, "type": "line_item_to_deal" }]}`

Unfortunately there isn’t a way to create a line item and associate it with a deal in one step, like there used to be in the old API. Now it’s necessary to use object association methods, or the associations API.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![inouire](https://avatars.discourse-cdn.com/v4/letter/i/7ab992/32.png) [@inouire](https://community.hubspot.com/u/inouire)\
**Post date:** [February 3, 2022, 10:51am UTC](https://community.hubspot.com/t/deals-api-params-not-clear/50535/5 "2022-02-03T10:51:06Z")

</div>

Thanks a lot @WaydeChristie1 , it seems exactly what I need, I’ll try it today.  
Why isn’t the API doc as clear as your comment? 😓

Thanks again

---

<div class="post-metadata">

**Author:** ![WaydeChristie1](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/waydechristie1/32/10224_2.png) [@WaydeChristie1](https://community.hubspot.com/u/WaydeChristie1)\
**Post date:** [February 4, 2022, 2:13am UTC](https://community.hubspot.com/t/deals-api-params-not-clear/50535/6 "2022-02-04T02:13:18Z")

</div>

You’ll have an a-ha moment with the docs eventually, like I did. They’re actually very well written,

Happy to help 👍
