import Inbound from 'inboundemail';
const client = new Inbound({
apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
});
const mail = await client.mail.retrieve('id');
console.log(mail.messages);{
"thread": {
"id": "<string>",
"root_message_id": "<string>",
"participant_emails": [
"<string>"
],
"participant_names": [
"<string>"
],
"message_count": 123,
"last_message_at": "<string>",
"created_at": "<string>",
"updated_at": "<string>",
"normalized_subject": "<string>"
},
"messages": [
{
"id": "<string>",
"type": "inbound",
"thread_position": 123,
"from": "<string>",
"to": [
"<string>"
],
"cc": [
"<string>"
],
"bcc": [
"<string>"
],
"is_read": true,
"has_attachments": true,
"attachments": [
{
"filename": "<string>",
"contentType": "<string>",
"size": 123,
"contentId": "<string>",
"content": "<string>"
}
],
"references": [
"<string>"
],
"headers": "<unknown>",
"tags": [
{
"name": "<string>",
"value": "<string>"
}
],
"message_id": "<string>",
"subject": "<string>",
"text_body": "<string>",
"html_body": "<string>",
"from_name": "<string>",
"from_address": "<string>",
"date": "<string>",
"received_at": "<string>",
"sent_at": "<string>",
"read_at": "<string>",
"in_reply_to": "<string>",
"status": "<string>",
"failure_reason": "<string>"
}
],
"total_count": 123
}Retrieve a complete email thread (conversation) with all messages.
What You Get:
Message Types:
inbound - Emails you receivedoutbound - Emails you sent (includes delivery status)import Inbound from 'inboundemail';
const client = new Inbound({
apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
});
const mail = await client.mail.retrieve('id');
console.log(mail.messages);{
"thread": {
"id": "<string>",
"root_message_id": "<string>",
"participant_emails": [
"<string>"
],
"participant_names": [
"<string>"
],
"message_count": 123,
"last_message_at": "<string>",
"created_at": "<string>",
"updated_at": "<string>",
"normalized_subject": "<string>"
},
"messages": [
{
"id": "<string>",
"type": "inbound",
"thread_position": 123,
"from": "<string>",
"to": [
"<string>"
],
"cc": [
"<string>"
],
"bcc": [
"<string>"
],
"is_read": true,
"has_attachments": true,
"attachments": [
{
"filename": "<string>",
"contentType": "<string>",
"size": 123,
"contentId": "<string>",
"content": "<string>"
}
],
"references": [
"<string>"
],
"headers": "<unknown>",
"tags": [
{
"name": "<string>",
"value": "<string>"
}
],
"message_id": "<string>",
"subject": "<string>",
"text_body": "<string>",
"html_body": "<string>",
"from_name": "<string>",
"from_address": "<string>",
"date": "<string>",
"received_at": "<string>",
"sent_at": "<string>",
"read_at": "<string>",
"in_reply_to": "<string>",
"status": "<string>",
"failure_reason": "<string>"
}
],
"total_count": 123
}Your Inbound API key. Include it in the Authorization header as: Bearer
The unique thread ID to retrieve
Was this page helpful?