Edit and Delete Messages

Available since SDK 0.4.0 (PROTOCOL_VERSION 3). Both edits and deletes work for E2EE and cleartext 1:1 messages. The relay never sees the new plaintext for E2EE edits, the sender re-encrypts the new content per recipient device, exactly like a new message.

Semantics

  • Edit (E2EE): client re-encrypts new plaintext per recipient device, server stores an immutable edit record and forwards it.
  • Edit (cleartext): server overwrites the stored plaintext on the original message and forwards the new content.
  • Delete FOR_EVERYONE: server records a tombstone and fans it out to recipient devices. For cleartext messages the stored plaintext is wiped server-side.
  • Delete FOR_ME: only the sender's other devices receive the tombstone; the recipient is not notified.
  • Sender ownership enforced: only the original sender can edit or delete a message.
  • Usage: each edit and each FOR_EVERYONE delete counts as one MESSAGE usage record toward your monthly quota.
  • Webhooks: emits message.edited and message.deleted events.
  • Offline: pending edits and tombstones are replayed on reconnect.
// Edit an E2EE message
const { editId } = await client.editMessage(originalMessageId, toUserId, 'New text');

// Edit a cleartext message
await client.editCleartextMessage(originalMessageId, toUserId, 'Updated');

// Delete for everyone
await client.deleteMessage(originalMessageId, toUserId, 'FOR_EVERYONE');

// Delete for me only (sender's other devices receive the tombstone)
await client.deleteMessage(originalMessageId, toUserId, 'FOR_ME');

// Listen for inbound edits and deletes
client.onMessageEdit((edit) => {
  console.log('edited', edit.originalMessageId, edit.text);
});
client.onMessageDelete((del) => {
  console.log('deleted', del.originalMessageId, del.scope);
});

Webhook events

Configure a webhook in the dashboard to receive server-side notifications:

  • message.edited, fired when an edit is accepted by the relay (E2EE or cleartext).
  • message.deleted, fired when a delete is accepted, includes scope.