APIs & Integrations

michaelbarley
Contributor

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

SOLVE

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

0 Upvotes
1 Accepted solution
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

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

SOLVE

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

Associate Certification Manager

View solution in original post

3 Replies 3
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

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

SOLVE

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

Associate Certification Manager
michaelbarley
Contributor

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

SOLVE

@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

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

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

SOLVE

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

Associate Certification Manager