CRM API v3 - Sort based on the modified date

SOLVE
Highlighted
Visitor

Hi Hubspot team,

I was working around Hubspot API v3, and I have requirement of sorting contacts based on modified date.So is there any solution for the same.

Thanks 

Atul

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Highlighted
HubSpot Moderator

Hi @Athul_C 

 

When working with our v3 APIs, you can work specifically with our CRM Search API in order to Sort results by properties.

 

As an example, we can use the following request:

curl https://api.hubapi.com/crm/v3/objects/contacts/search?hapikey=YOUR_HUBSPOT_API_KEY \
  --request POST \
  --header "Content-Type: application/json" \
  --data '{
    "sorts": [
      {
        "propertyName": "lastmodifieddate",
        "direction": "DESCENDING"
      }
    ]
  }'

This would then fetch your Contacts and sort them according to the lastmodifieddate timestamp, in this particular case, those created most recently.

 

I hope this helps!

Matthew Willson

HubSpot Developer Support
2 Replies 2
Highlighted
HubSpot Moderator

Hi @Athul_C 

 

When working with our v3 APIs, you can work specifically with our CRM Search API in order to Sort results by properties.

 

As an example, we can use the following request:

curl https://api.hubapi.com/crm/v3/objects/contacts/search?hapikey=YOUR_HUBSPOT_API_KEY \
  --request POST \
  --header "Content-Type: application/json" \
  --data '{
    "sorts": [
      {
        "propertyName": "lastmodifieddate",
        "direction": "DESCENDING"
      }
    ]
  }'

This would then fetch your Contacts and sort them according to the lastmodifieddate timestamp, in this particular case, those created most recently.

 

I hope this helps!

Matthew Willson

HubSpot Developer Support
Highlighted
Visitor

Hi willson,

Thank you for the quick response.This made my day.Smiley Happy

Regards

Athul

Reply
0 Upvotes