# Manage folders and labels with Python

Source: https://developer.nylas.com/docs/v3/sdks/python/manage-folders-labels/

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:

- [Installed and set up the Nylas Python SDK](/docs/v3/sdks/python/).
- Authenticated one or more users.

## List folders and labels

Depending on the 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](/docs/reference/api/folders/).

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

```py
folders = nylas.folders.list(
    '<NYLAS_GRANT_ID>'
)

print(folders)
```

## Create folders and labels

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

```py
from dotenv import load_dotenv
load_dotenv()


from nylas import Client

nylas = Client(
    os.environ.get('NYLAS_API_KEY'),
    os.environ.get('NYLAS_API_URI')
)

folder = nylas.folders.create(
    '<NYLAS_GRANT_ID>',
    request_body={
      "name": 'New Folder XYZ',
      "parent": None,
    }
)

print(folder)

message = nylas.messages.update(
    '<NYLAS_GRANT_ID>',
    '<MESSAGE_ID>',
    request_body={
      "folders": ['<FOLDER_ID>']
    }
)

print(message)
```