APIs & Integrations

sshaikh
Membro

Companies(Contacts and Deals) - Recently created/modified

resolver

How to get recently created or modified companies/contacts/deals using the new version(v3)?

 

Previously, they were available under below endpoints for the companies;

 

GET /companies/v2/companies/recent/modified

GET /companies/v2/companies/recent/created

 

Appreciate help.

 

 

0 Avaliação positiva
1 Solução aceita
Willson
Solução
HubSpot Employee
HubSpot Employee

Companies(Contacts and Deals) - Recently created/modified

resolver

Hi @sshaikh 

 

These endpoints should still be functioning for you as we have not created these specific endpoints in the new v3. 

 

However, if you'd like, we can work with the new CRM Search to filter with same results. If we take a look at the Get recently created companies endpoint, this endpoint will only return records created in the last 30 days, or the 10k most recently created records.

 

With this in mind, we can build out our request using the new CRM Search and the operators to ensure we get the same results. This would look something like this:

POST https://api.hubapi.com/crm/v3/objects/companies/search?hapikey={{hapikey}}

Payload:
{
    "filterGroups":[
      {
        "filters":[
          {
            "propertyName": "createdate",
            "operator": "LTE",
            "value": "1584748800000" (This is 30 days ago, from now as of posting, in milliseconds)
          }
        ]
      }
    ]
  }'

This would then return all Companies that have been created less than 30 days ago. For more information on this new endpoint and the operators that can be used to query your data, head over to the documentation here

 

I hope this helps!

Product Manager @ HubSpot

Exibir solução no post original

3 Respostas 3
Willson
Solução
HubSpot Employee
HubSpot Employee

Companies(Contacts and Deals) - Recently created/modified

resolver

Hi @sshaikh 

 

These endpoints should still be functioning for you as we have not created these specific endpoints in the new v3. 

 

However, if you'd like, we can work with the new CRM Search to filter with same results. If we take a look at the Get recently created companies endpoint, this endpoint will only return records created in the last 30 days, or the 10k most recently created records.

 

With this in mind, we can build out our request using the new CRM Search and the operators to ensure we get the same results. This would look something like this:

POST https://api.hubapi.com/crm/v3/objects/companies/search?hapikey={{hapikey}}

Payload:
{
    "filterGroups":[
      {
        "filters":[
          {
            "propertyName": "createdate",
            "operator": "LTE",
            "value": "1584748800000" (This is 30 days ago, from now as of posting, in milliseconds)
          }
        ]
      }
    ]
  }'

This would then return all Companies that have been created less than 30 days ago. For more information on this new endpoint and the operators that can be used to query your data, head over to the documentation here

 

I hope this helps!

Product Manager @ HubSpot
alansp
Participante

Companies(Contacts and Deals) - Recently created/modified

resolver

I think your filter should be "GTE", no?

 

Also, what is the property for updated date? I can't seem to find one in the property editor for companies. I need recently modified, not just created.

0 Avaliação positiva
alansp
Participante

Companies(Contacts and Deals) - Recently created/modified

resolver

Nevermind. Answered my own question - hs_lastmodifieddate. The ruby code I'm using for the filter groups:

 

ninety_minutes_ago = (DateTime.now - 90.minutes).to_i * 1000
filters            = [{ "propertyName" => "hs_lastmodifieddate", "operator" => "GTE", "value" => "#{ninety_minutes_ago}" }]
filter_groups      = [ "filters" => filters ]