Retrieve emails

Learn how to retrieve emails using Unipile API.

List emails

To list all emails in a specific folder, or with a specific Gmail label, use List folder Emails method and provide the folder ID.

const { data } = await emailsApi.getFolderEmailsList({
  path: {
    account_id: "acc_123456789",
    folder_id: "folder_id",
  },
  query: {
    limit: 20,
  },
});
emails = emails_api.get_folder_emails_list(
    "acc_123456789",
    "folder_id",
    limit=20,
)
curl --request GET \
     --url https://api.unipile.com/v2/account_id/folders/folder_id/emails \
     --header 'accept: application/json'

If you need to, you can even list emails across all folders using List all Emails.

❗️

This feature is not supported for IMAP accounts unless you enable Initial Sync

const { data } = await emailsApi.getEmailsList({
  path: {
    account_id: "acc_123456789",
  },
  query: {
    limit: 20,
  },
});
emails = emails_api.get_emails_list(
    "acc_123456789",
    limit=20,
)
curl --request GET \
     --url https://api.unipile.com/v2/account_id/emails \
     --header 'accept: application/json'

Get a specific email

To get a specific email, use Get an Email method and provide the Email ID.

const { data } = await emailsApi.getEmail({
  path: {
    account_id: "acc_123456789",
    email_id: "email_id",
  },
});
email = emails_api.get_email("acc_123456789", "email_id")
curl --request GET \
     --url https://api.unipile.com/v2/account_id/emails/email_id \
     --header 'accept: application/json'
👍

Recommendation

Listing full emails can be slow and use more provider quota when the data is not cached. To improve performance, set meta_only to true when listing emails to fetch only partial data (enough for displaying in a UI list).
When a full email is needed, retrieve it using Get an Email.


Download attachments

If an email contains attachments, only metadata useful for display are present in the Email object.

Use Get an Email Attachment to download the file itself by providing the Email ID and Attachment ID.

const attachment = await emailsApi.getAttachment1({
  path: {
    account_id: "acc_123456789",
    email_id: "email_id",
    attachment_id: "attachment_id",
  },
});
attachment = emails_api.get_attachment1(
    "acc_123456789",
    "email_id",
    "attachment_id",
)
curl --request GET \
     --url https://api.unipile.com/v2/account_id/emails/email_id/attachments/attachment_id

What’s Next