<?xml version="1.0" encoding="utf-8"?>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.miek.nl" -->
<rfc version="3" ipr="trust200902" docName="draft-baum-jmap-rest-01" submissionType="IETF" category="std" xml:lang="en" xmlns:xi="http://www.w3.org/2001/XInclude" indexInclude="true">

<front>
<title abbrev="JMAP REST">JMAP REST Mapping</title><seriesInfo value="draft-baum-jmap-rest-01" stream="IETF" status="standard" name="Internet-Draft"></seriesInfo>
<author role="editor" initials="J.M." surname="Baum" fullname="Joris Baum"><organization>audriga</organization><address><postal><street>Alter Schlachthof 57</street>
<city>Karlsruhe </city>
<code>76137</code>
<country>Germany</country>
</postal><email>joris@audriga.com</email>
<uri>https://www.audriga.com</uri>
</address></author><author role="editor" initials="H.J." surname="Happel" fullname="Hans-Joerg"><organization>audriga</organization><address><postal><street>Alter Schlachthof 57</street>
<city>Karlsruhe </city>
<code>76137</code>
<country>Germany</country>
</postal><email>hans-joerg@audriga.com</email>
<uri>https://www.audriga.com</uri>
</address></author><date year="2023" month="November" day="10"></date>
<area>Applications</area>
<workgroup>JMAP</workgroup>
<keyword>jmap</keyword>
<keyword>rest</keyword>

<abstract>
<t>This document specifies a REST Mapping for JMAP endpoints to impose fewer requirements on applications compared to conventional JMAP endpoints.</t>
</abstract>

</front>

<middle>

<section anchor="introduction"><name>Introduction</name>
<t>Structured data exchange over JMAP <xref target="RFC8620"></xref> usually involves processing JMAP Request JSON payloads. This might impose unnecessary requirements for certain use cases of JMAP. Likely scenarios in which this is beneficiary are situations in which portability needs to be provided due to regulatory requirements or when migrating user data away from legacy platforms.</t>
<t>For rapid development of a JMAP API, the essential properties of the Request object can instead be implemented as a URI.</t>

<section anchor="conventions-used-in-this-document"><name>Conventions Used In This Document</name>
<t>The key words &quot;MUST&quot;, &quot;MUST NOT&quot;, &quot;REQUIRED&quot;, &quot;SHALL&quot;, &quot;SHALL
NOT&quot;, &quot;SHOULD&quot;, &quot;SHOULD NOT&quot;, &quot;RECOMMENDED&quot;, &quot;NOT RECOMMENDED&quot;,
&quot;MAY&quot;, and &quot;OPTIONAL&quot; in this document are to be interpreted as
described in BCP 14 <xref target="RFC2119"></xref> <xref target="RFC8174"></xref> when, and only when,
they appear in all capitals, as shown here.</t>
<t>The definitions of JSON keys and datatypes in the document follow
the conventions described in the core JMAP specification <xref target="RFC8620"></xref>.</t>
</section>

<section anchor="addition-to-the-capabilities-object"><name>Addition to the capabilities object</name>
<t>The capabilities object is returned as part of the JMAP Session object;
see <xref target="RFC8620"></xref>, Section 2. This document defines one additional capability URI.</t>

<section anchor="urn-ietf-params-jmap-rest"><name>urn:ietf:params:jmap:rest</name>
<t>The capability <tt>urn:ietf:params:jmap:rest</tt> being present in the &quot;capabilities&quot; property represents support for the simplified JMAP REST API.</t>
<t>The value of this property in the JMAP Session capabilities property and the
account's accountCapabilities property is an empty object.</t>
</section>
</section>

<section anchor="addition-to-the-session-resource"><name>Addition to the Session Resource</name>
<t>The JMAP Session Resource will be extended by the following property:</t>

<ul>
<li><t><strong>apiUrlRest</strong>: <tt>String</tt> The URL to use for JMAP API requests. THE URL MUST
contain the variable <tt>methodCall</tt>, the name of the method to call as defined in <xref target="RFC8620"></xref> Section 3.2. For example, Mailbox/get.</t>
<t>One MAY specify additional variables here, also those specific to a JMAP method like <tt>using</tt>, <tt>ids</tt> or <tt>accountId</tt>. Only properties that are a subset of the types <tt>String</tt>, <tt>Number</tt>, <tt>Boolean</tt> and arrays (as defined in <xref target="RFC8620"></xref> Section 1.1) can be referenced as variables.</t>
<t>All values of arrays MUST also be of a type that is a subset of <tt>String</tt>, <tt>Number</tt>, <tt>Boolean</tt> or <tt>Id</tt>. For properties that are arrays, the value is a comma-separated list of values in the array. An example property of type array is the using property: <tt>using=urn%3Aietf%3Aparams%3Ajmap%3Acontacts,urn%3Aietf%3Aparams%3Ajmap%3Acore</tt>.</t>
</li>
</ul>
<t>The required variables MAY be implemented as query parameters to avoid routing logic as a requirement.</t>
</section>
</section>

<section anchor="changes-to-structured-data-exchange"><name>Changes to structured data exchange</name>
<t>Clients make API Requests by issuing authenticated POST requests to the API resource, defined by the <em>apiUrlRest</em> property of the Session object.</t>
<t>The request typically consists of a single JSON-encoded Request object, as defined in <xref target="RFC8620"></xref> Section 3.3. Requests with a JSON body MUST be of type <tt>application/json</tt>. The response MUST be of type <tt>application/json</tt> and typically consists of a single Response object, as defined in <xref target="RFC8620"></xref> Section 3.4.</t>
<t>Properties referenced via variables in the apiUrlRest property MAY be omitted by clients in the POST request body. If all properties of a method call can be supplied as URL parameters, the <tt>methodCalls</tt> property (<xref target="RFC7540"></xref> Section 3.3) can be omitted completely in the request. Clients issuing an API request for which all properties of the request can be supplied as URL parameters MAY omit the <tt>application/json</tt> type and the whole JSON body.</t>
<t>The method call id in the Invocation object of JMAP Responses to JMAP REST requests SHOULD be set to empty string.</t>
<t>JMAP allows to batch multiple method calls in a single request by default by specifying them as multiple Invocations inside the methodCalls property. When using JMAP REST requests, this is no longer possible. Servers MAY support HTTP/2 multiplexing instead (<xref target="RFC7540"></xref> Section 5) to improve performance in that scenario.</t>
</section>

<section anchor="example-endpoint-supporting-using-and-accountid-as-url-parameters"><name>Example: Endpoint supporting using and accountId as URL Parameters</name>
<t>Example value in the Session Object:</t>

<sourcecode type="json"><![CDATA[{
  ...
  "capabilities": {
    ...,
    "urn:ietf:params:jmap:rest": {}
  },
  "apiUrlRest": "https://jmap.me/api/<methodCall>
    ?using=<using>&accountId=<accountId>"
}
]]>
</sourcecode>
<t>For the example, we chose ContactCard/get as the method call.</t>
<t>Request:</t>

<artwork><![CDATA[POST /api/ContactCard/get/?
 using=urn%3Aietf%3Aparams%3Ajmap%3Acontacts,
 urn%3Aietf%3Aparams%3Ajmap%3Acore&
 accountId=u7339402f
Host: jmap.me
Accept: application/json
]]>
</artwork>
<t>Response:</t>

<artwork><![CDATA[HTTP/2 200 OK
Content-Type: application/json
Location:
 https://jmap.me/api/ContactCard/get/?
 using=urn%3Aietf%3Aparams%3Ajmap%3Acontacts,
 urn%3Aietf%3Aparams%3Ajmap%3Acore&
 accountId=u7339402f

{
   "methodResponses" : [
      [
         "ContactCard/get",
         {
            "accountId" : "u7339402f",
            "list" : [
               {
                "id": "123-12345",
                "addressBookId": "22294",
                ...
               }
            ],
            "notFound" : [],
            "state" : "62"
         },
         ""
      ]
   ],
   "sessionState" : ""
}
]]>
</artwork>
</section>

<section anchor="security"><name>Security considerations</name>
<t>All security considerations of JMAP <xref target="RFC8620"></xref> apply to this specification.</t>
<t>The values of URL parameters SHOULD not contain sensitive data, as requested URLs are typically visible to third parties. Place sensitive data in HTTP bodies instead.</t>
</section>

<section anchor="iana-considerations"><name>IANA considerations</name>

<section anchor="jmap-capability-registration-for-rest"><name>JMAP Capability registration for &quot;rest&quot;</name>
<t>IANA is requested to register the &quot;rest&quot; JMAP Capability as follows:</t>
<t>Capability Name: urn:ietf:params:jmap:rest</t>
<t>Specification document: this document</t>
<t>Intended use: common</t>
<t>Change Controller: IETF</t>
<t>Security and privacy considerations: this document, <xref target="security"></xref>.</t>
</section>
</section>

<section anchor="acknowledgements"><name>Acknowledgements</name>
<t>Bron Gondwana, Neil Jenkins, Alexey Melnikov, Ken Murchison, Robert Stepanek and
the JMAP working group at the IETF.</t>
</section>

</middle>

<back>
<references><name>Normative References</name>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.7540.xml"/>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8620.xml"/>
</references>

</back>

</rfc>
