An undocumented product_id parameter in Pipedrive API to attach products to deals

I found a “bug” in the Pipedrive API documentation while exploring a customer case together with Pipedrive partner SaaShop.

If you need to attach products to deals through Pipedrive API, this might be helpful to you as well.

The Pipedrive development team has been informed and the issue has been confirmed. The documentation will be updated soon according to my report.

Here is the related discussion in the Pipedrive dev community.

Product-deal attachment endpoint missing product_id parameter from the documentation

In order to link products and deals with each other, you obviously need an id for both product and deal.

In Pipedrive API it should be done by posting to /v1/deals/{id}/products endpoint that is documented here.

Unfortunately, the documentation was missing the required product_id parameter from the list of parameters. The product_id should be sent in the payload of the http post request.

The following screenshot has been taken on 2022-04-09. It can be seen, that product_id is not among the parameters.

Screenshot from the Pipedrive API endpoint to connect products to deals.
Screenshot from the Pipedrive API endpoint to connect products to deals.

Replicating the issue with product and deal linking

The issue can be replicated with the following Python code:

#run in the console: pip install requests
import requests

product_id=1
deal_id=1
api_key=''
domain = ''
endpoint = f'https://{domain}.pipedrive.com/v1/deals/{deal_id}/products'

#Causes the error
response = requests.post(
    endpoint,
    params = {'api_token': api_key},
    json = {
        #Code works when the following line is uncommented
        #'product_id': product_id,
        'item_price': 100,
        'quantity': 1 
    }
)

The code should cause the following error. It states that the product_id is required, even though it is not in the docs.

Error when trying to link products to deals without product_id in Pipedrive API: "Product id must be given."
Error when trying to link products to deals without product_id in Pipedrive API: “Product id must be given.”

How I found the undocumented feature from Pipedrive API?

I browsed through different endpoints in the Pipedrive API to find a way to link the products to deals.

Even though /v1/deals/{id}/products seemed the most promising, something did not make sense. I thoguht first that I need to create a product variation and utilize the product_variation_id parameter.

After hitting the endpoint, the error message in my console gave the revealing hint.

It was kinda existing to do such a finding from an established company. But as a developer I understand how easily something like this can happen.

Fix to the Pipedrive API docs coming soon!

The bottom line is that the API is working as a developer could expect. It was the documentation page that had a deficiency.

The Pipedrive Dev team took the finding really well and the docs should be updated soon.

Leave a Reply

Your email address will not be published.