<?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-ietf-jmap-quotas-12" submissionType="IETF" category="std" xml:lang="en" xmlns:xi="http://www.w3.org/2001/XInclude" indexInclude="true" consensus="true">

<front>
<title abbrev="JMAP Quotas">JMAP for Quotas</title><seriesInfo value="draft-ietf-jmap-quotas-12" stream="IETF" status="standard" name="Internet-Draft"></seriesInfo>
<author role="editor" initials="R.C." surname="Cordier" fullname="René Cordier"><organization>Linagora Vietnam</organization><address><postal><street>5 Dien Bien Phu</street>
<city>Hanoi</city>
<code>10000</code>
<country>Vietnam</country>
</postal><email>rcordier@linagora.com</email>
<uri>https://linagora.vn</uri>
</address></author><date year="2023" month="February" day="6"></date>
<area>Applications</area>
<workgroup>JMAP Working Group</workgroup>
<keyword>JMAP</keyword>
<keyword>JSON</keyword>
<keyword>email</keyword>
<keyword>quotas</keyword>

<abstract>
<t>This document specifies a data model for handling quotas on accounts with a server using the JSON Meta Application Protocol (JMAP).</t>
</abstract>

</front>

<middle>

<section anchor="introduction"><name>Introduction</name>
<t>JMAP (<xref target="RFC8620"></xref> <u format="char-num">–</u> JSON Meta Application Protocol) is a generic protocol for synchronising data, such as mails,
calendars or contacts, between a client and a server. It is optimised for mobile and web environments, and aims
to provide a consistent interface to different data types.</t>
<t>This specification defines a data model for handling quotas over JMAP, allowing a user to obtain details about a certain quota.</t>
<t>This specification does not address quota administration, which should be handled by other means.</t>

<section anchor="notational-conventions"><name>Notational conventions</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>Type signatures, examples and property descriptions in this document follow the conventions established in section 1.1
of <xref target="RFC8620"></xref>. Data types defined in the core specification are also used in this document.</t>
</section>

<section anchor="terminology"><name>Terminology</name>
<t>This document reuses the terminology from the core JMAP specification established in section 1.6 of <xref target="RFC8620"></xref>.</t>
<t>The term Quota (when capitalized) is used to refer to the data type defined in this document
in <xref target="quota"></xref> and instance of that data type.</t>
</section>
</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.</t>
<t>This document defines one additional capability URI.</t>

<section anchor="urn-ietf-params-jmap-quota"><name>urn:ietf:params:jmap:quota</name>
<t>This represents support for the Quota data type and associated API methods. Servers supporting this specification MUST add a property called urn:ietf:params:jmap:quota to the capabilities object.</t>
<t>The value of this property is an empty object in both the JMAP session capabilities property and an account's accountCapabilities property.</t>
</section>
</section>

<section anchor="sub-types-of-the-quota-data-type"><name>Sub-types of the Quota data type</name>
<t>There are two fields within the Quota datatype which have an enumerated set of possible values.  These are:</t>

<section anchor="scope"><name>Scope</name>
<t>The <strong>Scope</strong> data type is used to represent the entities the Quota applies to. It is defined as a &quot;String&quot; with values from the following set:</t>

<ul spacing="compact">
<li>account: The Quota information applies to just the client's account</li>
<li>domain: The Quota information applies to all accounts sharing this domain</li>
<li>global: The Quota information applies to all accounts belonging to the server</li>
</ul>
</section>

<section anchor="resourcetype"><name>ResourceType</name>
<t>The <strong>ResourceType</strong> data type is used to act as a unit of measure for the quota usage. It is defined as a &quot;String&quot; with values from the following set:</t>

<ul spacing="compact">
<li>count: The quota is measured in number of data type objects. For example, a quota can have a limit of 50 &quot;Mail&quot; objects.</li>
<li>octets: The quota is measured in size (in &quot;octets&quot;). For example, a quota can have a limit of 25000 &quot;octets&quot;.</li>
</ul>
</section>
</section>

<section anchor="quota"><name>Quota</name>
<t>The quota is an object that displays the limit set to an account usage. It then shows as well the current usage in regard to that limit.</t>

<section anchor="properties-of-the-quota-object"><name>Properties of the quota object</name>
<t>The quota object MUST contain the following fields:</t>

<ul spacing="compact">
<li>id: &quot;Id&quot;</li>
</ul>
<ul empty="true"><li>The unique identifier for this object.</li></ul>

<ul spacing="compact">
<li>resourceType: &quot;String&quot;</li>
</ul>
<ul empty="true"><li>The resource type of the quota as defined in <xref target="resourcetype"></xref>.</li></ul>

<ul spacing="compact">
<li>used: &quot;UnsignedInt&quot;</li>
</ul>
<ul empty="true"><li>The current usage of the defined quota, using the &quot;resourceType&quot; defined as unit of measure.
Computation of this value is handled by the server.</li></ul>

<ul spacing="compact">
<li>hardLimit: &quot;UnsignedInt&quot;</li>
</ul>
<ul empty="true"><li>The hard limit set by this quota, using the &quot;resourceType&quot; defined as unit of measure. Objects
in scope may not be created or updated if this limit is reached.</li></ul>

<ul spacing="compact">
<li>scope: &quot;String&quot;</li>
</ul>
<ul empty="true"><li>The &quot;Scope&quot; of this quota as defined in <xref target="scope"></xref>.</li></ul>

<ul spacing="compact">
<li>name: &quot;String&quot;</li>
</ul>
<ul empty="true"><li>The name of the quota object. Useful for managing quotas and using queries for searching.</li></ul>

<ul spacing="compact">
<li>types: &quot;String[]&quot;</li>
</ul>
<ul empty="true"><li>A list of all the type names as defined in the &quot;JMAP Types Names&quot; registry (e.g., Email, Calendar, etc.) to which this quota applies.
This allows to assign quotas to distinct or shared data types.</li></ul>
<ul empty="true"><li>The server MUST filter out any types for which the client did not request the associated capability in the &quot;using&quot; section of the request.
Further, the server MUST NOT return Quota objects for which there are no types recognised by the client.</li></ul>
<t>The quota object MAY contain the following fields:</t>

<ul spacing="compact">
<li>warnLimit: &quot;UnsignedInt|null&quot;</li>
</ul>
<ul empty="true"><li>The warn limit set by this quota object, using the &quot;resourceType&quot; defined as unit of measure.
It can be used to send a warning to an entity about to reach the hard limit soon, but with no action taken yet. If set, it
SHOULD be lower than the &quot;softLimit&quot; (if present and different from null) and the &quot;hardLimit&quot;.</li></ul>

<ul spacing="compact">
<li>softLimit: &quot;UnsignedInt|null&quot;</li>
</ul>
<ul empty="true"><li>The soft limit set by this quota object, using the &quot;resourceType&quot; defined as unit of measure.
It can be used to still allow some operations, but refuse some others. What is allowed or not is up to the server. For example, it
could be used for blocking outgoing events of an entity (sending emails, creating calendar events, ...) while still receiving
incoming events (receiving emails, receiving calendars events, ...). If set, it SHOULD be higher than the &quot;warnLimit&quot;
(if present and different from null) but lower than the &quot;hardLimit&quot;.</li></ul>

<ul spacing="compact">
<li>description: &quot;String|null&quot;</li>
</ul>
<ul empty="true"><li>Arbitrary free, human-readable, description of this quota. It might be used to explain
where the different limits come from and explain the entities and data types this quota applies to. The description MUST be
encoded in UTF-8 <xref target="RFC3629"></xref> as described in <xref target="RFC8620"></xref> section 1.5, selected based on an Accept-Language header in the request
(as defined in <xref target="RFC9110"></xref>, Section 12.5.4) or out-of-band information about the user's language/locale.</li></ul>
<t>The following JMAP methods are supported.</t>
</section>

<section anchor="quota-get"><name>Quota/get</name>
<t>Standard &quot;/get&quot; method as described in <xref target="RFC8620"></xref> section 5.1. The <em>ids</em> argument may be &quot;null&quot; to fetch all Quotas of the account
at once, as demonstrated in this document in <xref target="fetching-quotas"></xref>.</t>
</section>

<section anchor="quota-changes"><name>Quota/changes</name>
<t>Standard &quot;/changes&quot; method as described in <xref target="RFC8620"></xref> section 5.2 but with one extra argument in the response:</t>

<ul spacing="compact">
<li>updatedProperties: &quot;String[]|null&quot;</li>
</ul>
<ul empty="true"><li>If only the &quot;used&quot; Quota property has changed since the old state, this
will be a list containing only that property. If the server is unable to tell if only &quot;used&quot; has changed, it
MUST be null.</li></ul>
<t>Since &quot;used&quot; frequently changes but other properties are generally only changed rarely, the server can help the client
optimise data transfer by keeping track of changes to Quota usage separate from other state changes. The
updatedProperties array may be used directly via a back-reference in a subsequent Quota/get call in the same request,
so only these properties are returned if nothing else has changed.</t>
<t>Servers MAY decide to add other properties to the list that they judge to be changing frequently.</t>
<t>This method's usage is demonstrated in this document at <xref target="requesting-latest-quota-changes"></xref>.</t>
</section>

<section anchor="quota-query"><name>Quota/query</name>
<t>This is a standard &quot;/query&quot; method as described in <xref target="RFC8620"></xref>, Section 5.5.</t>
<t>A <strong>FilterCondition</strong> object has the following properties, any of which may be included or  omitted:</t>

<ul spacing="compact">
<li>name: &quot;String&quot;</li>
</ul>
<ul empty="true"><li>The Quota <em>name</em> property contains the given string.</li></ul>

<ul spacing="compact">
<li>scope: &quot;String&quot;</li>
</ul>
<ul empty="true"><li>The Quota <em>scope</em> property must match the given value exactly.</li></ul>

<ul spacing="compact">
<li>resourceType: &quot;String&quot;</li>
</ul>
<ul empty="true"><li>The Quota <em>resourceType</em> property must match the given value exactly.</li></ul>

<ul spacing="compact">
<li>type: &quot;String&quot;</li>
</ul>
<ul empty="true"><li>The Quota <em>types</em> property contains the given value.</li></ul>
<t>A Quota object matches the FilterCondition if and only if all the given conditions
match. If zero properties are specified, it is automatically true for all objects.</t>
<t>The following Quota properties MUST be supported for sorting:</t>

<ul spacing="compact">
<li>name</li>
<li>used</li>
</ul>
</section>

<section anchor="quota-querychanges"><name>Quota/queryChanges</name>
<t>This is a standard &quot;/queryChanges&quot; method as described in <xref target="RFC8620"></xref>, Section 5.6.</t>
</section>
</section>

<section anchor="examples"><name>Examples</name>

<section anchor="fetching-quotas"><name>Fetching quotas</name>
<t>Request fetching all quotas related to an account :</t>

<artwork>[[ &quot;Quota/get&quot;, {
  &quot;accountId&quot;: &quot;u33084183&quot;,
  &quot;ids&quot;: null
}, &quot;0&quot; ]]
</artwork>
<t>With response :</t>

<artwork>[[ &quot;Quota/get&quot;, {
  &quot;accountId&quot;: &quot;u33084183&quot;,
  &quot;state&quot;: &quot;78540&quot;,
  &quot;list&quot;: [{
    &quot;id&quot;: &quot;2a06df0d-9865-4e74-a92f-74dcc814270e&quot;,
    &quot;resourceType&quot;: &quot;count&quot;,
    &quot;used&quot;: 1056,
    &quot;warnLimit&quot;: 1600,
    &quot;softLimit&quot;: 1800,
    &quot;hardLimit&quot;: 2000,
    &quot;scope&quot;: &quot;account&quot;,
    &quot;name&quot;: &quot;bob@example.com&quot;,
    &quot;description&quot;: &quot;Personal account usage. When the soft limit is reached, the user is not allowed to send mails or create contacts and calendar events anymore.&quot;,
    &quot;types&quot; : [ &quot;Mail&quot;, &quot;Calendar&quot;, &quot;Contact&quot; ]
  }, {
    &quot;id&quot;: &quot;3b06df0e-3761-4s74-a92f-74dcc963501x&quot;,
    &quot;resourceType&quot;: &quot;octets&quot;,
    ...
  }, ...],
  &quot;notFound&quot;: []
}, &quot;0&quot; ]]
</artwork>
</section>

<section anchor="requesting-latest-quota-changes"><name>Requesting latest quota changes</name>
<t>Request fetching the changes for a specific quota:</t>

<artwork>[[ &quot;Quota/changes&quot;, {
  &quot;accountId&quot;: &quot;u33084183&quot;,
  &quot;sinceState&quot;: &quot;78540&quot;,
  &quot;maxChanges&quot;: 20
}, &quot;0&quot; ],
[ &quot;Quota/get&quot;, {
  &quot;accountId&quot;: &quot;u33084183&quot;,
  &quot;#ids&quot;: {
    &quot;resultOf&quot;: &quot;0&quot;,
    &quot;name&quot;: &quot;Quota/changes&quot;,
    &quot;path&quot;: &quot;/updated&quot;
  },
  &quot;#properties&quot;: {
    &quot;resultOf&quot;: &quot;0&quot;,
    &quot;name&quot;: &quot;Quota/changes&quot;,
    &quot;path&quot;: &quot;/updatedProperties&quot;
  }
}, &quot;1&quot; ]]
</artwork>
<t>With response:</t>

<artwork>[[ &quot;Quota/changes&quot;, {
  &quot;accountId&quot;: &quot;u33084183&quot;,
  &quot;oldState&quot;: &quot;78540&quot;,
  &quot;newState&quot;: &quot;78542&quot;,
  &quot;hasMoreChanges&quot;: false,
  &quot;updatedProperties&quot;: [&quot;used&quot;],
  &quot;created&quot;: [],
  &quot;updated&quot;: [&quot;2a06df0d-9865-4e74-a92f-74dcc814270e&quot;],
  &quot;destroyed&quot;: []
}, &quot;0&quot; ],
[ &quot;Quota/get&quot;, {
  &quot;accountId&quot;: &quot;u33084183&quot;,
  &quot;state&quot;: &quot;10826&quot;,
  &quot;list&quot;: [{
    &quot;id&quot;: &quot;2a06df0d-9865-4e74-a92f-74dcc814270e&quot;,
    &quot;used&quot;: 1246
  }],
  &quot;notFound&quot;: []
}, &quot;1&quot; ]]
</artwork>
</section>
</section>

<section anchor="push"><name>Push</name>
<t>Servers MUST support the JMAP push mechanisms, as specified in <xref target="RFC8620"></xref> Section 7, to allow clients to receive
notifications when the state changes for the Quota type defined in this specification.</t>
</section>

<section anchor="security-considerations"><name>Security considerations</name>
<t>All security considerations of JMAP (<xref target="RFC8620"></xref>) apply to this specification.</t>
<t>Implementors should be careful to make sure the implementation of the extension specified in this document does not violate the site's
security policy. The resource usage of other users is likely to be considered confidential information and should not be divulged to
unauthorized persons.</t>
<t>As for any resource shared across users (for example, a quota with the &quot;domain&quot; or &quot;global&quot; scope), a user that can consume
the resource can affect the resources available to the other users. For example, a user could spam themselves with events and
make the shared resource hit the limit and unusable for others (implementors could mitigate that with some rate limiting
implementation on the server).</t>
<t>Also, revealing domain and global quota counts to all users may cause privacy leakage of other sensitive data,
or at least the existence of other sensitive data. For example, some users are part of a private list
belonging to the server, so they shouldn't know how many users are in there. But by comparing the quota count
before and after sending a message to the list, it could reveal the number of people of the list, as the
domain or global quota count would go up by the number of people subscribed. In order to limit those attacks, quotas with
&quot;domain&quot; or &quot;global&quot; scope SHOULD only be visible to server administrators and not to general users.</t>
</section>

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

<section anchor="jmap-capability-registration-for-quota"><name>JMAP Capability Registration for &quot;quota&quot;</name>
<t>IANA will register the &quot;quota&quot; JMAP Capability as follows:</t>
<t>Capability Name: &quot;urn:ietf:params:jmap:quota&quot;</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-considerations"></xref>.</t>
</section>

<section anchor="jmap-datatype-registration-for-quota"><name>JMAP Datatype Registration for &quot;Quota&quot;</name>
<t>IANA will register the &quot;Quota&quot; Data Type as folows:</t>
<t>Type Name: &quot;Quota&quot;</t>
<t>Can reference blobs: No</t>
<t>Can use for state change: Yes</t>
<t>Capability: &quot;urn:ietf:params:jmap:quota&quot;</t>
<t>Reference: this document</t>
</section>
</section>

<section anchor="acknowledgements"><name>Acknowledgements</name>
<t>Thank you to Michael Bailly, that co-wrote the first draft version of this document, before deciding to turn to other matters.</t>
<t>Thank you to Benoit Tellier for his constant help and support on writing this document.</t>
<t>Thank you to Raphael Ouazana for sharing his own experience on how to write a RFC after finalizing his own document, the <xref target="RFC9007"></xref>.</t>
<t>Thank you to Bron Gondwana, Neil Jenkins, Alexei Melnikov, Joris Baum and the people from the IETF JMAP working group in general
that helped with extensive discussions, reviews and feedbacks.</t>
<t>Thank you to the people in the IETF organization that took the time to read, understand, comment and give great feedbacks
in the last rounds.</t>
</section>

</middle>

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

</back>

</rfc>
