<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc2629 version 1.6.6 (Ruby 3.0.4) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-ietf-httpapi-link-template-00" category="std" consensus="true" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.12.4 -->
  <front>
    <title abbrev="Link-Template">The Link-Template HTTP Header Field</title>
    <seriesInfo name="Internet-Draft" value="draft-ietf-httpapi-link-template-00"/>
    <author initials="M." surname="Nottingham" fullname="Mark Nottingham">
      <organization/>
      <address>
        <postal>
          <postalLine>Prahran</postalLine>
          <postalLine>Australia</postalLine>
        </postal>
        <email>mnot@mnot.net</email>
        <uri>https://www.mnot.net/</uri>
      </address>
    </author>
    <date year="2022" month="April" day="28"/>
    <area>Applications and Real-Time</area>
    <workgroup>Building Blocks for HTTP APIs</workgroup>
    <keyword>link relation</keyword>
    <abstract>
      <t>This specification defines the Link-Template HTTP header field, providing a means for describing the structure of a link between two resources, so that new links can be generated.</t>
    </abstract>
    <note removeInRFC="true">
      <name>About This Document</name>
      <t>
        The latest revision of this draft can be found at <eref target="https://ietf-wg-httpapi.github.io/link-template/draft-ietf-httpapi-link-template.html"/>.
        Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/draft-ietf-httpapi-link-template/"/>.
      </t>
      <t>
        Discussion of this document takes place on the
        Building Blocks for HTTP APIs Working Group mailing list (<eref target="mailto:httpapi@ietf.org"/>),
        which is archived at <eref target="https://mailarchive.ietf.org/arch/browse/httpapi/"/>.
      </t>
      <t>Source for this draft and an issue tracker can be found at
        <eref target="https://github.com/ietf-wg-httpapi/link-template"/>.</t>
    </note>
  </front>
  <middle>
    <section anchor="introduction">
      <name>Introduction</name>
      <t><xref target="URI-TEMPLATE"/> defines a syntax for templates that, when expanded using a set of variables, results in a URI <xref target="URI"/>.</t>
      <t>This specification defines a HTTP header field <xref target="HTTP"/> for conveying templates for links in the headers of a HTTP message. It is complimentary to the Link header field defined in <xref section="3" sectionFormat="of" target="WEB-LINKING"/>, which carries links directly.</t>
      <section anchor="notational-conventions">
        <name>Notational Conventions</name>
        <t>The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL
NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
"<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as
described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they
appear in all capitals, as shown here.</t>
        <t>This document uses the Augmented BNF defined in <xref target="HTTP"/> to specify valid protocol elements. Additionally, it uses the modified "parameter" rule from <xref target="RFC5987"/> and the "URI-Template" rule from <xref target="URI-TEMPLATE"/>.</t>
      </section>
    </section>
    <section anchor="the-link-template-header-field">
      <name>The Link-Template Header Field</name>
      <t>The Link-Template header field provides a means for serialising one or more links into HTTP message metadata. It is semantically equivalent to the Link header field defined in <xref section="3" sectionFormat="of" target="WEB-LINKING"/>, except that it uses URI Templates <xref target="URI-TEMPLATE"/> to convey the structure of links.</t>
      <sourcecode type="abnf"><![CDATA[
Link-Template  = "Link-Template" ":" #templated-link
templated-link = "<" URI-Template ">" *( ";" parameter )
]]></sourcecode>
      <t>For example:</t>
      <sourcecode type="http-message"><![CDATA[
Link-Template: </{username}>; rel="https://example.org/rel/user"
]]></sourcecode>
      <t>indicates that a resource with the relation type "https://example.org/rel/user" can be found by interpolating the "username" variable into the template given.</t>
      <t>The target for the link (as defined in <xref section="2" sectionFormat="of" target="WEB-LINKING"/>) is the result of expanding the URI Template <xref target="URI-TEMPLATE"/> (being converted to an absolute URI after expansion, if necessary).</t>
      <t>The context, relation type and target attributes for the link are determined as defined for the Link header field in <xref section="3" sectionFormat="of" target="WEB-LINKING"/>.</t>
      <t>Parameters on a templated-link have identical semantics to those of a Link header field. This includes (but is not limited to) the use of the "rel" parameter to convey the relation type, the "anchor" parameter to modify the context IRI, and so on.</t>
      <t>Likewise, the requirements for parameters on templated-links are the same as those for a Link header field; in particular, the "rel" parameter <bcp14>MUST NOT</bcp14> appear more than once, and if it does, the templated-link <bcp14>MUST</bcp14> be ignored by parsers.</t>
      <t>This specification defines additional semantics for the "var-base" parameter on templated-links; see below.</t>
      <section anchor="the-var-base-parameter">
        <name>The 'var-base' parameter</name>
        <t>When a templated-link has a 'var-base' parameter, its value conveys a URI-reference that is used as a base URI for the variable names in the URI template. This allows template variables to be globally identified, rather than specific to the context of use.</t>
        <t>Dereferencing the URI for a particular variable might lead to more information about the syntax or semantics of that variable; specification of particular formats for this information is out of scope for this document.</t>
        <t>To determine the URI for a given variable, the value given is used as a base URI in reference resolution (as specified in <xref target="URI"/>). If the resulting URI is still relative, the context of the link is used as the base URI in a further resolution; see <xref target="WEB-LINKING"/>.</t>
        <t>For example:</t>
        <sourcecode type="http-message"><![CDATA[
Link-Template: </widgets/{widget_id}>;
               rel="https://example.org/rel/widget";
               var-base="https://example.org/vars/"
]]></sourcecode>
        <t>indicates that a resource with the relation type "https://example.org/rel/widget" can be found by interpolating the "https://example.org/vars/widget_id" variable into the template given.</t>
        <t>If the current context of the message that the header appears within is "https://example.org/", the same information could be conveyed by this header field:</t>
        <sourcecode type="http-message"><![CDATA[
Link-Template: </widgets/{widget_id}>;
               rel="https://example.org/rel/widget";
               var-base="/vars/"
]]></sourcecode>
      </section>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <t>The security consideration for the Link header field in <xref target="WEB-LINKING"/> and those for URI Templates <xref target="URI-TEMPLATE"/> both apply.</t>
    </section>
    <section anchor="iana-considerations">
      <name>IANA Considerations</name>
      <t>This specification enters the "Link-Template" into the Hypertext Transfer Protocol (HTTP) Field Name Registry.</t>
      <artwork><![CDATA[
Field Name: Link-Template
Status: permanent
Specification document: [this document]
]]></artwork>
    </section>
  </middle>
  <back>
    <references>
      <name>Normative References</name>
      <reference anchor="HTTP">
        <front>
          <title>HTTP Semantics</title>
          <author fullname="Roy T. Fielding">
            <organization>Adobe</organization>
          </author>
          <author fullname="Mark Nottingham">
            <organization>Fastly</organization>
          </author>
          <author fullname="Julian Reschke">
            <organization>greenbytes GmbH</organization>
          </author>
          <date day="12" month="September" year="2021"/>
          <abstract>
            <t>   The Hypertext Transfer Protocol (HTTP) is a stateless application-
   level protocol for distributed, collaborative, hypertext information
   systems.  This document describes the overall architecture of HTTP,
   establishes common terminology, and defines aspects of the protocol
   that are shared by all versions.  In this definition are core
   protocol elements, extensibility mechanisms, and the "http" and
   "https" Uniform Resource Identifier (URI) schemes.

   This document updates RFC 3864 and obsoletes RFC 2818, RFC 7231, RFC
   7232, RFC 7233, RFC 7235, RFC 7538, RFC 7615, RFC 7694, and portions
   of RFC 7230.

            </t>
          </abstract>
        </front>
        <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-semantics-19"/>
      </reference>
      <reference anchor="URI-TEMPLATE">
        <front>
          <title>URI Template</title>
          <author fullname="J. Gregorio" initials="J." surname="Gregorio">
            <organization/>
          </author>
          <author fullname="R. Fielding" initials="R." surname="Fielding">
            <organization/>
          </author>
          <author fullname="M. Hadley" initials="M." surname="Hadley">
            <organization/>
          </author>
          <author fullname="M. Nottingham" initials="M." surname="Nottingham">
            <organization/>
          </author>
          <author fullname="D. Orchard" initials="D." surname="Orchard">
            <organization/>
          </author>
          <date month="March" year="2012"/>
          <abstract>
            <t>A URI Template is a compact sequence of characters for describing a range of Uniform Resource Identifiers through variable expansion. This specification defines the URI Template syntax and the process for expanding a URI Template into a URI reference, along with guidelines for the use of URI Templates on the Internet.   [STANDARDS-TRACK]</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="6570"/>
        <seriesInfo name="DOI" value="10.17487/RFC6570"/>
      </reference>
      <reference anchor="URI">
        <front>
          <title>Uniform Resource Identifier (URI): Generic Syntax</title>
          <author fullname="T. Berners-Lee" initials="T." surname="Berners-Lee">
            <organization/>
          </author>
          <author fullname="R. Fielding" initials="R." surname="Fielding">
            <organization/>
          </author>
          <author fullname="L. Masinter" initials="L." surname="Masinter">
            <organization/>
          </author>
          <date month="January" year="2005"/>
          <abstract>
            <t>A Uniform Resource Identifier (URI) is a compact sequence of characters that identifies an abstract or physical resource.  This specification defines the generic URI syntax and a process for resolving URI references that might be in relative form, along with guidelines and security considerations for the use of URIs on the Internet.  The URI syntax defines a grammar that is a superset of all valid URIs, allowing an implementation to parse the common components of a URI reference without knowing the scheme-specific requirements of every possible identifier.  This specification does not define a generative grammar for URIs; that task is performed by the individual specifications of each URI scheme.  [STANDARDS-TRACK]</t>
          </abstract>
        </front>
        <seriesInfo name="STD" value="66"/>
        <seriesInfo name="RFC" value="3986"/>
        <seriesInfo name="DOI" value="10.17487/RFC3986"/>
      </reference>
      <reference anchor="WEB-LINKING">
        <front>
          <title>Web Linking</title>
          <author fullname="M. Nottingham" initials="M." surname="Nottingham">
            <organization/>
          </author>
          <date month="October" year="2017"/>
          <abstract>
            <t>This specification defines a model for the relationships between resources on the Web ("links") and the type of those relationships ("link relation types").</t>
            <t>It also defines the serialisation of such links in HTTP headers with the Link header field.</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="8288"/>
        <seriesInfo name="DOI" value="10.17487/RFC8288"/>
      </reference>
      <reference anchor="RFC2119">
        <front>
          <title>Key words for use in RFCs to Indicate Requirement Levels</title>
          <author fullname="S. Bradner" initials="S." surname="Bradner">
            <organization/>
          </author>
          <date month="March" year="1997"/>
          <abstract>
            <t>In many standards track documents several words are used to signify the requirements in the specification.  These words are often capitalized. This document defines these words as they should be interpreted in IETF documents.  This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
          </abstract>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="2119"/>
        <seriesInfo name="DOI" value="10.17487/RFC2119"/>
      </reference>
      <reference anchor="RFC8174">
        <front>
          <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
          <author fullname="B. Leiba" initials="B." surname="Leiba">
            <organization/>
          </author>
          <date month="May" year="2017"/>
          <abstract>
            <t>RFC 2119 specifies common key words that may be used in protocol  specifications.  This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the  defined special meanings.</t>
          </abstract>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="8174"/>
        <seriesInfo name="DOI" value="10.17487/RFC8174"/>
      </reference>
      <reference anchor="RFC5987">
        <front>
          <title>Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters</title>
          <author fullname="J. Reschke" initials="J." surname="Reschke">
            <organization/>
          </author>
          <date month="August" year="2010"/>
          <abstract>
            <t>By default, message header field parameters in Hypertext Transfer Protocol (HTTP) messages cannot carry characters outside the ISO- 8859-1 character set.  RFC 2231 defines an encoding mechanism for use in Multipurpose Internet Mail Extensions (MIME) headers.  This document specifies an encoding suitable for use in HTTP header fields that is compatible with a profile of the encoding defined in RFC 2231.  [STANDARDS-TRACK]</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="5987"/>
        <seriesInfo name="DOI" value="10.17487/RFC5987"/>
      </reference>
    </references>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA81YbXPbuBH+zl+xZT5cfGNJjpO7OPJd5pTEuWjqtzrKZG5u
bjoQCUkYUwQLgFZUj/Nb+lv6y/osQFKkpCbptB96H2IRwC52n919dnG9Xi9y
ymVySPFkIelc5be9iVwWmXCS3k0m1/ROilQaeqtklsaRmE6NvMPpzsk4SvDv
XJv1kKxLoyjVSS6W0JoaMXM9Jd2st3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