Retrieving emails

Learn how to retrieve messages of your connected accounts.

Feature available for : Google, Microsoft, IMAP

Get emails history

To get existing emails, use the GETemails Method or the appropriate SDK Method .

Most recent messages will be returned first, ordered by date.

By default, the limit of returned messages is set to 100.

You can use lot of parameters to get only a folder, date, recipient, sender, see GETemails

curl --request GET \
     --url https://{YOUR_DSN}/api/v1/email \
     --header 'X-API-KEY: {YOUR_ACCESS_TOKEN}' \
     --header 'accept: application/json'
     --data '
  "limit": 10
const response = await{
  limit: "10"

This method use pagination.

Get new emails

Unipile's API give you two options to receive emails in your application

In realtime with Webhooks

The recommended approach to listen for new messages in your application is by using a Webhook because they trigger in real time. Whenever the user account receives or sends a new email, the Webhook will call your specified URL with the given email that you can store to be displayed.

-> More informations on new emails webhooks

With a cron job

If your system cannot handle Webhooks, or if you don't need real time, you can create a cron job calling GET /emails Method at interval.

We advise fetching a larger period than your cron delay to account for any potential disconnects or errors that may result in losing outdated emails. In this case, implementing a unique ID verification on your history entry based on the email ID can help prevent duplicate entries.