API call to find initial stage of a deal

Hi all,

I am trying to find a way to get the initial stage of of deal, by deal number.
Does any of you guys found a way? The result of the get /deals/{id} endpoint, specially the “order_of_stages” field sound like good answers, but sadly the stages are not in the good order there.

Thank you all,
Gustave

Hey @gustave

What do you mean they’re not in “good order”? They should show here in the order they are in the Pipeline (top to bottom)

Do you have an example?

1 Like

Thanks for the quick reply @David, sorry for not being very clear.

If I cross-reference the order_of_stages field (which is the ‘natural’ order of the stages) and a non-null time in the stage I might be able to find out what the first stage of the deal was.

Only thing is when a deal has been added in a stage and then moved to an earlier stage, it is impossible to detect that and the wrong stage will be marked as being the first stage.

For example I get the following result when calling the API:

“times_in_stages”: {

"19": 27940,
"20": 80030,
"30": 1067656,
"32": 200495,
"33": 11340,
"34": 0,
"35": 0,
"36": 0,
"38": 0,
"40": 0,
"49": 0,
"50": 0,
"51": 0,
"52": 0,
"65": 349651,
"66": 0,
"67": 174,
"71": 0,
"72": 425401

},
“order_of_stages”: [

34,
40,
49,
50,
35,
36,
71,
38,
65,
66,
67,
51,
52,
72,
30,
32,
33,
19,
20

]

In this case the deal really has been added to stage 67 and moved back to 65. But using the deal order I would find that 65 was the first stage.

So my question aimed at querying this another way.

Thanks for your help!

Thanks for giving me more details on this :slight_smile:

For that, you’ll want to use: https://developers.pipedrive.com/docs/api/v1/#!/Deals/get_deals_id_flow

Then, just look for the first “dealChange” with “field_key”: “stage_id”, changes old_value to new_value

Hi,

I ended up using https://developers.pipedrive.com/docs/api/v1/#!/Deals/get_deals_id_flow and getting the first previous stage that occurs.

When a deal had never been moved, I just used the get /deals/{id} endpoint has it is consistent in that case.

Thanks for your help @David

Have a great day everyone

1 Like