Nylas Folder API - Long next_cursor Causes URI Too Long Error with Limit > 10

Hello Community,

I am Working with folders using Email API to retrieve a list of folders and have encountered an issue related to pagination and the next_cursor value.

Problem:

When I request folders using a limit greater than 10 (e.g., 200), the next_cursor returned by the API becomes very long, such as:

"next_cursor": "djE6WyJBQU1rQURRME5tSm..."  // total character count is 87260
// I am not able to post whole due to post restriction 

When this cursor is passed as a page_token in the next paginated request, I encounter the following error:

Error: URI Too Long

However, if I set the limit to 10 or lower, the next_cursor remains short and the pagination works correctly without any error.

My Scenario:

  • Endpoint: GET /folders?limit=200
  • Using next_cursor as page_token for pagination
  • Issue only occurs when limit > 10

Questions:

  • Is this a known issue with the Folders API pagination logic?
  • Why does next_cursor become unreasonably long for higher limits?
  • Is there a way to shorten or safely encode the next_cursor to avoid this error?
  • Are there recommended best practices or limitations for paginating folder results?

Note:

This resembles Next_cursor in pagination got a lot bigger where cursor size scaled with limit.

Would appreciate any guidance or fixes regarding this issue.

Thanks!

Hi @anujkarki can you share more details, are you using an SDK or just HTTP requests?

So to reproduce:

  1. Request folders with a limit > 10
  2. Receive a large next_cursor value
  3. Try page_token in next request and receive an error

Do you know, how many folders do you have for that specific user? And the provider they are on?

The issue has been resolved. Upon contacting support, they confirmed it was a temporary issue and has now been addressed.

1 Like

@anujkarki glad to hear, thanks for following up!