<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>Stream Initiation</title>
  <abstract>This specification defines an XMPP protocol extension for initiating a data stream between any two XMPP entities. The protocol includes the ability to include metadata about the stream and provides a pluggable framework so that various profiles of stream initiation can be defined for particular use cases (such as file transfer).</abstract>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>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.</permissions>
<warranty>## 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. ##</warranty>
<liability>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.</liability>
<conformance>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 &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0095</number>
  <status>Deprecated</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0030</spec>
  </dependencies>
  <supersedes/>
  <supersededby><spec>XEP-0166</spec></supersededby>
  <shortname>si</shortname>
  <schemaloc>
    <url>http://www.xmpp.org/schemas/si.xsd</url>
  </schemaloc>
  <registry/>
  
  <author>
    <firstname>Thomas</firstname>
    <surname>Muldowney</surname>
    <email>temas@jabber.org</email>
    <jid>temas@jabber.org</jid>
  </author>

  
  <author>
    <firstname>Matthew</firstname>
    <surname>Miller</surname>
    <email>linuxwolf@outer-planes.net</email>
    <jid>linuxwolf@outer-planes.net</jid>
  </author>

  
  <author>
    <firstname>Ryan</firstname>
    <surname>Eatmon</surname>
    <email>reatmon@jabber.org</email>
    <jid>reatmon@jabber.org</jid>
  </author>

  <revision>
    <version>1.2</version>
    <date>2017-11-29</date>
    <initials>XEP Editor (ssw)</initials>
    <remark>Deprecated by vote of the council.</remark>
  </revision>
  <revision>
    <version>1.1</version>
    <date>2004-04-13</date>
    <initials>psa</initials>
    <remark>More fully defined the XMPP Registrar considerations.</remark>
  </revision>
  <revision>
    <version>1.0</version>
    <date>2003-10-17</date>
    <initials>psa</initials>
    <remark>Per a vote of the Jabber Council, advanced status to Draft.</remark>
  </revision>
  <revision>
    <version>0.6</version>
    <date>2003-07-15</date>
    <initials>rwe</initials>
    <remark>Stream ids not needed on return results.  Moved s5b, ibb, and url-data to the actual namespaces of the stream protocols.</remark>
  </revision>
  <revision>
    <version>0.5</version>
    <date>2003-07-06</date>
    <initials>lw</initials>
    <remark>Removed signalling; Strengthened the profile definition requirements; Allowed for optional feature negotiation under certain circumstances</remark>
  </revision>
  <revision>
    <version>0.4</version>
    <date>2003-06-30</date>
    <initials>lw</initials>
    <remark>Actually added XML schemas; Added clarifications/requirements for stream interaction.; Fixed various typos and inconsistencies</remark>
  </revision>
  <revision>
    <version>0.3</version>
    <date>2003-06-30</date>
    <initials>lw</initials>
    <remark>
      Added XML schemas; Added XMPP-style error conditions; Added signal/notification support; Moderate reorganization to accommodate changes
    </remark>
  </revision>
  <revision>
    <version>0.2</version>
    <date>2003-06-23</date>
    <initials>tjm</initials>
    <remark>
      Added linuxwolf as an author (should have been there from the start), form
      uses stream-method as the field var, clarified the stream interaction.
    </remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2003-06-10</date>
    <initials>tjm</initials>
    <remark>Initial version.</remark>
  </revision>
</header>
<section1 topic="Introduction" anchor="intro">
  <p>As the Jabber protocols are extended beyond basic messaging and presence, the need has arisen for a generic protocol that can be used to negotiate content streams between any two entities. Such streams might be in-band, but more likely will be out-of-band, binary streams used in applications such as file transfer, voice chat, and video conferencing. This document provides a method for negotiating such streams, including meta-information about the intended usage of the stream.</p>
</section1>
<section1 topic="Requirements" anchor="reqs">
  <ul>
    <li>The defined protocol will allow for negotiation of a common stream.</li>
    <li>The defined protocol will allow for meta-information to be sent about the stream usage.</li>
    <li>The defined protocol will not be required for stream usage.</li>
  </ul>
</section1>
<section1 topic="Use Case" anchor="usecase">
  <p>The process for stream negotiation is as follows:</p>
  <ol>
    <li>Sender discovers if Receiver implements the desired profile. [E1]</li>
    <li>Sender offers a stream initiation. [E2]</li>
    <li>Receiver accepts stream initiation.</li>
    <li>Sender and receiver prepare for using negotiated profile and stream, EUC</li>
  </ol>
  <p>Error Conditions:</p>
  <ol>
    <li>The Receiver does not support the desired profile, EUC</li>
    <li>Receiver rejects the stream initiation, EUC</li>
  </ol>
  <section2 topic="Discovery" anchor="usecase-disco">
    <p>Before a Stream Initiation is attempted the Sender should be sure that the Receiver supports both Stream Initiation and the specific profile that they wish to use.  This is typically accomplished using <span class="ref"><link url="https://xmpp.org/extensions/xep-0030.html">Service Discovery (XEP-0030)</link></span> <note>XEP-0030: Service Discovery &lt;<link url="https://xmpp.org/extensions/xep-0030.html">https://xmpp.org/extensions/xep-0030.html</link>&gt;.</note>:</p>
    <example caption="Requesting Disco Information From Receiver"><![CDATA[
<iq type='get'
    to='receiver@jabber.org/resource'
    from='sender@jabber.org/resource'
    id='info1'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
]]></example>
    <p>The Receiver advertises the "http://jabber.org/protocol/si" namespace as a feature to represent that they implement this document.  The specific profiles are also announced this way; they can be found by looking for "http://jabber.org/protocol/si/profile/profile-name". Shown in the result is a potential file transfer profile:</p>
    <example caption="Receiver Disco Information Result"><![CDATA[
<iq type='result'
    to='sender@jabber.org/resource'
    from='receiver@jabber.org/resource'
    id='info1'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    ...
    <feature var='http://jabber.org/protocol/si'/>
    <feature var='http://jabber.org/protocol/si/profile/file-transfer'/>
    ...
  </query>
</iq>
]]></example>
  </section2>
  <section2 topic="Negotiating Profile and Stream" anchor="usecase-neg">
  <p>Once support is determined, the Sender starts the negotiation with the  Receiver by sending an &lt;iq/&gt; stanza of type "set", such as in the following example from <span class="ref"><link url="https://xmpp.org/extensions/xep-0096.html">SI File Transfer (XEP-0096)</link></span> <note>XEP-0096: SI File Transfer &lt;<link url="https://xmpp.org/extensions/xep-0096.html">https://xmpp.org/extensions/xep-0096.html</link>&gt;.</note>:</p>
  <example caption="Offer Stream Initiation"><![CDATA[
<iq type='set' id='offer1' to='receiver@jabber.org/resource'>
  <si xmlns='http://jabber.org/protocol/si'
      id='a0'
      mime-type='text/plain'
      profile='http://jabber.org/protocol/si/profile/file-transfer'>
    <file xmlns='http://jabber.org/protocol/si/profile/file-transfer'
          name='test.txt'
          size='1022'>
      <desc>This is info about the file.</desc>
    </file>
    <feature xmlns='http://jabber.org/protocol/feature-neg'>
      <x xmlns='jabber:x:data' type='form'>
        <field var='stream-method' type='list-single'>
          <option><value>http://jabber.org/protocol/bytestreams</value></option>
          <option><value>jabber:iq:oob</value></option>
          <option><value>http://jabber.org/protocol/ibb</value></option>
        </field>
      </x>
    </feature>
  </si>
</iq>
]]></example>
    <p>At this point the Receiver can view the profile and other information to decide if they wish to accept the Stream Initiation. If acceptable the Receiver MUST select one of the presented stream types to use.</p>
  <example caption="Accept Stream Initiation">
    <![CDATA[
<iq type='result' to='sender@jabber.org/resource' id='offer1'>
  <si xmlns='http://jabber.org/protocol/si'>
    <feature xmlns='http://jabber.org/protocol/feature-neg'>
      <x xmlns='jabber:x:data' type='submit'>
        <field var='stream-method'>
          <value>http://jabber.org/protocol/bytestreams</value>
        </field>
      </x>
    </feature>
  </si>
</iq>
]]></example>
    <p>If the profile describes data to be sent back in the result it MUST be present as described in the profile's specification.</p>
    <example caption="Accept Stream Initiation with Profile"><![CDATA[
<iq type='result' to='sender@jabber.org/resource' id='offer1'>
  <si xmlns='http://jabber.org/protocol/si'>
    <file xmlns='http://jabber.org/protocol/si/profile/profile-name'>
      <value>returned value</value>
    </file>
    <feature xmlns='http://jabber.org/protocol/feature-neg'>
      <x xmlns='jabber:x:data' type='submit'>
        <field var='stream-method'>
          <value>http://jabber.org/protocol/bytestreams</value>
        </field>
      </x>
    </feature>
  </si>
</iq>
]]></example>
    <p>If none of the stream types are acceptable, or if the profile is not understood, the Receiver MUST reply with a "bad request" error:</p>
    <example caption="No Valid Streams"><![CDATA[
<iq type='error' to='sender@jabber.org/resource' id='offer1'>
  <error code='400' type='cancel'>
    <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
    <no-valid-streams xmlns='http://jabber.org/protocol/si'/>
  </error>
</iq>
]]></example>
    <example caption="Profile not understood"><![CDATA[
<iq type='error' to='sender@jabber.org/resource' id='offer1'>
  <error code='400' type='cancel'>
    <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
    <bad-profile xmlns='http://jabber.org/protocol/si'/>
  </error>
</iq>
]]></example>
    <p>If the Receiver rejects the request, they reply with a "forbidden" error:</p>
    <example caption="Rejecting Stream Initiation"><![CDATA[
<iq type='error' to='sender@jabber.org/resource' id='offer1'>
  <error code='403' type='cancel'>
    <forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
    <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>Offer Declined</text>
  </error>
</iq>
]]></example>
  </section2>
  <section2 topic="Preparing the Transfer" anchor="usecase-transfer">
    <p>At this point, the Sender and Receiver make any preparations necessary for the stream to be used. The exact process is specific to each protocol, and is beyond the scope of this document. This step now marks the end of SI's responsibilities.</p>
  </section2>
</section1>
<section1 topic="Formal Definition" anchor="def">
  <section2 topic="&lt;si/&gt; Root Element" anchor="def-si">
    <p>The &lt;si/&gt; element is the root element for this protocol. It is an identifiable container for all the information necessary for negotiation and signalling. It contains attributes for the identifier, intended MIME-type, and profile. The contents convey stream-negotation and profile information.</p>
    <p>The "id" attribute is an opaque identifier.  This attribute MUST be present on type='set', and MUST be a valid string. This SHOULD NOT be sent back on type='result', since the &lt;iq/&gt; "id" attribute provides the only context needed.  This value is generated by the Sender, and the same value MUST be used throughout a session when talking to the Receiver.</p>
    <p>The "mime-type" attribute identifies the MIME-type for the data across the stream. This attribute MUST be a valid MIME-type as registered with the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>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 &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note> (specifically, as listed at &lt;<link url="http://www.iana.org/assignments/media-types">http://www.iana.org/assignments/media-types</link>&gt;). During negotiation, this attribute SHOULD be present, and is otherwise not required. If not included during negotiation, its value is assumed to be "application/octet-stream".</p>
    <p>The "profile" attribute defines the SI profile in use. This value MUST be present during negotiation, and is the namespace of the profile to use.</p>
    <p>When the Sender first negotiates a Stream Initiation, all of the attributes SHOULD be present, and the id" and "profile" MUST be present. The contents MUST contain one profile, in the namespace declared in the "profile" attribute, and the feature negotiation for the stream. The feature negotiation MUST contain at least one option and use the field var "stream-method".</p>
    <p>When the Receiver accepts a Stream Initiation, the &lt;si/&gt; element SHOULD NOT possess any attributes. The selected stream MUST be in the feature negotiation for the stream. There MUST only be one selected stream.</p>
  </section2>
  <section2 topic="Error Codes" anchor="def-error">
    <p>To simplify the discussion on error conditions, this document uses the following mapping between namespace URIs and namespace prefixes<note>This mapping is provided for the purpose of simplifying this discussion, and is not intended to be used in the actual protocol.</note>.</p>
    <table caption="Namespace Mappings">
      <tr>
        <th>Prefix</th>
        <th>URI</th>
      </tr>
      <tr>
        <td>xmpp</td>
        <td>urn:ietf:params:xml:ns:xmpp-stanzas</td>
      </tr>
      <tr>
        <td>si</td>
        <td>http://jabber.org/protocol/si</td>
      </tr>
    </table>
    <p>Below are the most common errors that can result.</p>
    <table caption="Error Conditions/Codes">
      <tr>
        <th>Error Code</th>
        <th>Error Type</th>
        <th>General Condition</th>
        <th>Specific Condition</th>
        <th>Description</th>
      </tr>
      <tr>
        <td>400</td>
        <td>cancel</td>
        <td>&lt;xmpp:bad-request/&gt;</td>
        <td>&lt;si:no-valid-streams/&gt;</td>
        <td>None of the available streams are acceptable.</td>
      </tr>
      <tr>
        <td>400</td>
        <td>modify</td>
        <td>&lt;xmpp:bad-request/&gt;</td>
        <td>&lt;si:bad-profile/&gt;</td>
        <td>The profile is not understood or invalid. The profile MAY supply a profile-specific error condition.</td>
      </tr>
      <tr>
        <td>403</td>
        <td>cancel</td>
        <td>&lt;xmpp:forbidden/&gt;</td>
        <td>NONE</td>
        <td>The stream is rejected.</td>
      </tr>
    </table>
    <p>For further information about the relationship between XMPP error handling and "legacy" (HTTP-style) error codes, refer to <span class="ref"><link url="https://xmpp.org/extensions/xep-0086.html">Error Condition Mappings (XEP-0086)</link></span> <note>XEP-0086: Error Condition Mappings &lt;<link url="https://xmpp.org/extensions/xep-0086.html">https://xmpp.org/extensions/xep-0086.html</link>&gt;.</note>.</p>
  </section2>
</section1>
<section1 topic="Implementation Notes" anchor="impl">
  <section2 topic="Profiles" anchor="impl-profiles">
    <p>Stream Initiation on its own is of limited use; the Receiver almost always requires some reason for SI. Knowing this allows the Receiver to make a more educated choice about whether or not to accept the stream. This information is provided in Stream Initiation via a <em>profile</em>. A profile is a collection of information that describes the reason for and structure of the stream data, including what the data represents and what stream protocols are expected to be supported.</p>
    <p>The initial request for Stream Initiation MUST have only one profile, and this profile is in its own namespace. The profile is indicated not only by the presence of a "root" element in that particular namespace, but also be the "profile" attribute in &lt;si/&gt; The SUGGESTED format for profile namespaces is:</p>
    <code>http://jabber.org/protocol/si/profile/profile-name</code>
    <p>The information that the profile presents SHOULD be defined in an official XEP. The XEP defining the profile SHOULD contain explanations of what the profile consists of and MUST define the profile in a complete manner using DTD, Schema or another appropiate definition language.</p>
    <p>A profile SHOULD define what stream protocols MUST be supported, and MUST define what stream protocols MAY be supported. If a profile specifies only a single stream protocol that MUST be supported (even if others MAY also be supported), the "fneg" for the stream protocol may be omitted from the initial &lt;si/&gt;; the receiving entity then assumes the stream protocol that MUST be supported is the one to use.</p>
    <p>This document does not define any profiles, nor does it place any restrictions on what type of information a profile should detail. Other specifications will define profiles to be used with Stream Initiation.</p>
  </section2>
  <section2 topic="Stream Interaction" anchor="impl-stream">
    <p>While Stream Initiation is not directly required for stream usage, it does provide many benefits.  In order to fully appreciate these benefits, streams must link the Stream Initiation to the stream.  The "id" attribute transported on the &lt;si/&gt; element is intended to do this.  Once a session is fully negotiated, the value of the &lt;si/&gt; "id" attribute is used during the actual stream negotiation as the protocol's stream identifier attribute.</p>
    <p>To be compatible to this document, a stream protocol MUST define a stream identifier (typically "sid"), which MUST have a unique string representation. The stream protocol MUST be able to use any string identifier chosen during Stream Initiation, as long as the sending party does not use the same identifier more than once.</p>
  </section2>
</section1>
<section1 topic="Security Considerations" anchor="security">
  <p>
    Data security concerns are left to the profiles to define.  Wire security
    concerns are left to the stream definitions.
  </p>
</section1>
<section1 topic="IANA Considerations" anchor="iana">
  <p>
    This document uses the MIME types as recorded by the IANA, but no direct
    interaction with the IANA is necessary.
  </p>
</section1>
<section1 topic="XMPP Registrar Considerations" anchor="registrar">
  <section2 topic="Protocol Namespaces" anchor="registrar-ns">
    <p>The <span class="ref"><link url="https://xmpp.org/registrar/">XMPP Registrar</link></span> <note>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 &lt;<link url="https://xmpp.org/registrar/">https://xmpp.org/registrar/</link>&gt;.</note> includes the 'http://jabber.org/protocol/si' namespace in its registry of protocol namespaces.</p>
  </section2>
  <section2 topic="Registries" anchor="registrar-reg">
    <section3 topic="Profiles Registry" anchor="registrar-reg-profiles">
      <p>The XMPP Registrar shall maintain a registry of stream initiation profiles, located at &lt;<link url="https://xmpp.org/registrar/si-profiles.html">https://xmpp.org/registrar/si-profiles.html</link>&gt;. Any such profile defined in a XMPP Extension Protocol specification MUST be submitted to the XMPP Registrar; profiles defined in non-standard protocol extensions SHOULD be submitted to the XMPP Registrar.</p>
      <section4 topic="Process" anchor="registrar-reg-profiles-process">
        <p>In order to submit new values to this registry, the registrant shall define an XML fragment of the following form and either include it in the relevant XMPP Extension Protocol or send it to the email address &lt;registrar@xmpp.org&gt;:</p>
        <code><![CDATA[
<profile>
  <name>The profile name</name>
  <doc>The specification that defines the profile</doc>
  <desc>A natural-language description of the profile</desc>
</profile>
]]></code>
      </section4>
    </section3>
  </section2>
</section1>
<section1 topic="XML Schema" anchor="schema">
  <code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='http://jabber.org/protocol/si'
    xmlns='http://jabber.org/protocol/si'
    elementFormDefault='qualified'>

  <xs:import
      namespace='http://jabber.org/protocol/feature-neg'
      schemaLocation='http://www.xmpp.org/schemas/feature-neg.xsd'/>

  <xs:annotation>
    <xs:documentation>
      The protocol documented by this schema is defined in
      XEP-0095: http://www.xmpp.org/extensions/xep-0095.html
    </xs:documentation>
  </xs:annotation>

  <xs:element name='si'>
    <xs:annotation>
      <xs:documentation>
        This is the root content element. All other elements in
        this namespace are for communicating error information.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence xmlns:fneg='http://jabber.org/protocol/feature-neg'>
        <xs:any namespace='##other' minOccurs='0'/>
        <xs:element ref='fneg:feature'/>
      </xs:sequence>
      <xs:attribute name='id' type='xs:string' use='optional'/>
      <xs:attribute name='mime-type' type='xs:string' use='optional'/>
      <xs:attribute name='profile' type='xs:string' use='optional'/>
    </xs:complexType>
  </xs:element>

  <xs:element name='bad-profile' type='empty'/>
  <xs:element name='no-valid-streams' type='empty'/>

  <xs:simpleType name='empty'>
    <xs:restriction base='xs:string'>
      <xs:enumeration value=''/>
    </xs:restriction>
  </xs:simpleType>

</xs:schema>
]]></code>
</section1>
</xep>
