Only show these results:

Manage folders and labels with Python

This page explains how to organize an email inbox with folders and labels using the Nylas Python SDK and Email API.

Before you begin

Before you start, you must have done the following tasks:

List folders and labels

Depending on the end user's email provider, there are two possible ways their inbox might be organized: using either folders or labels. Gmail uses labels, and all other providers use folders. Nylas consolidates both folders and labels under the Folders endpoint.

The following example lists all folders and labels from an end user's inbox.

folders = nylas.folders.list(


Create folders and labels

The following example creates a folder and applies it to the most recent email message in the end user's inbox.

from dotenv import load_dotenv

import os
import sys
from nylas import Client

nylas = Client(

folder = nylas.folders.create(
"name": 'New Folder XYZ',
"parent": None,


message = nylas.messages.update(
"folders": ['<FOLDER_ID>']


Explore the Email API

If you've made it to this point, congratulations! You've learned how to manage folders and labels with the Nylas Node.js SDK and Email API! 🎉

There's plenty more that you can do with Nylas. Take a look at the following resources to learn more.