A discovery protocol such as Service Discovery (XEP-0030)  enables Jabber entities to query other entities regarding the features they support, but does not provide a means for the two entities to negotiate specific options related to the advertised features.
The protocol defined herein enables Jabber entities to negotiate options for specific features. These features could be negotiated between any two endpoints on the Jabber network, such as two clients, a client and a component, two components, a client and a server, or two servers. The protocol is generic enough that it can be used whenever options need to be negotiated between two Jabber entities. For examples, Stream Initiation (XEP-0095) , SI File Transfer (XEP-0096)  or Stanza Session Negotiation (XEP-0155) .
Features are negotiated through the exchange of <iq/> or <message/> stanzas containing <feature/> child elements qualified by the 'http://jabber.org/protocol/feature-neg' namespace. However, this <feature/> element is simply a wrapper for structured data encapsulated in the Data Forms (XEP-0004)  protocol. 
In order to begin a negotation, the initiator sends an <iq/> stanza of type "get" (or a <message/> stanza type "normal" - see Stanza Session Negotiation for examples) to the recipient with a single <feature/> element containing a data form of type "form" which defines the available options for one or more features. Each feature is represented as an x-data "field".
The recipient SHOULD examine each feature and the values of the options provided. In order to indicate preferred values, the recipient then SHOULD specify one value for each feature and return a data form of type "submit" to the initiator in an <iq/> stanza of type "result" (or a <message/> stanza type "normal").
The following examples show some likely scenarios for feature negotiation between entities. Further examples can be found in "using protocols", such as File Transfer.
A typical negotiation flow is shown in the following example of two entities negotiating the time and place for a meeting.
Note: If the responding entity does not want to reveal presence to the initiating entity for whatever reason then the responding entity's client SHOULD return a <service-unavailable/> error (or return no response or error whatsoever if the offer was wrapped in a <message/> stanza) - see Security Considerations.
If the responding entity does not support Feature Negotiation or does not support the specified FORM_TYPE, it SHOULD also return a <service-unavailable/> error:
If the responding entity does not support one or more of the features, it SHOULD return a <feature-not-implemented/> error, and SHOULD specify the feature(s) not implemented in the XMPP <text/> element.
If the responding entity supports none of the options offered for one or more of the features, it SHOULD return a <not-acceptable/> error, and SHOULD specify the relevant feature(s) in the XMPP <text/> element.
If at least one feature offered by an entity is subject to Feature Negotiation, the entity's response to a service discovery information request MUST include <feature var='http://jabber.org/protocol/feature-neg'/> as one of the features.
The "using protocol" (in these examples, Multi-User Chat (XEP-0045) ) SHOULD specify which features might be negotiable, either in the relevant documentation or in the entry for that feature in the service discovery features registry maintained by the XMPP Registrar . However, the initiating entity MAY also query the responding entity in order to determine which features are negotiable, as shown below.
If that feature is not negotiable, the responding entity SHOULD return a "Feature Not Implemented" error:
If that feature is negotiable, the responding entity SHOULD return an appropriate negotiation form:
The initiating entity MAY then submit a data form containing the required information.
If the responding entity responds to the initiating entity or returns an error (other than a <service-unavailable/> response to an <iq/> request), the initiating entity will effectively discover the presence of the responding entity's resource. Due care must therefore be exercised in determining how to respond (or whether to respond at all to a <message/> request). For examples, the responding entity SHOULD NOT automatically (i.e. without first asking its human user) either respond to the initiating entity's request or return a specific error unless the initiating entity is subscribing to the responding entity's presence (and the responding entity's presence is not currently "invisible" to the initiating entity). Note: There should be no need for the responding entity's client to consult its block list, since if the initiating entity is on the list then the responding entity would not receive any requests from the initiating entity anyway.
This document requires no interaction with the Internet Assigned Numbers Authority (IANA) .
In order for Jabber entities to adequately leverage Data Forms (e.g., by using machine-readable fields), it is RECOMMENDED to register standard x-data fields with the XMPP Registrar via the mechanisms defined in Field Standardization for Data Forms (XEP-0068) . Whether to do so for any given features and options shall be determined by the "using protocol".
Peter Millard, the primary author of this specification from version 0.1 through version 1.4, died on April 26, 2006. The remaining authors are thankful for Peter's work on this specification.
This document in other formats: XML PDF
This XMPP Extension Protocol is copyright © 1999 – 2020 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 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 <email@example.com> discussion list.
Discussion on other xmpp.org discussion lists might also be appropriate; see <http://xmpp.org/about/discuss.shtml> for a complete list.
Errata can be sent to <firstname.lastname@example.org>.
The following requirements keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".
6. Earlier versions of this document defined a structured data format to handle the feature negotiation workflow; versions later than 0.4 use Data Forms, i.e., the 'jabber:x:data' namespace.
8. 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/>.
9. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>.
Note: Older versions of this specification might be available at http://xmpp.org/extensions/attic/