Sort parameter not working

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”
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:

Hi @JDeak :waving_hand:

As per “Get threads” endpoint documentation (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 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.

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?:

Hi @JDeak :waving_hand:

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.