Method Signature
await sdk.messages.editMessage(options: {
messageGuid: string;
editedMessage: string;
backwardsCompatibilityMessage?: string;
partIndex?: number;
}): Promise<MessageResponse>
Edits the text content of a previously sent message. This feature requires iOS 16+ / macOS Ventura+ and only works with iMessage (not SMS).
Message editing only works with iMessage chats. SMS messages cannot be edited.
Parameters
The unique identifier of the message to edit
The new text content for the message
backwardsCompatibilityMessage
Fallback message text for recipients on older iOS/macOS versions that don’t support message editing.Defaults to editedMessage if not provided.Recipients on iOS 15 or earlier will see the backwardsCompatibilityMessage instead of the edit.
The part index for multi-part messages. Use 0 for single-part messages (most common).
Response
Returns a MessageResponse object with the updated message data:
The message GUID (unchanged)
Timestamp (milliseconds since epoch) when the message was last edited
Original creation timestamp (unchanged)
Whether the message was sent by you
Examples
Basic Edit
const editedMessage = await sdk.messages.editMessage({
messageGuid: "iMessage;-;[email protected];12345",
editedMessage: "Updated message text"
});
console.log(`Message edited at: ${new Date(editedMessage.dateEdited!)}`);
Edit with Backwards Compatibility
const editedMessage = await sdk.messages.editMessage({
messageGuid: "iMessage;-;[email protected];12345",
editedMessage: "Meeting is at 3pm",
backwardsCompatibilityMessage: "Meeting is at 3pm (edited)"
});
console.log("Message edited with fallback for older devices");
Edit and Track Changes
// First, get the original message
const originalMessage = await sdk.messages.getMessage(
"iMessage;-;[email protected];12345"
);
console.log(`Original: ${originalMessage.text}`);
// Edit the message
const editedMessage = await sdk.messages.editMessage({
messageGuid: originalMessage.guid,
editedMessage: "Corrected message text"
});
console.log(`Edited: ${editedMessage.text}`);
console.log(`Edit time: ${new Date(editedMessage.dateEdited!).toLocaleString()}`);
Fix a Typo
// Send a message
const message = await sdk.messages.sendMessage({
chatGuid: "iMessage;-;[email protected]",
message: "I'll be their at 5pm" // Typo: "their" instead of "there"
});
// Immediately fix the typo
await sdk.messages.editMessage({
messageGuid: message.guid,
editedMessage: "I'll be there at 5pm"
});
console.log("Typo corrected!");
Conditional Edit Based on Age
const message = await sdk.messages.getMessage(
"iMessage;-;[email protected];12345"
);
const messageAge = Date.now() - message.dateCreated;
const fifteenMinutes = 15 * 60 * 1000;
if (messageAge < fifteenMinutes) {
await sdk.messages.editMessage({
messageGuid: message.guid,
editedMessage: "Updated information"
});
console.log("Message edited");
} else {
console.log("Message too old, sending correction as new message");
await sdk.messages.sendMessage({
chatGuid: message.chats![0].guid,
message: "Correction: Updated information",
selectedMessageGuid: message.guid // Reply to original
});
}
Error Handling
try {
const edited = await sdk.messages.editMessage({
messageGuid: "iMessage;-;[email protected];12345",
editedMessage: "Corrected text"
});
console.log("Message edited successfully");
} catch (error) {
if (error.response?.status === 400) {
console.error("Invalid message GUID or format");
} else if (error.response?.status === 404) {
console.error("Message not found");
} else if (error.response?.data?.message?.includes("not supported")) {
console.error("Editing not supported (SMS chat or old iOS version)");
} else {
console.error("Failed to edit message:", error.message);
}
}
Limitations
Message editing has several limitations:
- Only works with iMessage (not SMS/MMS)
- Requires iOS 16+ / macOS Ventura+ for both sender and recipient
- You can only edit your own messages (
isFromMe: true)
- Some message types (reactions, effects, etc.) cannot be edited
- Recipients on older versions see the
backwardsCompatibilityMessage
Edit History
Edited messages retain their original guid and dateCreated timestamp. The dateEdited field indicates when the last edit occurred. Currently, the SDK does not provide access to full edit history.
const message = await sdk.messages.getMessage(
"iMessage;-;[email protected];12345"
);
if (message.dateEdited) {
const timeSinceEdit = Date.now() - message.dateEdited;
console.log(`Message was edited ${Math.floor(timeSinceEdit / 1000)} seconds ago`);
} else {
console.log("Message has never been edited");
}