<?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-rfc version 1.7.5 (Ruby 3.2.2) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-ietf-httpapi-link-template-03" category="std" consensus="true" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.19.1 -->
  <front>
    <title abbrev="Link-Template">The Link-Template HTTP Header Field</title>
    <seriesInfo name="Internet-Draft" value="draft-ietf-httpapi-link-template-03"/>
    <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="2024" month="January" day="31"/>
    <area>Applications and Real-Time</area>
    <workgroup>Building Blocks for HTTP APIs</workgroup>
    <keyword>link relation</keyword>
    <abstract>
      <?line 44?>

<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/"/>.
        Subscribe at <eref target="https://www.ietf.org/mailman/listinfo/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>
    <?line 49?>

<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>
        <?line -18?>

<t>This specification uses the following terms from <xref target="STRUCTURED-FIELDS"/>: List, String, Display String, Parameter.</t>
      </section>
    </section>
    <section anchor="the-link-template-header-field">
      <name>The Link-Template Header Field</name>
      <t>The Link-Template header field is a Structured Field <xref target="STRUCTURED-FIELDS"/> that serializes 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 the link target and link anchor can contain URI Templates <xref target="URI-TEMPLATE"/>.</t>
      <t>Its value is a List of Strings. Each String is a URI Template, and Parameters on it carry associated metadata.</t>
      <t>For example:</t>
      <sourcecode type="http-message"><![CDATA[
Link-Template: "/{username}"; rel="item"
]]></sourcecode>
      <t>indicates that a resource with the relation type "item" for a given "username" can be found by expanding the "username" variable into the template given.</t>
      <t>The link target (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 link context and link relation type for the link (as defined in <xref section="2" sectionFormat="of" target="WEB-LINKING"/>) are conveyed using the "anchor" and "rel" Parameters, as they are for the Link header field in <xref section="3" sectionFormat="of" target="WEB-LINKING"/>. Their values <bcp14>MUST</bcp14> be Strings.</t>
      <t>However, the "anchor" Parameter <bcp14>MAY</bcp14> contain a URI Template. For example:</t>
      <sourcecode type="http-message"><![CDATA[
Link-Template: "/books/{book_id}/author";
               rel="author"; anchor="#{book_id}"
]]></sourcecode>
      <t>Here, the link to the author for a particular book in a list of books can be found by following the link template.</t>
      <t>This specification defines additional semantics for the "var-base" Parameter on templated links; see below.</t>
      <t>The link's target attributes (as defined in <xref section="2.2" sectionFormat="of" target="WEB-LINKING"/>) are conveyed using other Parameters, in a manner similar to the Link header field. These Parameter values <bcp14>MUST</bcp14> be Strings, unless they contain non-ASCII characters, in which case they <bcp14>MUST</bcp14> be Display Strings. Note that some target attribute names will not serialise as Structure Field Parameter keys (see <xref section="3.1.2" sectionFormat="of" target="STRUCTURED-FIELDS"/>).</t>
      <t>For example:</t>
      <sourcecode type="http-message"><![CDATA[
Link-Template: "/author"; rel="author";
               title=%"Bj%c3%b6rn J%c3%a4rnsida"
]]></sourcecode>
      <t>Implementations <bcp14>MUST</bcp14> support all levels of template defined by <xref target="URI-TEMPLATE"/> in the link String and the anchor Parameter.</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 expanding 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>
      <ul spacing="normal">
        <li>
          <t>Field Name: Link-Template</t>
        </li>
        <li>
          <t>Status: permanent</t>
        </li>
        <li>
          <t>Specification document: [this document]</t>
        </li>
      </ul>
    </section>
  </middle>
  <back>
    <references anchor="sec-normative-references">
      <name>Normative References</name>
      <reference anchor="HTTP">
        <front>
          <title>HTTP Semantics</title>
          <author fullname="R. Fielding" initials="R." role="editor" surname="Fielding"/>
          <author fullname="M. Nottingham" initials="M." role="editor" surname="Nottingham"/>
          <author fullname="J. Reschke" initials="J." role="editor" surname="Reschke"/>
          <date month="June" year="2022"/>
          <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.</t>
            <t>This document updates RFC 3864 and obsoletes RFCs 2818, 7231, 7232, 7233, 7235, 7538, 7615, 7694, and portions of 7230.</t>
          </abstract>
        </front>
        <seriesInfo name="STD" value="97"/>
        <seriesInfo name="RFC" value="9110"/>
        <seriesInfo name="DOI" value="10.17487/RFC9110"/>
      </reference>
      <reference anchor="URI-TEMPLATE">
        <front>
          <title>URI Template</title>
          <author fullname="J. Gregorio" initials="J." surname="Gregorio"/>
          <author fullname="R. Fielding" initials="R." surname="Fielding"/>
          <author fullname="M. Hadley" initials="M." surname="Hadley"/>
          <author fullname="M. Nottingham" initials="M." surname="Nottingham"/>
          <author fullname="D. Orchard" initials="D." surname="Orchard"/>
          <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"/>
          <author fullname="R. Fielding" initials="R." surname="Fielding"/>
          <author fullname="L. Masinter" initials="L." surname="Masinter"/>
          <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"/>
          <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="STRUCTURED-FIELDS">
        <front>
          <title>Structured Field Values for HTTP</title>
          <author fullname="Mark Nottingham" initials="M." surname="Nottingham">
            <organization>Cloudflare</organization>
          </author>
          <author fullname="Poul-Henning Kamp" initials="P." surname="Kamp">
            <organization>The Varnish Cache Project</organization>
          </author>
          <date day="23" month="January" year="2024"/>
          <abstract>
            <t>   This document describes a set of data types and associated algorithms
   that are intended to make it easier and safer to define and handle
   HTTP header and trailer fields, known as "Structured Fields",
   "Structured Headers", or "Structured Trailers".  It is intended for
   use by specifications of new HTTP fields that wish to use a common
   syntax that is more restrictive than traditional HTTP field values.

   This document obsoletes RFC 8941.

            </t>
          </abstract>
        </front>
        <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-sfbis-05"/>
      </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"/>
          <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"/>
          <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>
    </references>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA81YbXPbNhL+zl+BYyaTpGNKcZKmjtK0VWyn1tV2fLY8mU6n
cwORkISaIngAaEX1OL/lfsv9snsWACnSUt56X84fLBLALha7zz67YJIkkZU2
FwMWj+eCHcviKhmLRZlzK9jReHzGjgTPhGZvpMizOOKTiRbXWN1ZGUcp/s+U
Xg2YsVkUZSot+AJaM82nNpHCTpO5tSUvZZKTpA2SyeOnEdQ9jbgWHGqHZZlL
KJOqMIwXGTsXPE/GcoE9lkpfzbSqSqx7Xck8k8WMvc5VemXYVGlv7vBsZOJI
lnrArK6MffL48YvHT6LoSqwgnw3cEbtvULMeeCcmm4NkMtMid3ZF0bUoKjGI
GPtCaxizq5Jc/A4noGU/kxyNL7jMMR5c8xP5qaf0jKa4Tudhygz6fVpJQ/Ja
9OplfRroT7RaGtEPOvokO5N2Xk0g7Ry/nNW+73d8Tyvp19jWPnckel5VT6qu
bP9zge3N7SKPo4hXdq40nJVgN8ZkYQbspMdOlbXwxJwv3LAHywnXV3dncExe
yD+d5wdupFTG8tw/M5awM83nmhfuPVVVYQmFQ4Re81xyNyy8nxeFsj/Rv14h
rJuotByw+ujL5bJXz/ajqFB6gW2vXaQpmgN2/mb/xe7uY7xfno+S8eHJ2fFw
fOjGn3/7XRh3r09f7D3H67vD18nx6PSX0enPbnjvyd4ehi/G55f748vzw4Pk
zejw+OBiwEbJQa/x5kSaxEzxP4qiJEkYn9BpUhtF47k0zJQildOQJiwTU1kI
w+z2/J37/J1S/u6wUqtr6aDK2ULwwmM1EybVckLDpAWbVamttGBqinUO/RNh
l0IUzC4VMsGoSqfC7DCjIMEtK8TSrTMs5QUWs5kohIYRWS+cYSGzLBd4ucdG
iJHKsIXLppubtjNvb5sDcWZWheXvnYk1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