Email API Overview
The Nylas Email API gives you a secure and reliable connection to your user’s inboxes. This enables you to sync both historic and live email data into your application in real-time, as well as perform bi-directional email sync with full CRUD (Create, Read, Update, Delete) for most email providers.
The Nylas Email API provides a REST interface that includes the functionality to do the following:
- Read data from email messages and threads, such as email content, sender and recipient information, subject lines, dates, and more.
- Organize email inboxes with labels and folders.
- Update the unread and starred status of email messages.
- Create drafts and send emails.
- Search email inboxes for specific content.
- Manage and download file attachments.
This section covers the endpoints that the Nylas Email API provides to enable you to integrate full email functionality into your app.
Messages are the fundamental object of the Nylas platform and the core building block for most email applications. They contain several pieces of information, such as a timestamp of the message, the sender's address, the recipient, and the message body. They can also contain file attachments, calendar invites, and more.
Threads are multiple messages that are grouped together into a single, first-class object. Nylas threads messages together using a variety of heuristics. For Gmail and Microsoft Exchange accounts, messages are threaded together as close as possible to the representation in those environments. For all other providers (including generic IMAP), messages are threaded using a custom JWZ-inspired algorithm.
Emails that are forwarded to other people in a thread remain in the thread both on the provider and Nylas.
Folders are the primary component for organizing email inboxes from most providers. They also behave like regular IMAP or filesystem folders. A message can only be contained within a single folder, but a thread with many messages might span multiple folders.
Gmail uses labels to organize email inboxes rather than folders, and messages may have more than one label. Nylas makes it easy to detect when accounts use this method of organization so you can ensure your end users have an experience that matches their provider of choice.
When adding and removing certain Gmail labels, Nylas follows the provider rules:
- Adding one of the All Mail, Trash, or Spam labels removes the other two.
- Adding either the Trash or Spam label removes the Inbox label.
- Adding the Inbox label removes a message's Trash or Spam labels. It also re-adds the All Mail label if needed.
Files are any data attached to messages. Nylas allows you to download existing attachments from messages and threads, as well as upload new files to be sent.
Drafts are a special kind of message that haven't been sent, and therefore its body contents and recipients are still mutable. The drafts endpoints let you read and modify existing drafts, create new drafts, send drafts, and delete drafts.