How do I get all deals marked as "Closed Won"

SOLVE
Highlighted
Occasional Contributor

I am wanting to use this information in my application. I'm feeling a little confused about which API I need to use.

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
HubSpot Moderator

Welcome, @michaelbarley.

 

You can use the brand new CRM Search API to accomplish this.

 

For example, you could make a POST request to https://api.hubapi.com/crm/v3/objects/deals/search?hapikey=YOUR_HUBSPOT_API_KEY with the following body:

{
    "filterGroups":[
      {
        "filters":[
          {
            "propertyName": "dealstage",
            "operator": "EQ",
            "value": "closedwon"
          }
        ]
      }
    ]
  }

Isaac Takushi

HubSpot Developer Support
3 Replies 3
HubSpot Moderator

Welcome, @michaelbarley.

 

You can use the brand new CRM Search API to accomplish this.

 

For example, you could make a POST request to https://api.hubapi.com/crm/v3/objects/deals/search?hapikey=YOUR_HUBSPOT_API_KEY with the following body:

{
    "filterGroups":[
      {
        "filters":[
          {
            "propertyName": "dealstage",
            "operator": "EQ",
            "value": "closedwon"
          }
        ]
      }
    ]
  }

Isaac Takushi

HubSpot Developer Support
Occasional Contributor

@IsaacTakushi Thank you very much! Is there any way of only showing deals marked as "Closed Won" within the last 24 hours from when the API call is made? 

 

Thanks in advance,

 

Michael

Reply
0 Upvotes
HubSpot Moderator

Hi, @michaelbarley.

 

Yes, you could add a filter for the deal property closedate using a "greater than or equal to" (GTE) operator and set the value to the UNIX millisecond timestamp exactly 24 hours before the current time which you are making the request.

 

For example:

{
    "filterGroups":[
      {
        "filters":[
          {
            "propertyName": "dealstage",
            "operator": "EQ",
            "value": "closedwon"
          },
          {
            "propertyName": "closedate",
            "operator": "GTE",
            "value": "1580043600000"
          }
        ]
      }
    ]
  }

uses the value 1580043600000, which is about 24 hours before I authored this post, 26 January 2020 at 08:00 EST.

 

You will have to calculate the value on your end before making the request(s).

Isaac Takushi

HubSpot Developer Support