Folders Retrieval

Hello nylas,
I have an issue with the retrieval of all folders (endpoint: GET “grants/<NYLAS_GRANT_ID>/folders”).

I would like customers to be able to define which folders they want to see at the top of the list, because I often have folders such as “inbox” or “sent” that end up on page 3 or 4 when data is retrieved from the user’s mailbox.

When folders are displayed, clients complain that they don’t see the same display as in their main GMAIL or OUTLOOK inbox, and this is mainly due, for example, displaying folders such as CATEGORY_FORUMS and CATEGORY_PERSONAL as top priority ahead of folders such as Inbox or Drafts.

So how can we ensure that the order of the source mailbox is respected when the data is moved up?

I attached a screen of a typical page 1 retrieval from the route.

Hi Yvan,

Thanks for reaching out! The folder ordering you’re seeing is expected behavior.

Gmail and Outlook web UIs use custom client-side ordering that prioritizes system folders like Inbox and Sent - this ordering isn’t exposed by their APIs, so we can’t replicate it server-side.

You can implement client-side sorting using the system_folder and name fields we return. Documentation.

This will display Inbox, Sent, Drafts, etc. at the top, followed by other system folders, then user-created folders, matching what users see in their native email clients.

Let us know if you have any questions!