Documentation Index
Fetch the complete documentation index at: https://mintlify.com/photon-hq/advanced-imessage-kit/llms.txt
Use this file to discover all available pages before exploring further.
Method Signature
async sendAttachment(options: SendAttachmentOptions): Promise<MessageResponse>
Send a file attachment to an iMessage conversation. Supports any file type that iMessage can handle, including images, videos, documents, and more.
Parameters
options
SendAttachmentOptions
required
Configuration object for sending the attachmentShow SendAttachmentOptions
The GUID of the chat to send the attachment to
Absolute path to the file to send
Optional custom filename. If not provided, uses the basename of filePath
If true, sends the attachment as an audio message with special formatting. See Audio Messages for details GUID of a message to reply to. When set, the attachment will be sent as a reply
Returns
The sent message object containing the attachment metadataShow MessageResponse properties
Unique identifier for the sent message
Temporary GUID assigned before the message is sent
The chat where the message was sent
Text content (null for attachment-only messages)
Timestamp when the message was created
Examples
Send an Image
const message = await client.attachment.sendAttachment({
chatGuid: "iMessage;+;chat123456",
filePath: "/path/to/photo.jpg"
});
console.log(`Image sent: ${message.guid}`);
Send with Custom Filename
const message = await client.attachment.sendAttachment({
chatGuid: "iMessage;+;chat123456",
filePath: "/tmp/download.pdf",
fileName: "Report-Q1-2024.pdf"
});
Send as a Reply
const message = await client.attachment.sendAttachment({
chatGuid: "iMessage;+;chat123456",
filePath: "/path/to/screenshot.png",
selectedMessageGuid: "original-message-guid"
});
Send Video
const message = await client.attachment.sendAttachment({
chatGuid: "iMessage;+;chat123456",
filePath: "/path/to/video.mp4",
fileName: "vacation.mp4"
});
Behavior
- If the specified chat doesn’t exist, it will be created automatically before sending
- The method is queued to ensure messages are sent in order
- File is read from disk and uploaded as multipart form data
- All file types supported by iMessage can be sent
Error Handling
try {
const message = await client.attachment.sendAttachment({
chatGuid: "iMessage;+;chat123456",
filePath: "/path/to/file.jpg"
});
} catch (error) {
if (error.code === 'ENOENT') {
console.error('File not found');
} else {
console.error('Failed to send attachment:', error);
}
}
See Also