Skip to main content
POST
/
inbox_messages
JavaScript
import Moonbase from '@moonbaseai/sdk';

const client = new Moonbase({
  apiKey: process.env['MOONBASE_API_KEY'], // This is the default and can be omitted
});

const emailMessage = await client.inboxMessages.create({
  body: 'This is the body of the message. It supports [markdown](https://en.wikipedia.org/wiki/Markdown).',
  inbox_id: '1CLJt2v1rdcqdM6vZpPpjq',
  bcc: [{ email: '[email protected]', name: 'Steve' }],
  cc: [{ email: '[email protected]', name: 'Joe' }],
  subject: 'Test Subject',
  to: [{ email: '[email protected]', name: 'Bob' }, { email: '[email protected]' }],
});

console.log(emailMessage.id);
{
  "id": "1CLJt2v2rARKGD4MLziBCw",
  "type": "email_message",
  "body": {
    "markdown": "This is the body of the message. It supports [markdown](https://en.wikipedia.org/wiki/Markdown)."
  },
  "addresses": [
    {
      "id": "1CLJt2v36YcwAvYi3HnmKi",
      "type": "message_address",
      "email": "[email protected]",
      "role": "from"
    },
    {
      "id": "1CLJt2v3LvpZ5e34jasMSV",
      "type": "message_address",
      "email": "[email protected]",
      "role": "to",
      "person": {
        "id": "1CLJt2v5KzRWMMwvHwW4Nh",
        "type": "item"
      },
      "organization": {
        "id": "1CLJt2v4LTd2iVzVWmBhub",
        "type": "item"
      }
    },
    {
      "id": "1CLJt2v3bK2AzMXRRswwZG",
      "type": "message_address",
      "email": "[email protected]",
      "role": "to",
      "person": {
        "id": "1CLJt2v8Yy2ZAfJZKmXhtn",
        "type": "item"
      },
      "organization": {
        "id": "1CLJt2v4LTd2iVzVWmBhub",
        "type": "item"
      }
    },
    {
      "id": "1CLJt2v3qhDnu51n8B2Xg3",
      "type": "message_address",
      "email": "[email protected]",
      "role": "cc",
      "person": {
        "id": "1CLJt2vAnQq8M6hmaREzwm",
        "type": "item"
      },
      "organization": {
        "id": "1CLJt2v4LTd2iVzVWmBhub",
        "type": "item"
      }
    },
    {
      "id": "1CLJt2v465RQonW8pU77np",
      "type": "message_address",
      "email": "[email protected]",
      "role": "bcc",
      "person": {
        "id": "1CLJt2vDGEqKSFbLXN2t7X",
        "type": "item"
      },
      "organization": {
        "id": "1CLJt2v4LTd2iVzVWmBhub",
        "type": "item"
      }
    }
  ],
  "conversation": {
    "id": "1CLJt2v2bnDhMVZzehdb6A",
    "type": "inbox_conversation",
    "created_at": "2025-02-17T16:00:00.000Z",
    "updated_at": "2025-02-17T16:00:00.000Z",
    "tags": [],
    "subject": "Test Subject",
    "last_message_at": "2025-02-17T16:00:00.000Z",
    "state": "unassigned",
    "follow_up": false,
    "unread": false,
    "bulk": false,
    "spam": false,
    "trash": false,
    "draft": true
  },
  "created_at": "2025-02-17T16:00:00.000Z",
  "unread": false,
  "bulk": false,
  "spam": false,
  "trash": false,
  "draft": true,
  "subject": "Test Subject"
}

Authorizations

Authorization
string
header
required

Your Moonbase API key.

Body

application/json

The EmailMessage object to be created.

inbox_id
string
required

The inbox to use for sending the email.

body
string
required

The content of the email body in Markdown format.

conversation_id
string

The ID of the conversation, if responding to an existing conversation.

subject
string

The subject line of the email.

to
EmailMessageAddressParams · object[]

A list of Address objects for the recipients.

cc
EmailMessageAddressParams · object[]

A list of Address objects for the CC recipients.

bcc
EmailMessageAddressParams · object[]

A list of Address objects for the BCC recipients.

Response

Creation succeeded.

The Email Message object represents a single email within a Conversation.

type
string
required

String representing the object’s type. Always email_message for this object.

Allowed value: "email_message"
id
string
required

Unique identifier for the object.

created_at
string<date-time>
required

The time the message was received, as an ISO 8601 timestamp in UTC.

unread
boolean
required

true if the message has not been read.

bulk
boolean
required

true if the message appears to be part of a bulk mailing.

spam
boolean
required

true if the message is classified as spam.

trash
boolean
required

true if the message is in the trash.

draft
boolean
required

true if the message is a draft that has not been sent.

subject
string
required

The subject line of the email.

body
FormattedText · object
required

Structured content that can be rendered in multiple formats, currently supporting Markdown.

summary
string

A concise, system-generated summary of the email content.

addresses
MessageAddress · object[]

A list of Address objects associated with the message (sender and recipients).

Note: Only present when requested using the include query parameter.

attachments
MessageAttachment · object[]

A list of Attachment objects on the message.

Note: Only present when requested using the include query parameter.

conversation
InboxConversation · object

The Conversation thread this message is part of.

Note: Only present when requested using the include query parameter.