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: {
    markdown:
      'This is the body of the message. It supports [markdown](https://en.wikipedia.org/wiki/Markdown).',
  },
  inbox_id: '1CLJt2v6KXDyzDuM57pQqo',
  bcc: [{ email: 'steve@example.com', name: 'Steve' }],
  cc: [{ email: 'joe@example.com', name: 'Joe' }],
  subject: 'Test Subject',
  to: [{ email: 'bob@example.com', name: 'Bob' }, { email: 'jack@example.com' }],
});

console.log(emailMessage.id);
{
  "id": "1CLJt2v7K42Td5rmrJ8mJu",
  "type": "email_message",
  "body": {
    "markdown": "This is the body of the message. It supports [markdown](https://en.wikipedia.org/wiki/Markdown)."
  },
  "addresses": [
    {
      "id": "1CLJt2v7ZSE5XoM8YbDMRg",
      "type": "message_address",
      "email": "person-241@example-241.com",
      "role": "from"
    },
    {
      "id": "1CLJt2v7opRhSWqVEtHwYT",
      "type": "message_address",
      "email": "bob@example.com",
      "role": "to",
      "person": {
        "id": "1CLJt2v9nt2eiEkLoEveUf",
        "type": "item"
      },
      "organization": {
        "id": "1CLJt2v8oMEB5Nnv24cJ1Z",
        "type": "item"
      }
    },
    {
      "id": "1CLJt2v84CdKMEKqwBNXfE",
      "type": "message_address",
      "email": "jack@example.com",
      "role": "to",
      "person": {
        "id": "1CLJt2vD1rdhXY6yq4xHzk",
        "type": "item"
      },
      "organization": {
        "id": "1CLJt2v8oMEB5Nnv24cJ1Z",
        "type": "item"
      }
    },
    {
      "id": "1CLJt2v8JapwFwpCdUT7n1",
      "type": "message_address",
      "email": "joe@example.com",
      "role": "cc",
      "person": {
        "id": "1CLJt2vFFJSGhyWC5ifb3j",
        "type": "item"
      },
      "organization": {
        "id": "1CLJt2v8oMEB5Nnv24cJ1Z",
        "type": "item"
      }
    },
    {
      "id": "1CLJt2v8Yy2ZAfJZKmXhtn",
      "type": "message_address",
      "email": "steve@example.com",
      "role": "bcc",
      "person": {
        "id": "1CLJt2vHj8STo8Pm2fTUDV",
        "type": "item"
      },
      "organization": {
        "id": "1CLJt2v8oMEB5Nnv24cJ1Z",
        "type": "item"
      }
    }
  ],
  "conversation": {
    "id": "1CLJt2v74fpqiNNRA14BC8",
    "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": true,
    "bulk": false,
    "spam": false,
    "trash": false,
    "draft": true
  },
  "lock_version": 0,
  "created_at": "2025-02-17T16:00:00.000Z",
  "unread": true,
  "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
FormattedText · object
required

The email body.

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 recipients.

cc
EmailMessageAddressParams · object[]

A list of the CC recipients.

bcc
EmailMessageAddressParams · object[]

A list of 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.

lock_version
integer
required

The current lock version of the message for optimistic concurrency control.

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.