A chat participant might want to retract a message which they've already sent out, for example if they've mistakenly sent it to the wrong recipient or groupchat.
Due to the federated and extensible nature of XMPP it's not possible to remove a message with full certainty and a retraction can only be considered an unenforceable request for such removal. Clients which don't support message retraction are not obligated to enforce the request and people could have seen or copied the message contents already.
If a client implements message retractions, it MUST specify the 'urn:xmpp:message-retract:1' feature in its service discovery information features as specified in Service Discovery (XEP-0030) [1] and the Entity Capabilities profile specified in Entity Capabilities (XEP-0115) [2].
Similarly, a server that is aware of message retractions and will therefore ensure that they're archived for later retrieval (e.g.via Message Archive Management (XEP-0313) [3]), MUST also advertise the 'urn:xmpp:message-retract:1' feature.
<iq type='get'
from='romeo@montague.example/orchard'
to='juliet@capulet.example/balcony'
id='info1'>
<query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
<iq type='result'
to='romeo@montague.example/orchard'
from='juliet@capulet.example/balcony'
id='info1'>
<query xmlns='http://jabber.org/protocol/disco#info'>
...
<feature var='urn:xmpp:message-retract:1'/>
...
</query>
</iq>A client, server or other service (for example a Multi-User Chat (XEP-0045) [4] service) MAY enforce a time limit on message retractions, meaning that it will only honour a retraction request that it receives within a certain amount of time after the original message was sent. An entity which enforces such a limit SHOULD advertise it in its service discovery information response, by including a Service Discovery Extensions (XEP-0128) [5] data form with a FORM_TYPE of 'urn:xmpp:message-retract:1' and a 'max-age' field, the value of which MUST be the limit in seconds.
<iq type='result'
to='romeo@montague.example/orchard'
from='muc.capulet.example'
id='info2'>
<query xmlns='http://jabber.org/protocol/disco#info'>
...
<feature var='urn:xmpp:message-retract:1'/>
...
<x xmlns='jabber:x:data' type='result'>
<field var='FORM_TYPE' type='hidden'>
<value>urn:xmpp:message-retract:1</value>
</field>
<field var='max-age'>
<value>1800</value>
</field>
</x>
</query>
</iq>Consider a situation where a user sends a message to the wrong recipient:
<message type='chat' to='lord@capulet.example' id='wrong-recipient-1'> <body>Have not saints lips, and holy palmers too?</body> </message>
The author notices that the message was sent to the wrong recipient and indicates to their client that it should be retracted.
The client sends out a retraction message and uses the 'id' attribute of the <message> element in the original message to indicate that it should be removed.
A <retract/> element in a retraction message MUST include this 'id' attribute. Other specifications MAY embed the <retract/> element in other contexts in which the message to be retracted is identified by other means, in which case the 'id' attribute may be omitted (see for example the moderation request in Message Moderation (XEP-0425) [6]).
In the case of a group chat message, for example Multi-User Chat (XEP-0045) [4], instead of the message ID, the XEP-0359 stanza ID that was assigned by the group chat SHOULD be used.
<message type='chat' to='lord@capulet.example' id='retract-message-1'> <retract id="wrong-recipient-1" xmlns='urn:xmpp:message-retract:1'/> <fallback xmlns="urn:xmpp:fallback:0" for='urn:xmpp:message-retract:1'/> <body>/me retracted a previous message, but it's unsupported by your client.</body> <store xmlns="urn:xmpp:hints"/> </message>
A sender MAY include fallback text in the <body/>, so that clients that don't support this specification can indicate that there was an intent to retract. However, the fallback text can't tell the recipient which message was meant to be retracted and it might be in a language the recipient doesn't understand.
When a <body/> is included, it SHOULD be marked with a Fallback Indication (XEP-0428) [7] <fallback/> element with a 'for' attribute set to 'urn:xmpp:message-retract:1', to indicate that it merely serves as a fallback. The fallback text is intentionally generic and SHOULD NOT identify or repeat the contents of the retracted message, since doing so would undermine the purpose of the retraction.
Whether or not a <body/> is included, the sender SHOULD include a Message Processing Hints (XEP-0334) [8] <store/> hint, to ensure that the retraction is archived even by services that are unaware of this specification.
The <retract/> element MAY contain a <reason/> child element, qualified by the 'urn:xmpp:message-retract:1' namespace, with human-readable text explaining why the message was retracted. A receiving client MAY display this reason to the user, subject to the rules in the Business Rules section.
<message type='chat' to='lord@capulet.example' id='retract-message-2'>
<retract id="wrong-recipient-1" xmlns='urn:xmpp:message-retract:1'>
<reason>Sent to the wrong person</reason>
</retract>
<fallback xmlns="urn:xmpp:fallback:0" for='urn:xmpp:message-retract:1'/>
<body>/me retracted a previous message, but it's unsupported by your client.</body>
<store xmlns="urn:xmpp:hints"/>
</message>It might be desirable to remove the retracted message from a Message Archive Management (XEP-0313) [3] service, while still recording the fact that it once existed, in order to aid clients in synchronizing their archives. To do this, the archiving service MAY replace the retracted message contents with a 'tombstone'.
A service which supports tombstones MUST advertise the 'urn:xmpp:message-retract:1#tombstone' feature in its Service Discovery responses.
<iq type='get'
from='romeo@montague.example/orchard'
to='romeo@montague.example'
id='info1'>
<query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
<iq type='result'
to='romeo@montague.example/orchard'
from='romeo@montague.example'
id='info1'>
<query xmlns='http://jabber.org/protocol/disco#info'>
...
<feature var='urn:xmpp:message-retract:1#tombstone'/>
...
</query>
</iq>When replacing the original message with a tombstone, the original contents (i.e. the <body/> and any related elements which might leak information about the original message) get replaced with a <retracted/> element which MUST include an 'id' attribute that's set to the value of the retraction's <message/> element's 'id' attribute, so that clients can match the tombstone to the retraction (which MUST also be stored in the archive).
The <retracted/> element SHOULD also include a 'stamp' attribute indicating the time at which the retraction took place.
If the retraction contained a <reason/> element, the archiving service SHOULD copy it into the <retracted/> element of the tombstone.
As with other XEP-0313 archived messages, the Delayed Delivery (XEP-0203) [9] <delay/> element is used to indicate when the original message was received.
<message id='aeb213' to='lord@capulet.example/chamber'>
<result xmlns='urn:xmpp:mam:2' queryid='f27' id='stanza-id-1'>
<forwarded xmlns='urn:xmpp:forward:0'>
<delay xmlns='urn:xmpp:delay' stamp='2019-09-20T23:08:25Z'/>
<message type='chat' from='romeo@montague.example' to='lord@capulet.example' id='wrong-recipient-1'>
<retracted stamp='2019-09-20T23:09:32Z' xmlns='urn:xmpp:message-retract:1' id='retract-message-1'/>
</message>
</forwarded>
</result>
</message>If the retraction included a <reason/>, as in the second retraction example above, the tombstone contains a copy of it.
<message id='aeb215' to='lord@capulet.example/chamber'>
<result xmlns='urn:xmpp:mam:2' queryid='f27' id='stanza-id-1'>
<forwarded xmlns='urn:xmpp:forward:0'>
<delay xmlns='urn:xmpp:delay' stamp='2019-09-20T23:08:25Z'/>
<message type='chat' from='romeo@montague.example' to='lord@capulet.example' id='wrong-recipient-1'>
<retracted stamp='2019-09-20T23:09:32Z' xmlns='urn:xmpp:message-retract:1' id='retract-message-2'>
<reason>Sent to the wrong person</reason>
</retracted>
</message>
</forwarded>
</result>
</message>When a retracted message has been corrected, as described in Last Message Correction (XEP-0308) [10], the archiving service SHOULD replace the original message and each of its corrections with a tombstone, all with the same 'id' on the <retracted/> element. The tombstone of a correction SHOULD keep its <replace/> element. This element contains only the 'id' of the original message and therefore doesn't leak information about it, while it lets clients tell which tombstone is the original message and which are corrections of it, so that they can show a single retracted message instead of one for each version.
<message id='aeb214' to='lord@capulet.example/chamber'>
<result xmlns='urn:xmpp:mam:2' queryid='f27' id='stanza-id-2'>
<forwarded xmlns='urn:xmpp:forward:0'>
<delay xmlns='urn:xmpp:delay' stamp='2019-09-20T23:08:40Z'/>
<message type='chat' from='romeo@montague.example' to='lord@capulet.example' id='wrong-recipient-2'>
<replace id='wrong-recipient-1' xmlns='urn:xmpp:message-correct:0'/>
<retracted stamp='2019-09-20T23:09:32Z' xmlns='urn:xmpp:message-retract:1' id='retract-message-1'/>
</message>
</forwarded>
</result>
</message>A receiving client can choose to remove the retracted message from whatever display is used for messages, from any stored history, or choose to display the fact that a message has been retracted in another way.
A MUC or other service that supports message retraction SHOULD prevent further distribution of the message by the service (e.g., by not replaying the message to new occupants joining the room, omitting the message from history archive requests where possible, or replacing the original message with a 'tombstone').
Some clients may have been offline while the retraction was issued. The archiving service therefore MUST store the retraction message, regardless of whether the original message is deleted or replaced with a tombstone. These clients will then become aware of the retraction as soon as they catch up with the archive.
A client MAY inform the user that a no-longer displayed message did previously exist and has been removed.
Supporting clients MUST set an 'id' attribute on the <message> element of outgoing messages, to make them suitable for retraction. Its value MUST be globally unique, not merely unique within the current stream, and MUST NOT be reused for other stanzas. Clients SHOULD generate it following the guidance for IDs in Unique and Stable Stanza IDs (XEP-0359) [11], that is, as a UUID as defined in RFC 4122 [12], with a value that is unpredictable and doesn't reveal any information, such as the number of messages sent.
A retraction applies to a message together with all of its corrections, as described in Last Message Correction (XEP-0308) [10]. The 'id' of the <retract/> element MUST refer to the original message (identified as described in Using the correct ID), and not to one of its corrections. A receiving entity SHOULD treat a retraction that refers to a correction as retracting the original message and all of its corrections.
The Sender MUST NOT send a retraction request for a message with non-messaging payloads, in other words, for a message that serves as a transport for protocol signalling and is not displayed as a message to the user. For example, a sender MUST NOT send a retraction for a roster item exchange request (Roster Item Exchange (XEP-0144) [13]) or a file transfer part. Conversely, a message that conveys user-visible content is considered to have a messaging payload even when that content is not contained in the <body/> element itself. For example, a Stateless file sharing (XEP-0447) [14] message, in which the <body/> merely serves as a fallback, MAY be retracted.
A retraction message's <body/> serves only as a fallback for clients that don't support this specification, and its contents are entirely under the sender's control. A sender which includes a <body/> SHOULD mark it with a Fallback Indication (XEP-0428) [7] <fallback/> element with a 'for' attribute set to 'urn:xmpp:message-retract:1' (see the Use Case section), and MUST NOT put anything in it other than a description of the retraction.
A client that supports this specification MUST NOT display the <body/> of a message containing a <retract/> element, whether or not the <body/> is marked with a XEP-0428 fallback indication. This also applies when no message matching the 'id' of the <retract/> element can be found: instead of rendering the sender-supplied fallback text, the client MAY indicate that the sender attempted to retract an unknown message.
A retraction message MAY contain a Last Message Correction (XEP-0308) [10] <replace/> element as part of its fallback (see the Use Case section). A client that supports this specification MUST process such a message only as a retraction, and MUST NOT apply it as a correction.
A retraction (that's not part of a Message Moderation (XEP-0425) [6] operation) MUST only be processed when both the original message and the retraction request are received from the same bare-JID (in a one-on-one conversation) or full-JID (in a non-anonymous MUC from Multi-User Chat (XEP-0045) [4]).
When used in a semi-anonymous MUC, the recipient client MUST check that a message retraction was sent by the author of the retracted message by checking the occupant id from Anonymous unique occupant identifiers for MUCs (XEP-0421) [15].
A client MUST NOT display the <reason/> of a retraction unless it has processed the retraction according to the rules above, that is, the retraction refers to a message the client knows of and was sent by that message's author. The reason SHOULD only be displayed in association with the retracted message (for example alongside the indication that it has been retracted), and not as a separate message. When no matching message can be found, a client which indicates that the sender attempted to retract an unknown message MUST NOT include the reason in that indication.
Before sending a retraction request, a client SHOULD determine whether any involved entity (for example the group chat service in a group chat, or the chat partner's client in a one-on-one chat) advertises a retraction time limit, as described in Discovering support, and SHOULD NOT offer retraction of a message older than the smallest advertised limit.
An entity which receives a retraction request for a message older than its advertised limit MAY ignore the request. An entity which doesn't enforce and advertise such a limit SHOULD honour retraction requests regardless of the age of the retracted message, in order to provide behaviour that's consistent across implementations.
For messages of type 'groupchat', the ID assigned to the stanza by the group chat itself must be used. This is discovered in a <stanza-id> element with a 'by' attribute that matches the bare JID of the group chat, as defined in Unique and Stable Stanza IDs (XEP-0359) [11].
If a group chat does not support Unique and Stable Stanza IDs (XEP-0359) [11], a client can still opt to include an <origin-id> element in the message stanza, which can be used to refer to the message in a retraction.
For other message types the sender should use the value of the 'id' attribute on the <message> element. See however the Security Considerations below.
The text of a <reason/> element is chosen by the entity that sent the retraction. Like the fallback body, it SHOULD NOT identify or repeat the contents of the retracted message.
There can never be a guarantee that a retracted message was never seen or otherwise distributed, and it is encouraged for clients and services when possible to inform users that no such guarantee exists.
If message retraction results in the complete removal of any record of the original message's body, for example to be replaced by a tombstone, then this could be used to hide messages that moderators might want to be notified of.
To prevent message spoofing, it's very important that the sender's JID or XEP-0421 occupant id of message retractions are checked (as explained in the Business Rules section).
The fallback <body/> of a retraction message is entirely under the sender's control, and a sender could deliberately place content in it that's unrelated to the retraction. Clients that support this specification won't display it, while non-supporting clients will display it verbatim, meaning that different recipients may see very different content for the same message. While this divergence is inherent to Fallback Indication (XEP-0428) [7] fallbacks in general, message retraction makes it easy to trigger deliberately: combined with a <retract/> element that refers to a nonexistent message, it could be used to send content which is only visible to some recipients, or which disappears without a trace on others.
For this reason, clients that support this specification don't render the <body/> of a retraction message, also when the referenced message can't be found (see the Business Rules section). The same concern applies to the <reason/> element, which is why clients only display it for retractions that have been processed (see the Business Rules section).
RFC 6120 [16] allows the 'id' attribute of a stanza to be unique only within the stream in which it's sent, and doesn't require it to be unique globally. This specification requires supporting clients to set globally unique 'id' attributes (see the Business Rules section), but clients that don't support it are under no such obligation, and might for example reuse 'id' values across streams. This means that when someone is using a supporting client, and attempts to retract a message from a different, non-supporting client, it might not be possible to uniquely identify the message being retracted, as more than one message could have the same 'id' attribute.
To mitigate this, clients can do a Service Discovery (XEP-0030) [1] request to check whether the other client advertises the 'urn:xmpp:message-retract:1' feature, and if not, they can choose to not support retraction for messages from that client, or otherwise warn the user about this limitation. However, the other client might not be online to respond to a disco request, so this is not a foolproof method.
None.
The XMPP Registrar [17] includes 'urn:xmpp:message-retract:1' in its registry of protocol namespaces (see <https://xmpp.org/registrar/namespaces.html>).
Field Standardization for Data Forms (XEP-0068) [18] defines a process for standardizing the fields used within Data Forms qualified by a particular namespace. The following field is registered for use within Service Discovery extension elements:
<form_type>
<name>urn:xmpp:message-retract:1</name>
<doc>XEP-0424</doc>
<desc>Service discovery extension fields for advertising message retraction limits</desc>
<field var='max-age'
type='text-single'
label='Maximum age in seconds of a message for which a retraction request will be honoured'/>
</form_type>If the protocol defined in this specification undergoes a revision that is not fully backwards-compatible with an older version, the XMPP Registrar shall increment the protocol version number found at the end of the XML namespaces defined herein, as described in Section 4 of XEP-0053.
<?xml version='1.0' encoding='UTF-8'?>
<xs:schema
xmlns:xs='http://www.w3.org/2001/XMLSchema'
targetNamespace='urn:xmpp:message-retract:1'
xmlns='urn:xmpp:message-retract:1'
elementFormDefault='qualified'>
<xs:element name='retract'>
<xs:complexType>
<xs:sequence>
<xs:any namespace='##other' processContents='lax' minOccurs='0' maxOccurs='unbounded'/>
<xs:sequence minOccurs='0'>
<xs:element ref='reason'/>
<xs:any namespace='##other' processContents='lax' minOccurs='0' maxOccurs='unbounded'/>
</xs:sequence>
</xs:sequence>
<xs:attribute name='id' type='xs:string' use='optional'/>
</xs:complexType>
</xs:element>
<xs:element name='retracted'>
<xs:complexType>
<xs:sequence>
<xs:any namespace='##other' processContents='lax' minOccurs='0' maxOccurs='unbounded'/>
<xs:sequence minOccurs='0'>
<xs:element ref='reason'/>
<xs:any namespace='##other' processContents='lax' minOccurs='0' maxOccurs='unbounded'/>
</xs:sequence>
</xs:sequence>
<xs:attribute name='by' type='xs:string' use='optional'/>
<xs:attribute name='id' type='xs:string' use='required'/>
<xs:attribute name='stamp' type='xs:dateTime' use='optional'/>
</xs:complexType>
</xs:element>
<xs:element name='reason' type='xs:string'/>
</xs:schema>
This document in other formats: XML PDF
This XMPP Extension Protocol is copyright © 1999 – 2024 by the XMPP Standards Foundation (XSF).
Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.
## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.
This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at <https://xmpp.org/about/xsf/ipr-policy> or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).
The HTML representation (you are looking at) is maintained by the XSF. It is based on the YAML CSS Framework, which is licensed under the terms of the CC-BY-SA 2.0 license.
The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 6120) and XMPP IM (RFC 6121) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.
The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.
Discussion on other xmpp.org discussion lists might also be appropriate; see <https://xmpp.org/community/> for a complete list.
Errata can be sent to <editor@xmpp.org>.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.
1. XEP-0030: Service Discovery <https://xmpp.org/extensions/xep-0030.html>.
2. XEP-0115: Entity Capabilities <https://xmpp.org/extensions/xep-0115.html>.
3. XEP-0313: Message Archive Management <https://xmpp.org/extensions/xep-0313.html>.
4. XEP-0045: Multi-User Chat <https://xmpp.org/extensions/xep-0045.html>.
5. XEP-0128: Service Discovery Extensions <https://xmpp.org/extensions/xep-0128.html>.
6. XEP-0425: Message Moderation <https://xmpp.org/extensions/xep-0425.html>.
7. XEP-0428: Fallback Indication <https://xmpp.org/extensions/xep-0428.html>.
8. XEP-0334: Message Processing Hints <https://xmpp.org/extensions/xep-0334.html>.
9. XEP-0203: Delayed Delivery <https://xmpp.org/extensions/xep-0203.html>.
10. XEP-0308: Last Message Correction <https://xmpp.org/extensions/xep-0308.html>.
11. XEP-0359: Unique and Stable Stanza IDs <https://xmpp.org/extensions/xep-0359.html>.
12. RFC 4122: A Universally Unique IDentifier (UUID) URN Namespace <http://tools.ietf.org/html/rfc4122>.
13. XEP-0144: Roster Item Exchange <https://xmpp.org/extensions/xep-0144.html>.
14. XEP-0447: Stateless file sharing <https://xmpp.org/extensions/xep-0447.html>.
15. XEP-0421: Anonymous unique occupant identifiers for MUCs <https://xmpp.org/extensions/xep-0421.html>.
16. RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core <http://tools.ietf.org/html/rfc6120>.
17. The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see <https://xmpp.org/registrar/>.
18. XEP-0068: Field Data Standardization for Data Forms <https://xmpp.org/extensions/xep-0068.html>.
Note: Older versions of this specification might be available at https://xmpp.org/extensions/attic/
Remove MUC moderation use-case which will go into a separate XEP
Fix the XEP title to be Message Retraction.
Use the term 'retraction' instead of 'deletion'. Added tombstone marker.
First draft.
@report{stout2015message-retract,
title = {Message Retraction},
author = {Stout, Lance and Brand, JC},
type = {XEP},
number = {0424},
version = {0.6.0},
institution = {XMPP Standards Foundation},
url = {https://xmpp.org/extensions/xep-0424.html},
date = {2015-07-07/2026-11-12},
}END