JavaScript
import fs from 'fs';
import Moonbase from '@moonbaseai/sdk';
const client = new Moonbase({
apiKey: process.env['MOONBASE_API_KEY'], // This is the default and can be omitted
});
const messageAttachment = await client.inboxMessages.attachments.create('inbox_message_id');
console.log(messageAttachment.id);require "moonbase"
moonbase = Moonbase::Client.new(api_key: "My API Key")
message_attachment = moonbase.inbox_messages.attachments.create("inbox_message_id")
puts(message_attachment)import os
from moonbase import Moonbase
client = Moonbase(
api_key=os.environ.get("MOONBASE_API_KEY"), # This is the default and can be omitted
)
message_attachment = client.inbox_messages.attachments.create(
inbox_message_id="inbox_message_id",
)
print(message_attachment.id)package main
import (
"context"
"fmt"
"github.com/moonbaseai/moonbase-sdk-go"
"github.com/moonbaseai/moonbase-sdk-go/option"
)
func main() {
client := moonbase.NewClient(
option.WithAPIKey("My API Key"),
)
messageAttachment, err := client.InboxMessages.Attachments.New(
context.TODO(),
"inbox_message_id",
moonbase.InboxMessageAttachmentNewParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", messageAttachment.ID)
}
curl --request POST \
--url https://api.moonbase.ai/v0/inbox_messages/{inbox_message_id}/attachments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file='@example-file' \
--form 'file_id=<string>'{
"id": "1CLJt2vAY2dWSPDQt8AQpz",
"type": "message_attachment",
"filename": "readme.txt",
"size": 24,
"download_url": "https://api.moonbase.ai/asset_redirects/1CLJt2vAY2dWSPDQt8AQpz?token=eyJfcmFpbHMiOnsiZGF0YSI6eyJpZCI6IjFDTEp0MnZBWTJkV1NQRFF0OEFRcHoiLCJibG9iX2lkIjoiMUNMSnQydkFIZVJ0WGZqNEJxNXBpRCIsImNyZWF0ZWRfYXQiOiIyMDI1LTAyLTE3VDE2OjAwOjAwLjAwMFoiLCJuYW1lIjoiYXR0YWNobWVudHMiLCJyZWNvcmRfaWQiOiIxQ0xKdDJ2NWFOZDhHNVNHekVhZVZVIiwicmVjb3JkX3R5cGUiOiJNZXNzYWdlIn0sImV4cCI6IjIwMjUtMDItMTdUMTc6MDA6MDAuMDAwWiIsInB1ciI6InJlZGlyZWN0In19--5d7d52ce87afcd22c2dd88a5a6b1c2822764b32b",
"created_at": "2025-02-17T16:00:00.000Z"
}{
"id": "1CLJt2vAY2dWSPDQt8AQpz",
"type": "message_attachment",
"filename": "readme.txt",
"size": 24,
"download_url": "https://api.moonbase.ai/asset_redirects/1CLJt2vAY2dWSPDQt8AQpz?token=eyJfcmFpbHMiOnsiZGF0YSI6eyJpZCI6IjFDTEp0MnZBWTJkV1NQRFF0OEFRcHoiLCJibG9iX2lkIjoiMUNMSnQydkFIZVJ0WGZqNEJxNXBpRCIsImNyZWF0ZWRfYXQiOiIyMDI1LTAyLTE3VDE2OjAwOjAwLjAwMFoiLCJuYW1lIjoiYXR0YWNobWVudHMiLCJyZWNvcmRfaWQiOiIxQ0xKdDJ2NWFOZDhHNVNHekVhZVZVIiwicmVjb3JkX3R5cGUiOiJNZXNzYWdlIn0sImV4cCI6IjIwMjUtMDItMTdUMTc6MDA6MDAuMDAwWiIsInB1ciI6InJlZGlyZWN0In19--5d7d52ce87afcd22c2dd88a5a6b1c2822764b32b",
"created_at": "2025-02-17T16:00:00.000Z"
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "400",
"title": "Bad Request",
"detail": "Provide either a 'file' (binary upload) or 'file_id' (library file ID)."
}
]
}{
"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": "404",
"title": "Not Found"
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "422",
"title": "Unprocessable Entity",
"detail": "Attachments can only be managed on draft messages."
}
]
}{
"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."
}
]
}Messages
Add an attachment
Add an attachment to a draft message. You can send either a multipart/form-data request with the raw file content, or a JSON request with a file ID.
POST
/
inbox_messages
/
{inbox_message_id}
/
attachments
JavaScript
import fs from 'fs';
import Moonbase from '@moonbaseai/sdk';
const client = new Moonbase({
apiKey: process.env['MOONBASE_API_KEY'], // This is the default and can be omitted
});
const messageAttachment = await client.inboxMessages.attachments.create('inbox_message_id');
console.log(messageAttachment.id);require "moonbase"
moonbase = Moonbase::Client.new(api_key: "My API Key")
message_attachment = moonbase.inbox_messages.attachments.create("inbox_message_id")
puts(message_attachment)import os
from moonbase import Moonbase
client = Moonbase(
api_key=os.environ.get("MOONBASE_API_KEY"), # This is the default and can be omitted
)
message_attachment = client.inbox_messages.attachments.create(
inbox_message_id="inbox_message_id",
)
print(message_attachment.id)package main
import (
"context"
"fmt"
"github.com/moonbaseai/moonbase-sdk-go"
"github.com/moonbaseai/moonbase-sdk-go/option"
)
func main() {
client := moonbase.NewClient(
option.WithAPIKey("My API Key"),
)
messageAttachment, err := client.InboxMessages.Attachments.New(
context.TODO(),
"inbox_message_id",
moonbase.InboxMessageAttachmentNewParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", messageAttachment.ID)
}
curl --request POST \
--url https://api.moonbase.ai/v0/inbox_messages/{inbox_message_id}/attachments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file='@example-file' \
--form 'file_id=<string>'{
"id": "1CLJt2vAY2dWSPDQt8AQpz",
"type": "message_attachment",
"filename": "readme.txt",
"size": 24,
"download_url": "https://api.moonbase.ai/asset_redirects/1CLJt2vAY2dWSPDQt8AQpz?token=eyJfcmFpbHMiOnsiZGF0YSI6eyJpZCI6IjFDTEp0MnZBWTJkV1NQRFF0OEFRcHoiLCJibG9iX2lkIjoiMUNMSnQydkFIZVJ0WGZqNEJxNXBpRCIsImNyZWF0ZWRfYXQiOiIyMDI1LTAyLTE3VDE2OjAwOjAwLjAwMFoiLCJuYW1lIjoiYXR0YWNobWVudHMiLCJyZWNvcmRfaWQiOiIxQ0xKdDJ2NWFOZDhHNVNHekVhZVZVIiwicmVjb3JkX3R5cGUiOiJNZXNzYWdlIn0sImV4cCI6IjIwMjUtMDItMTdUMTc6MDA6MDAuMDAwWiIsInB1ciI6InJlZGlyZWN0In19--5d7d52ce87afcd22c2dd88a5a6b1c2822764b32b",
"created_at": "2025-02-17T16:00:00.000Z"
}{
"id": "1CLJt2vAY2dWSPDQt8AQpz",
"type": "message_attachment",
"filename": "readme.txt",
"size": 24,
"download_url": "https://api.moonbase.ai/asset_redirects/1CLJt2vAY2dWSPDQt8AQpz?token=eyJfcmFpbHMiOnsiZGF0YSI6eyJpZCI6IjFDTEp0MnZBWTJkV1NQRFF0OEFRcHoiLCJibG9iX2lkIjoiMUNMSnQydkFIZVJ0WGZqNEJxNXBpRCIsImNyZWF0ZWRfYXQiOiIyMDI1LTAyLTE3VDE2OjAwOjAwLjAwMFoiLCJuYW1lIjoiYXR0YWNobWVudHMiLCJyZWNvcmRfaWQiOiIxQ0xKdDJ2NWFOZDhHNVNHekVhZVZVIiwicmVjb3JkX3R5cGUiOiJNZXNzYWdlIn0sImV4cCI6IjIwMjUtMDItMTdUMTc6MDA6MDAuMDAwWiIsInB1ciI6InJlZGlyZWN0In19--5d7d52ce87afcd22c2dd88a5a6b1c2822764b32b",
"created_at": "2025-02-17T16:00:00.000Z"
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "400",
"title": "Bad Request",
"detail": "Provide either a 'file' (binary upload) or 'file_id' (library file ID)."
}
]
}{
"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": "404",
"title": "Not Found"
}
]
}{
"type": "errors",
"errors": [
{
"type": "error",
"status": "422",
"title": "Unprocessable Entity",
"detail": "Attachments can only be managed on draft messages."
}
]
}{
"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.
Path Parameters
The ID of the Message.
Response
The Attachment object represents a file attached to a message. You can download the file content via the download_url.
String representing the object’s type. Always message_attachment for this object.
Allowed value:
"message_attachment"Unique identifier for the object.
The original name of the uploaded file, including its extension.
The size of the file in bytes.
A temporary, signed URL to download the file content. The URL expires after one hour.
Time at which the object was created, as an ISO 8601 timestamp in UTC.
⌘I

