Deal Search API

I am on the https://developers.hubspot.com/docs/api/crm/deals page and I am runing test POSTs of the /crm/v3/objects/deals/search API endpoint, using the Python library.
I post:

url = “https://api.hubapi.com/crm/v3/objects/deals/search”

querystring = {“hapikey”:“API_KEY_REDACTED”}

payload = “{\“filterGroups\”:[{\“filters\”:[{\“value\”:\“closedwon\”,\“propertyName\”:\“dealstage\”,\“operator\”:\“EQ\”}]}],\“sorts\”:[\“ASCENDING\”],\“query\”:\“string\”,\“properties\”:[\“hs_object_id\”],\“limit\”:100,\“after\”:0}”
headers = {
‘accept’: “application/json”,
‘content-type’: “application/json”
}

response = requests.request(“POST”, url, data=payload, headers=headers, params=querystring)

print(response.text)

The response that I get is:

HTTP 200

{
“total”: 0,
“results”: []
}

This is confusing, because there are 25 deals that are currently in closedwon.
I have noticed 2 things:

1) The response does not change if I pass any actual dealstage value, or a random string like “HELLO_WORLD”.

2) The same thing happens for the sorts body parameter. I don’t actually know what list of strings to pass here to achieve any kind of result. But as long as its a string, the post goes through.

What am I missing here? Ideally I would like to filter by dealstage value, and between two dates, and return all deal ids for deals in that search. However, since I can’t even get the dealstage to work, I am unable to progress.

Hello @MBright-Choch :waving_hand:

Deal stages and pipelines can not be search for by their name. They have uniqe ID numbers that you need to use.

If the deal stage is named “closedwon” it will have a uniqe ID that you need to refere to.

See my post here to get a full understanding on where to find your uniqe ID:

https://community.hubspot.com/t5/APIs-Integrations/Retrieve-Multiple-Deals-By-Account-Number/m-p/438299/highlight/true#M43405

Michael

HubSpot says the unique id for the stage named “Closed Won” is “closedwon”. This deal ID is returned to me when I use the Deal List API and simply look through all the deals.
Regardless, I have tried all the ids for every stage and have gotten the same result.

@MBright-Choch

I think the issue is in the sorts, query, properties,limit section.

My code to the left has been active for a year and is working.

Your code to the right is not working.

Try to adjust yours as mine to see if you get it to work.

Thank you! It seems that removing the limit, after and sorts parameters solved this issue. However, I’m not sure if this won’t break in the future…

I have tried using the method outlined an the id is “closedwon”