Sorting threads by latest activity

Hi there!

When I try to fetch all threads, it looks like they’re sorted by creation date instead of when the last message was sent (which can make my nylas inbox look dramatically different than gmail when I’m aiming for parity). It’s not uncommon for my users to have threads that span months and it’s important to always show threads with the most recently received messages at top. If I’m only able to grab 50-100 of the most recent (based on time of creation) threads I might miss a thread that started 2 months ago but had a reply today. does anyone have any experience with this or know a good workaround?

Thanks for calling this out — you’re right that the default /threads results are anchored to when the thread was created, we do return the threads in the order it’s being returned to us from the provider Google and not sorted based on recent timestamp, thus this can which can diverge from Gmail’s “most recently active first” view.

How to surface the most recently active threads

Use the latest_message_after / latest_message_before filters to fetch threads by activity window (based on the most recent message in each thread), then sort by the thread’s last-message timestamp in your UI. This captures long-running threads that started months ago but received a reply today.

Example:

#last_30_days_epoch = (now - 30 days) in seconds

curl --request GET 
–url “https://api.us.nylas.com/v3/grants/<GRANT_ID>/threads?latest_message_after=<last_30_days_epoch>&limit=50” 
–header “Authorization: Bearer <NYLAS_API_KEY>” 
–header “Accept: application/json”

Could you please let us know if this answers your question and resolves your issue?