How to retrieve expanded email details with view=expanded using Nylas Node SDK

To access additional details for email messages and threads you can use the view=expanded option when fetching them with the Nylas API (Messages API Doc & Threads API Doc). Below are guides on how to retrieve expanded details for both messages and threads using Nylas Node SDK:

Retrieve an Expanded Message

Specify the unique message_id of the message you want to retrieve and use the messages.find method:

const messageId = "your_message_id"; // Replace with your actual message ID
const nylas = Nylas.with("your_access_token"); // Replace with your actual access token

nylas.messages.find(messageId, { view: 'expanded' }).then(message = {
  console.log(message);
}).catch(error = {
  console.error("Error fetching message:", error);
});

Example Response

Here's an example of what the expanded message response might look like in the response:

{
  // ...other message properties...
  headers: {
    'In-Reply-To': null,
    'Message-Id': '<cakp3d7gjg2+r+5p_zaqt3q=jrze=vdnnnntaz3-2m_pqtxa@mail.gmail.com>',
    References: []
  }

 

Retrieve an Expanded Thread

Similarly, for threads, specify the thread ID and use the threads.find method:

const threadId = "your_thread_id"; // Replace with your actual thread ID
const nylas = Nylas.with("your_access_token"); // Replace with your actual access token

nylas.threads.find(threadId, { view: 'expanded' }).then(thread = {
  console.log(thread);
}).catch(error = {
  console.error("Error fetching thread:", error);
});

Example Response

Here's an example of what the expanded thread response might look like in the response:

{
  // ...other thread properties...
  messages: [
    {
      // ...other message properties...
      id: 'message_id',
      accountId: 'account_id',
      object: 'message',
      // ...other message details...
      threadId: 'thread_id'
    }
  ],
  // ...other thread properties...
  drafts: []
}

Note: Make sure to replace "your_message_id", "your_thread_id", and "your_access_token" with the actual message ID, thread ID, and access token for your use case. Ensure that the Nylas SDK is properly installed and configured in your development environment before running the code (Getting started with Node SDK). 

---

Updated

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Article is closed for comments.