import Moonbase from '@moonbaseai/sdk';
const client = new Moonbase({
apiKey: process.env['MOONBASE_API_KEY'], // This is the default and can be omitted
});
const inboxMessage = await client.inboxMessages.create({
message: {
body: {},
inbox_id: '1CLJt2v6KXDyzDuM57pQqo',
subject: 'Test Subject',
to: [{ email: 'bob@example.com' }, { email: 'jack@example.com' }],
type: 'email_message',
},
});
console.log(inboxMessage);require "moonbase"
moonbase = Moonbase::Client.new(api_key: "My API Key")
inbox_message = moonbase.inbox_messages.create(
message: {
body: {},
inbox_id: "1CLJt2v6KXDyzDuM57pQqo",
subject: "Test Subject",
to: [{email: "bob@example.com"}, {email: "jack@example.com"}],
type: :email_message
}
)
puts(inbox_message)import os
from moonbase import Moonbase
client = Moonbase(
api_key=os.environ.get("MOONBASE_API_KEY"), # This is the default and can be omitted
)
inbox_message = client.inbox_messages.create(
message={
"body": {},
"inbox_id": "1CLJt2v6KXDyzDuM57pQqo",
"subject": "Test Subject",
"to": [{
"email": "bob@example.com"
}, {
"email": "jack@example.com"
}],
"type": "email_message",
},
)
print(inbox_message)package main
import (
"context"
"fmt"
"github.com/moonbaseai/moonbase-sdk-go"
"github.com/moonbaseai/moonbase-sdk-go/option"
"github.com/moonbaseai/moonbase-sdk-go/shared"
)
func main() {
client := moonbase.NewClient(
option.WithAPIKey("My API Key"),
)
inboxMessage, err := client.InboxMessages.New(context.TODO(), moonbase.InboxMessageNewParams{
OfEmailMessageNewConversationCreates: &moonbase.InboxMessageNewParamsMessageEmailMessageNewConversationCreateParams{
Body: shared.FormattedTextParam{},
InboxID: "1CLJt2v6KXDyzDuM57pQqo",
Subject: "Test Subject",
To: []moonbase.EmailMessageAddressParams{{
Email: "bob@example.com",
}, {
Email: "jack@example.com",
}},
},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", inboxMessage)
}
curl --request POST \
--url https://api.moonbase.ai/v0/inbox_messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "email_message",
"inbox_id": "1CLJt2v6KXDyzDuM57pQqo",
"subject": "Test Subject",
"body": {
"markdown": "This is the body of the message. It supports [markdown](https://en.wikipedia.org/wiki/Markdown)."
},
"to": [
{
"email": "bob@example.com",
"name": "Bob"
},
{
"email": "jack@example.com"
}
],
"cc": [
{
"email": "joe@example.com",
"name": "Joe"
}
],
"bcc": [
{
"email": "steve@example.com",
"name": "Steve"
}
]
}
'{
"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": "1CLJt2v7opRhSWqVEtHwYT",
"type": "email_message_address",
"email": "bob@example.com",
"role": "to",
"person": {
"id": "1CLJt2vA3GEGcxEhVY1EbS",
"type": "item",
"collection": {
"id": "1CLJt2ubZ7zAZFBxUxeBHo",
"type": "collection",
"ref": "people"
}
},
"organization": {
"id": "1CLJt2v93jRnz6HGiMgt8L",
"type": "item",
"collection": {
"id": "1CLJt2uco2zG6pdjxS37sg",
"type": "collection",
"ref": "organizations"
}
}
},
{
"id": "1CLJt2v84CdKMEKqwBNXfE",
"type": "email_message_address",
"email": "jack@example.com",
"role": "to",
"person": {
"id": "1CLJt2vDGEqKSFbLXN2t7X",
"type": "item",
"collection": {
"id": "1CLJt2ubZ7zAZFBxUxeBHo",
"type": "collection",
"ref": "people"
}
},
"organization": {
"id": "1CLJt2v93jRnz6HGiMgt8L",
"type": "item",
"collection": {
"id": "1CLJt2uco2zG6pdjxS37sg",
"type": "collection",
"ref": "organizations"
}
}
},
{
"id": "1CLJt2v8JapwFwpCdUT7n1",
"type": "email_message_address",
"email": "joe@example.com",
"role": "cc",
"person": {
"id": "1CLJt2vFVgdtcgzYn1kBAW",
"type": "item",
"collection": {
"id": "1CLJt2ubZ7zAZFBxUxeBHo",
"type": "collection",
"ref": "people"
}
},
"organization": {
"id": "1CLJt2v93jRnz6HGiMgt8L",
"type": "item",
"collection": {
"id": "1CLJt2uco2zG6pdjxS37sg",
"type": "collection",
"ref": "organizations"
}
}
},
{
"id": "1CLJt2v8Yy2ZAfJZKmXhtn",
"type": "email_message_address",
"email": "steve@example.com",
"role": "bcc",
"person": {
"id": "1CLJt2vHyWe5hqt7ixY4LG",
"type": "item",
"collection": {
"id": "1CLJt2ubZ7zAZFBxUxeBHo",
"type": "collection",
"ref": "people"
}
},
"organization": {
"id": "1CLJt2v93jRnz6HGiMgt8L",
"type": "item",
"collection": {
"id": "1CLJt2uco2zG6pdjxS37sg",
"type": "collection",
"ref": "organizations"
}
}
},
{
"id": "1CLJt2v8oMEB5Nnv24cJ1Z",
"type": "email_message_address",
"email": "person-151@example-151.com",
"role": "from"
}
],
"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"
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "400",
"title": "Bad Request",
"detail": "The request could not be understood due to malformed syntax or invalid parameters."
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "401",
"title": "Unauthorized",
"detail": "Invalid or missing API key or JWT. You should provide your Moonbase API Key or JWT in the authorization header, in the format: \"Authorization: Bearer MOONBASE_API_KEY\""
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "403",
"title": "Forbidden"
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "422",
"title": "Unprocessable Entity",
"detail": "Subject can't be blank",
"source": {
"pointer": "/subject"
}
},
{
"type": "error",
"status": "422",
"title": "Unprocessable Entity",
"detail": "To can't be blank",
"source": {
"pointer": "/to"
}
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "429",
"title": "Too Many Requests"
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "500",
"title": "Internal Server Error"
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "503",
"title": "Service Unavailable",
"detail": "The service is temporarily unavailable, please try again later."
}
]
}Create a Draft
Creates a new message draft.
import Moonbase from '@moonbaseai/sdk';
const client = new Moonbase({
apiKey: process.env['MOONBASE_API_KEY'], // This is the default and can be omitted
});
const inboxMessage = await client.inboxMessages.create({
message: {
body: {},
inbox_id: '1CLJt2v6KXDyzDuM57pQqo',
subject: 'Test Subject',
to: [{ email: 'bob@example.com' }, { email: 'jack@example.com' }],
type: 'email_message',
},
});
console.log(inboxMessage);require "moonbase"
moonbase = Moonbase::Client.new(api_key: "My API Key")
inbox_message = moonbase.inbox_messages.create(
message: {
body: {},
inbox_id: "1CLJt2v6KXDyzDuM57pQqo",
subject: "Test Subject",
to: [{email: "bob@example.com"}, {email: "jack@example.com"}],
type: :email_message
}
)
puts(inbox_message)import os
from moonbase import Moonbase
client = Moonbase(
api_key=os.environ.get("MOONBASE_API_KEY"), # This is the default and can be omitted
)
inbox_message = client.inbox_messages.create(
message={
"body": {},
"inbox_id": "1CLJt2v6KXDyzDuM57pQqo",
"subject": "Test Subject",
"to": [{
"email": "bob@example.com"
}, {
"email": "jack@example.com"
}],
"type": "email_message",
},
)
print(inbox_message)package main
import (
"context"
"fmt"
"github.com/moonbaseai/moonbase-sdk-go"
"github.com/moonbaseai/moonbase-sdk-go/option"
"github.com/moonbaseai/moonbase-sdk-go/shared"
)
func main() {
client := moonbase.NewClient(
option.WithAPIKey("My API Key"),
)
inboxMessage, err := client.InboxMessages.New(context.TODO(), moonbase.InboxMessageNewParams{
OfEmailMessageNewConversationCreates: &moonbase.InboxMessageNewParamsMessageEmailMessageNewConversationCreateParams{
Body: shared.FormattedTextParam{},
InboxID: "1CLJt2v6KXDyzDuM57pQqo",
Subject: "Test Subject",
To: []moonbase.EmailMessageAddressParams{{
Email: "bob@example.com",
}, {
Email: "jack@example.com",
}},
},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", inboxMessage)
}
curl --request POST \
--url https://api.moonbase.ai/v0/inbox_messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "email_message",
"inbox_id": "1CLJt2v6KXDyzDuM57pQqo",
"subject": "Test Subject",
"body": {
"markdown": "This is the body of the message. It supports [markdown](https://en.wikipedia.org/wiki/Markdown)."
},
"to": [
{
"email": "bob@example.com",
"name": "Bob"
},
{
"email": "jack@example.com"
}
],
"cc": [
{
"email": "joe@example.com",
"name": "Joe"
}
],
"bcc": [
{
"email": "steve@example.com",
"name": "Steve"
}
]
}
'{
"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": "1CLJt2v7opRhSWqVEtHwYT",
"type": "email_message_address",
"email": "bob@example.com",
"role": "to",
"person": {
"id": "1CLJt2vA3GEGcxEhVY1EbS",
"type": "item",
"collection": {
"id": "1CLJt2ubZ7zAZFBxUxeBHo",
"type": "collection",
"ref": "people"
}
},
"organization": {
"id": "1CLJt2v93jRnz6HGiMgt8L",
"type": "item",
"collection": {
"id": "1CLJt2uco2zG6pdjxS37sg",
"type": "collection",
"ref": "organizations"
}
}
},
{
"id": "1CLJt2v84CdKMEKqwBNXfE",
"type": "email_message_address",
"email": "jack@example.com",
"role": "to",
"person": {
"id": "1CLJt2vDGEqKSFbLXN2t7X",
"type": "item",
"collection": {
"id": "1CLJt2ubZ7zAZFBxUxeBHo",
"type": "collection",
"ref": "people"
}
},
"organization": {
"id": "1CLJt2v93jRnz6HGiMgt8L",
"type": "item",
"collection": {
"id": "1CLJt2uco2zG6pdjxS37sg",
"type": "collection",
"ref": "organizations"
}
}
},
{
"id": "1CLJt2v8JapwFwpCdUT7n1",
"type": "email_message_address",
"email": "joe@example.com",
"role": "cc",
"person": {
"id": "1CLJt2vFVgdtcgzYn1kBAW",
"type": "item",
"collection": {
"id": "1CLJt2ubZ7zAZFBxUxeBHo",
"type": "collection",
"ref": "people"
}
},
"organization": {
"id": "1CLJt2v93jRnz6HGiMgt8L",
"type": "item",
"collection": {
"id": "1CLJt2uco2zG6pdjxS37sg",
"type": "collection",
"ref": "organizations"
}
}
},
{
"id": "1CLJt2v8Yy2ZAfJZKmXhtn",
"type": "email_message_address",
"email": "steve@example.com",
"role": "bcc",
"person": {
"id": "1CLJt2vHyWe5hqt7ixY4LG",
"type": "item",
"collection": {
"id": "1CLJt2ubZ7zAZFBxUxeBHo",
"type": "collection",
"ref": "people"
}
},
"organization": {
"id": "1CLJt2v93jRnz6HGiMgt8L",
"type": "item",
"collection": {
"id": "1CLJt2uco2zG6pdjxS37sg",
"type": "collection",
"ref": "organizations"
}
}
},
{
"id": "1CLJt2v8oMEB5Nnv24cJ1Z",
"type": "email_message_address",
"email": "person-151@example-151.com",
"role": "from"
}
],
"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"
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "400",
"title": "Bad Request",
"detail": "The request could not be understood due to malformed syntax or invalid parameters."
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "401",
"title": "Unauthorized",
"detail": "Invalid or missing API key or JWT. You should provide your Moonbase API Key or JWT in the authorization header, in the format: \"Authorization: Bearer MOONBASE_API_KEY\""
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "403",
"title": "Forbidden"
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "422",
"title": "Unprocessable Entity",
"detail": "Subject can't be blank",
"source": {
"pointer": "/subject"
}
},
{
"type": "error",
"status": "422",
"title": "Unprocessable Entity",
"detail": "To can't be blank",
"source": {
"pointer": "/to"
}
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "429",
"title": "Too Many Requests"
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "500",
"title": "Internal Server Error"
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "503",
"title": "Service Unavailable",
"detail": "The service is temporarily unavailable, please try again later."
}
]
}Authorizations
Your Moonbase API key.
Body
The Message object to be created.
- EmailMessageNewConversationCreateParams
- SlackMessageNewConversationCreateParams
- EmailMessageReplyCreateParams
- SlackMessageReplyCreateParams
Parameters for creating an email message draft. Provide either the fields for a new conversation, or a conversation_id to reply to an existing conversation.
"email_message"The inbox to use for sending the email.
The subject line of the email.
The email body.
Show child attributes
Show child attributes
A list of recipients.
Show child attributes
Show child attributes
A list of the CC recipients.
Show child attributes
Show child attributes
A list of the BCC recipients.
Show child attributes
Show child attributes
Response
Creation succeeded.
- EmailMessage
- SlackMessage
The Email Message object represents a single email within a Conversation.
String representing the object’s type. Always email_message for this object.
"email_message"Unique identifier for the object.
The current lock version of the message for optimistic concurrency control.
The time the message was received, as an ISO 8601 timestamp in UTC.
true if the message has not been read.
true if the message appears to be part of a bulk mailing.
true if the message is classified as spam.
true if the message is in the trash.
true if the message is a draft that has not been sent.
The subject line of the email.
Structured content that can be rendered in multiple formats, currently supporting Markdown.
Show child attributes
Show child attributes
A concise, system-generated summary of the email content.
A list of Address objects associated with the message (sender and recipients).
Note: Only present when requested using the include query parameter.
Show child attributes
Show child attributes
A list of Attachment objects on the message.
Note: Only present when requested using the include query parameter.
Show child attributes
Show child attributes
The Conversation thread this message is part of.
Note: Only present when requested using the include query parameter.
Show child attributes
Show child attributes

