# Sort parameter not working

**URL:** <https://community.hubspot.com/t/sort-parameter-not-working/98916>\
**Category:** APIs & Integrations\
**Tags:** professional\
**Created:** [January 29, 2024, 6:44pm UTC](https://community.hubspot.com/t/sort-parameter-not-working/98916 "2024-01-29T18:44:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JDeak](https://avatars.discourse-cdn.com/v4/letter/j/b77776/32.png) [@JDeak](https://community.hubspot.com/u/JDeak)\
**Post date:** [January 29, 2024, 6:44pm UTC](https://community.hubspot.com/t/sort-parameter-not-working/98916/1 "2024-01-29T18:44:51Z")

</div>

Hi Im trying to sort values DESC, however everythin i tried for all fileds is not working. API is still returning oldest data. My code:

url = “[https://api.hubapi.com/conversations/v3/conversations/threads](https://api.hubapi.com/conversations/v3/conversations/threads)”  
headers = {  
‘accept’: “application/json”,  
‘authorization’: f’Bearer {api\_key}’  
}  
params = {‘threadStatus’: ‘OPEN’, “limit”:“500”, “sorts”: [  
{  
“propertyName”: “createdAt”,  
“direction”: “DESCENDING”  
}  
]}

response = requests.request(“GET”, url, headers=headers, params = params)

Documentation:

> **[Conversations API - HubSpot docs](https://developers.hubspot.com/docs/api-reference/legacy/conversations/guide)**
>
> Use the conversations API to manage inboxes, channels, threads, and messages.

> **[Search the CRM - HubSpot docs](https://developers.hubspot.com/docs/api-reference/latest/crm/search-the-crm)**
>
> The CRM search endpoints make getting data more efficient by allowing developers to filter, sort, and search across any CRM object type.

---

<div class="post-metadata">

**Author:** ![zach\_threadint](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zach_threadint/32/46318_2.png) [@zach\_threadint](https://community.hubspot.com/u/zach_threadint)\
**Post date:** [January 30, 2024, 12:30am UTC](https://community.hubspot.com/t/sort-parameter-not-working/98916/2 "2024-01-30T00:30:14Z")

</div>

Hi @JDeak 👋

As per [“Get threads” endpoint documentation](https://developers.hubspot.com/docs/api/conversations/conversations) (click into “Endpoints” tab, then scroll down to “Get threads”):

_ **Parameters \> Sort** : Set the sort order of the response. Valid options are id (default) and latestMessageTimestamp (which requires the latestMessageTimestampAfter field to also be set). **If you’re filtering threads by associatedContactId , you can sort in descending order** by prepending - to the sort option (e.g., -id or -latestMessageTimestampAfter ). Otherwise, results are always returned in ascending order._

The way I read this (and the way it behaves based on my testing) is that, unless you’re filtering Conversation Threads by Associated Contact ID, the results will always be returned in ascending order.

The Conversations Inbox & Messages API is still in Beta, so you may wish to [HubSpot Community - HubSpot Ideas - HubSpot Community](https://community.hubspot.com/t5/HubSpot-Ideas/idb-p/HubSpot_Ideas) in the hope of future changes being made that would suit your use case.

I hope this proves useful. Please let me know if you have any follow-up questions.

---

<div class="post-metadata">

**Author:** ![JDeak](https://avatars.discourse-cdn.com/v4/letter/j/b77776/32.png) [@JDeak](https://community.hubspot.com/u/JDeak)\
**Post date:** [January 30, 2024, 11:15am UTC](https://community.hubspot.com/t/sort-parameter-not-working/98916/3 "2024-01-30T11:15:02Z")

</div>

Hi Zach,

thanks for quick reply. Well even if i try with -id, its not working. I tried all the options mentioned at the documentation/ forums. Is there a way i can report a bug?:

 ![JDeak_0-1706612463429.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/2X/b/bc47deeea58487ad2c518916854aa771ef63471a.jpeg)

 ![JDeak_1-1706612885227.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/6/0/609ef0f6f8369e38bab8bd59bfaca76bdb726ead.png)

---

<div class="post-metadata">

**Author:** ![zach\_threadint](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zach_threadint/32/46318_2.png) [@zach\_threadint](https://community.hubspot.com/u/zach_threadint)\
**Post date:** [January 30, 2024, 9:55pm UTC](https://community.hubspot.com/t/sort-parameter-not-working/98916/4 "2024-01-30T21:55:39Z")

</div>

Hi @JDeak 👋

My understanding is that unless you use the _associatedContactId_ parameter, you can’t influence how the results are sorted (specific to this API endpoint). As I see in your screenshot, you aren’t defining the _associatedContactId_ parameter, so the API is likely just ignoring the _sort_ parameter.

I hope this proves useful. Please let me know if you have any follow-up questions.
