Hi,
I’m encountering an issue where metadata I’ve included in a sent message is not appearing when I fetch the message via the Nylas API. I’m using the nylas Node.js SDK to send and retrieve messages, but the metadata field I’ve set during sending is not present in the fetched message data.
Below are code snippets for both sending and fetching the message, along with the response I get when fetching the message by ID. I’d appreciate any guidance on why the metadata isn’t appearing and how to resolve this.
Sending a Message with Metadata:
const sendMessage = async () => {
const nylas = new NylasClient({ grantId });
const emailData = {
subject: subject,
to: [{ email: email }],
body: body,
trackingOptions: {
threadReplies: true,
},
metadata: {
key1: "tester",
},
};
await nylas.sendMessage(emailData);
};
sendMessage();
Fetching a Message by ID:
const fetchEmail = async () => {
const nylas = new NylasClient({ grantId });
const email = await nylas.fetchMessageById(messageId);
console.log(email.data);
};
fetchEmail();
Fetched Message Response (Relevant Part):
{
requestId: '8783371811-efc52682-27a2-4363-885a-bf3ba842c4ad',
data: {
starred: false,
unread: false,
folders: [ 'SENT' ],
subject: 'SUBJECT',
threadId: 'THREAD_ID',
body: "B0DY",
grantId: 'GRANT_ID',
id: 'MESSAGE_ID',
object: 'message',
snippet: "",
bcc: [],
cc: [],
attachments: [],
from: [ [Object] ],
replyTo: [],
to: [ [Object] ],
date: 1751824524
},
// ... other fields omitted for brevity
}
As you can see, the metadata
field with key1: "tester"
that I included when sending the message is not present in the fetched data. Is this expected behavior, or am I missing a step to retrieve metadata? If metadata isn’t returned by default, is there a specific query parameter or method to access it?
I should mention that I’m on the sandbox plan. Maybe this is the reason?
Thank you for your assistance!
Best regards,
Ryan