blob: 322a6ef2512c38950d67e7e12f84b9972a55c5b4 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Generated by Apache Maven Doxia at 2021-09-26 -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Apache James Project &#x2013; Web administration for JAMES</title>
<style type="text/css" media="all">
@import url("../css/james.css");
@import url("../css/maven-base.css");
@import url("../css/maven-theme.css");
@import url("../css/site.css");
@import url("../js/jquery/css/custom-theme/jquery-ui-1.8.5.custom.css");
@import url("../js/jquery/css/print.css");
@import url("../js/fancybox/jquery.fancybox-1.3.4.css");
</style>
<script type="text/javascript" src="../js/jquery/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="../js/jquery/js/jquery-ui-1.8.5.custom.min.js"></script>
<script type="text/javascript" src="../js/fancybox/jquery.fancybox-1.3.4.js"></script>
<link rel="stylesheet" href="../css/print.css" type="text/css" media="print" />
<meta name="Date-Revision-yyyymmdd" content="20210926" />
<meta http-equiv="Content-Language" content="en" />
<!-- Google Analytics -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1384591-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script').item(0); s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body class="composite">
<div id="banner">
<a href="../index.html" id="bannerLeft" title="james-logo.png">
<img src="../images/logos/james-logo.png" alt="James Project" />
</a>
<a href="https://www.apache.org/index.html" id="bannerRight">
<img src="images/logos/asf_logo_small.png" alt="The Apache Software Foundation" />
</a>
<div class="clear">
<hr/>
</div>
</div>
<div id="breadcrumbs">
<div class="xleft">
<span id="publishDate">Last Published: 2021-09-26</span>
</div>
<div class="xright"> <a href="../index.html" title="Home">Home</a>
|
<a href="../documentation.html" title="James">James</a>
|
<a href="../mime4j/index.html" title="Mime4J">Mime4J</a>
|
<a href="../jsieve/index.html" title="jSieve">jSieve</a>
|
<a href="../jspf/index.html" title="jSPF">jSPF</a>
|
<a href="../jdkim/index.html" title="jDKIM">jDKIM</a>
</div>
<div class="clear">
<hr/>
</div>
</div>
<div id="leftColumn">
<div id="navcolumn">
<h5>James components</h5>
<ul>
<li class="collapsed">
<a href="../documentation.html" title="About James">About James</a>
</li>
<li class="expanded">
<a href="../server/index.html" title="Server">Server</a>
<ul>
<li class="none">
<a href="../server/advantages.html" title="Advantages">Advantages</a>
</li>
<li class="none">
<a href="../server/objectives.html" title="Objectives">Objectives</a>
</li>
<li class="expanded">
<a href="../server/quick-start.html" title="User Manual">User Manual</a>
<ul>
<li class="collapsed">
<a href="../server/features.html" title="1. Features">1. Features</a>
</li>
<li class="none">
<a href="../server/packaging.html" title="2. Packaging">2. Packaging</a>
</li>
<li class="collapsed">
<a href="../server/install.html" title="3. Install James">3. Install James</a>
</li>
<li class="collapsed">
<a href="../server/config.html" title="4. Configure James">4. Configure James</a>
</li>
<li class="expanded">
<a href="../server/manage.html" title="5. Manage">5. Manage</a>
<ul>
<li class="none">
<a href="../server/manage-cli.html" title="Command line">Command line</a>
</li>
<li class="none">
<a href="../server/metrics.html" title="Metrics">Metrics</a>
</li>
<li class="none">
<strong>WebAdmin</strong>
</li>
<li class="none">
<a href="../server/manage-guice-distributed-james.html" title="Distributed James">Distributed James</a>
</li>
</ul>
</li>
<li class="collapsed">
<a href="../server/monitor.html" title="6. Monitor">6. Monitor</a>
</li>
<li class="collapsed">
<a href="../server/upgrade.html" title="7. Upgrade">7. Upgrade</a>
</li>
<li class="collapsed">
<a href="../server/dev.html" title="8. Developers Corner">8. Developers Corner</a>
</li>
</ul>
</li>
<li class="none">
<a href="../mail.html#James_Mailing_lists" title="Mailing Lists">Mailing Lists</a>
</li>
<li class="none">
<a href="../server/release-notes.html" title="Release Notes">Release Notes</a>
</li>
<li class="none">
<a href="../server/apidocs/index.html" title="Javadoc">Javadoc</a>
</li>
<li class="none">
<a href="https://issues.apache.org/jira/browse/JAMES" title="Issue Tracker">Issue Tracker</a>
</li>
<li class="none">
<a href="https://github.com/apache/james-project" title="Sources">Sources</a>
</li>
<li class="none">
<a href="../server/rfcs.html" title="RFCs">RFCs</a>
</li>
<li class="none">
<a href="../download.cgi#Apache_James_Server" title="Download releases">Download releases</a>
</li>
</ul>
</li>
<li class="collapsed">
<a href="../mailet/index.html" title="Mailets">Mailets</a>
</li>
<li class="collapsed">
<a href="../mailbox/index.html" title="Mailbox">Mailbox</a>
</li>
<li class="collapsed">
<a href="../protocols/index.html" title="Protocols">Protocols</a>
</li>
<li class="collapsed">
<a href="../mpt/index.html" title="MPT">MPT</a>
</li>
</ul>
<h5>Apache Software Foundation</h5>
<ul>
<li>
<strong>
<a title="ASF" href="http://www.apache.org/">ASF</a>
</strong>
</li>
<li>
<a title="Get Involved" href="http://www.apache.org/foundation/getinvolved.html">Get Involved</a>
</li>
<li>
<a title="FAQ" href="http://www.apache.org/foundation/faq.html">FAQ</a>
</li>
<li>
<a title="License" href="http://www.apache.org/licenses/" >License</a>
</li>
<li>
<a title="Sponsorship" href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a>
</li>
<li>
<a title="Thanks" href="http://www.apache.org/foundation/thanks.html">Thanks</a>
</li>
<li>
<a title="Security" href="http://www.apache.org/security/">Security</a>
</li>
</ul>
<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
<img class="poweredBy" alt="Built by Maven" src="../images/logos/maven-feather.png" />
</a>
</div>
</div>
<div id="bodyColumn">
<div id="contentBox">
<h1>Web administration for JAMES</h1>
<p>The web administration supports for now the CRUD operations on the domains, the users, their mailboxes and their quotas, managing mail repositories, performing cassandra migrations, and much more, as described in the following sections.</p>
<p><b>WARNING</b>: This API allow authentication only via the use of JWT. If not configured with JWT, an administrator should ensure an attacker can not use this API.</p>
<p>By the way, some endpoints are not filtered by authentication. Those endpoints are not related to data stored in James, for example: Swagger documentation &amp; James health checks.</p>
<p>Please also note <b>webadmin</b> is only enabled with <b>Guice</b>. You can not use it when using James with <b>Spring</b>, as the required injections are not implemented.</p>
<p>In case of any error, the system will return an error message which is json format like this:</p>
<div class="source">
<div class="source">
<pre>{
statusCode: &lt;error_code&gt;,
type: &lt;error_type&gt;,
message: &lt;the_error_message&gt;
cause: &lt;the_detail_message_from_throwable&gt;
}
</pre></div></div>
<p>Also be aware that, in case things go wrong, all endpoints might return a 500 internal error (with a JSON body formatted as exposed above). To avoid information duplication, this is ommited on endpoint specific documentation.</p>
<p>Finally, please note that in case of a malformed URL the 400 bad request response will contain an HTML body.</p><section>
<h2><a name="Navigation_menu"></a>Navigation menu</h2>
<ul>
<li><a href="#HealthCheck">HealthCheck</a></li>
<li><a href="#Administrating_domains">Administrating domains</a></li>
<li><a href="#Administrating_users">Administrating users</a></li>
<li><a href="#Administrating_mailboxes">Administrating mailboxes</a></li>
<li><a href="#Administrating_Messages">Administrating messages</a></li>
<li><a href="#Administrating_user_mailboxes">Administrating user mailboxes</a></li>
<li><a href="#Administrating_quotas_by_users">Administrating quotas by users</a></li>
<li><a href="#Administrating_quotas_by_domains">Administrating quotas by domains</a></li>
<li><a href="#Administrating_global_quotas">Administrating global quotas</a></li>
<li><a href="#Cassandra_Schema_upgrades">Cassandra Schema upgrades</a></li>
<li><a href="#Correcting_ghost_mailbox">Correcting ghost mailbox</a></li>
<li><a href="#Creating_address_aliases">Creating address aliases</a></li>
<li><a href="#Creating_domain_mappings">Creating domain mappings</a></li>
<li><a href="#Creating_address_forwards">Creating address forwards</a></li>
<li><a href="#Creating_address_group">Creating address group</a></li>
<li><a href="#Creating_regex_mapping">Creating regex mapping</a></li>
<li><a href="#Address_Mappings">Address Mappings</a></li>
<li><a href="#User_Mappings">User Mappings</a></li>
<li><a href="#Administrating_mail_repositories">Administrating mail repositories</a></li>
<li><a href="#Administrating_mail_queues">Administrating mail queues</a></li>
<li><a href="#Sending_email_over_webAdmin">Sending email over webAdmin</a></li>
<li><a href="#Administrating_DLP_Configuration">Administrating DLP Configuration</a></li>
<li><a href="#Administrating_Sieve_quotas">Administrating Sieve quotas</a></li>
<li><a href="#Running_blob_garbage_collection">Running blob garbage collection</a></li>
<li><a href="#Administrating_jmap_uploads">Administrating jmap uploads</a></li>
<li><a href="#Deleted_Messages_Vault">Deleted Messages Vault</a></li>
<li><a href="#Task_management">Task management</a></li>
<li><a href="#Cassandra_extra_operations">Cassandra extra operations</a></li>
<li><a href="#Event_Dead_Letter">Event Dead Letter</a></li>
</ul></section><section>
<h2><a name="HealthCheck"></a>HealthCheck</h2>
<ul>
<li><a href="#Check_all_components">Check all components</a></li>
<li><a href="#Check_single_component">Check single component</a></li>
<li><a href="#List_all_health_checks">List all health checks</a></li>
</ul><section>
<h3><a name="Check_all_components"></a>Check all components</h3>
<p>This endpoint is simple for now and is just returning the http status code corresponding to the state of checks (see below). The user has to check in the logs in order to have more information about failing checks.</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/healthcheck
</pre></div></div>
<p>Will return a list of healthChecks execution result, with an aggregated result:</p>
<div class="source">
<div class="source">
<pre>{
&quot;status&quot;: &quot;healthy&quot;,
&quot;checks&quot;: [
{
&quot;componentName&quot;: &quot;Cassandra backend&quot;,
&quot;escapedComponentName&quot;: &quot;Cassandra%20backend&quot;,
&quot;status&quot;: &quot;healthy&quot;
&quot;cause&quot;: null
}
]
}
</pre></div></div>
<p><b>status</b> field can be:</p>
<ul>
<li><b>healthy</b>: Component works normally</li>
<li><b>degraded</b>: Component works in degraded mode. Some non-critical services may not be working, or latencies are high, for example. Cause contains explanations.</li>
<li><b>unhealthy</b>: The component is currently not working. Cause contains explanations.</li>
</ul>
<p>Supported health checks include:</p>
<ul>
<li><b>Cassandra backend</b>: Cassandra storage. Included in Cassandra Guice based products.</li>
<li><b>ElasticSearch Backend</b>: ElasticSearch storage. Included in Cassandra Guice based products.</li>
<li><b>EventDeadLettersHealthCheck</b>: Included in all Guice products.</li>
<li><b>Guice application lifecycle</b>: included in all Guice products.</li>
<li><b>JPA Backend</b>: JPA storage. Included in JPA Guice based products.</li>
<li><b>MailReceptionCheck</b> We rely on a configured user, send an email to him and assert that the email is well received, and can be read within the given configured period. Unhealthy means that the email could not be received before reacing the timeout.</li>
<li><b>MessageFastViewProjection</b>: included in memory and Cassandra based Guice products. Health check of the component storing JMAP properties which are fast to retrieve. Those properties are computed in advance from messages and persisted in order to archive a better performance. There are some latencies between a source update and its projections updates. Incoherency problems arise when reads are performed in this time-window. We piggyback the projection update on missed JMAP read in order to decrease the outdated time window for a given entry. The health is determined by the ratio of missed projection reads. (lower than 10% causes degraded)</li>
<li>
<p><b>RabbitMQ backend</b>: RabbitMQ messaging. Included in Distributed Guice based products.</p>
</li>
</ul>
<p>Response codes:</p>
<ul>
<li>200: All checks have answered with a Healthy or Degraded status. James services can still be used.</li>
<li>503: At least one check have answered with a Unhealthy status</li>
</ul></section><section>
<h3><a name="Check_single_component"></a>Check single component</h3>
<p>Performs a health check for the given component. The component is referenced by its URL encoded name.</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/healthcheck/checks/Cassandra%20backend
</pre></div></div>
<p>Will return the component&#x2019;s name, the component&#x2019;s escaped name, the health status and a cause.</p>
<div class="source">
<div class="source">
<pre>{
&quot;componentName&quot;: &quot;Cassandra backend&quot;,
&quot;escapedComponentName&quot;: &quot;Cassandra%20backend&quot;,
&quot;status&quot;: &quot;healthy&quot;
&quot;cause&quot;: null
}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: The check has answered with a Healthy or Degraded status.</li>
<li>404: A component with the given name was not found.</li>
<li>503: The check has anwered with a Unhealthy status.</li>
</ul></section><section>
<h3><a name="List_all_health_checks"></a>List all health checks</h3>
<p>This endpoint lists all the available health checks.</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/healthcheck/checks
</pre></div></div>
<p>Will return the list of all available health checks.</p>
<div class="source">
<div class="source">
<pre>[
{
&quot;componentName&quot;: &quot;Cassandra backend&quot;,
&quot;escapedComponentName&quot;: &quot;Cassandra%20backend&quot;
}
]
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: List of available health checks</li>
</ul></section></section><section>
<h2><a name="Administrating_domains"></a>Administrating domains</h2>
<ul>
<li><a href="#Create_a_domain">Create a domain</a></li>
<li><a href="#Delete_a_domain">Delete a domain</a></li>
<li><a href="#Test_if_a_domain_exists">Test if a domain exists</a></li>
<li><a href="#Get_the_list_of_domains">Get the list of domains</a></li>
<li><a href="#Get_the_list_of_aliases_for_a_domain">Get the list of aliases for a domain</a></li>
<li><a href="#Create_an_alias_for_a_domain">Create an alias for a domain</a></li>
<li><a href="#Delete_an_alias_for_a_domain">Delete an alias for a domain</a></li>
</ul><section>
<h3><a name="Create_a_domain"></a>Create a domain</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/domains/domainToBeCreated
</pre></div></div>
<p>Resource name domainToBeCreated:</p>
<ul>
<li>can not be null or empty</li>
<li>can not contain &#x2018;@&#x2019;</li>
<li>can not be more than 255 characters</li>
<li>can not contain &#x2018;/&#x2019;</li>
</ul>
<p>Response codes:</p>
<ul>
<li>204: The domain was successfully added</li>
<li>400: The domain name is invalid</li>
</ul></section><section>
<h3><a name="Delete_a_domain"></a>Delete a domain</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/domains/{domainToBeDeleted}
</pre></div></div>
<p>Note: Deletion of an auto-detected domain, default domain or of an auto-detected ip is not supported. We encourage you instead to review your <a class="externalLink" href="https://james.apache.org/server/config-domainlist.html">domain list configuration</a>.</p>
<p>Response codes:</p>
<ul>
<li>204: The domain was successfully removed</li>
</ul></section><section>
<h3><a name="Test_if_a_domain_exists"></a>Test if a domain exists</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/domains/{domainName}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: The domain exists</li>
<li>404: The domain does not exist</li>
</ul></section><section>
<h3><a name="Get_the_list_of_domains"></a>Get the list of domains</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/domains
</pre></div></div>
<p>Possible response:</p>
<div class="source">
<div class="source">
<pre>[&quot;domain1&quot;, &quot;domain2&quot;]
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: The domain list was successfully retrieved</li>
</ul></section><section>
<h3><a name="Get_the_list_of_aliases_for_a_domain"></a>Get the list of aliases for a domain</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/domains/destination.domain.tld/aliases
</pre></div></div>
<p>Possible response:</p>
<div class="source">
<div class="source">
<pre>[
{&quot;source&quot;: &quot;source1.domain.tld&quot;},
{&quot;source&quot;: &quot;source2.domain.tld&quot;}
]
</pre></div></div>
<p>When sending an email to an email address having source1.domain.tld or source2.domain.tld as a domain part (example: user@source1.domain.tld), then the domain part will be rewritten into destination.domain.tld (so into user@destination.domain.tld).</p>
<p>Response codes:</p>
<ul>
<li>200: The domain aliases was successfully retrieved</li>
<li>400: destination.domain.tld has an invalid syntax</li>
<li>404: destination.domain.tld is not part of handled domains and does not have local domains as aliases.</li>
</ul></section><section>
<h3><a name="Create_an_alias_for_a_domain"></a>Create an alias for a domain</h3>
<p>To create a domain alias execute the following query:</p>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/domains/destination.domain.tld/aliases/source.domain.tld
</pre></div></div>
<p>When sending an email to an email address having source.domain.tld as a domain part (example: user@source.domain.tld), then the domain part will be rewritten into destination.domain.tld (so into user@destination.domain.tld).</p>
<p>Response codes:</p>
<ul>
<li>204: The redirection now exists</li>
<li>400: source.domain.tld or destination.domain.tld have an invalid syntax</li>
<li>400: source, domain and destination domain are the same</li>
<li>404: source.domain.tld are not part of handled domains.</li>
</ul>
<p>Be aware that no checks to find possible loops that would result of this creation will be performed.</p></section><section>
<h3><a name="Delete_an_alias_for_a_domain"></a>Delete an alias for a domain</h3>
<p>To delete a domain alias execute the following query:</p>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/domains/destination.domain.tld/aliases/source.domain.tld
</pre></div></div>
<p>When sending an email to an email address having source.domain.tld as a domain part (example: user@source.domain.tld), then the domain part will be rewritten into destination.domain.tld (so into user@destination.domain.tld).</p>
<p>Response codes:</p>
<ul>
<li>204: The redirection now no longer exists</li>
<li>400: source.domain.tld or destination.domain.tld have an invalid syntax</li>
<li>400: source, domain and destination domain are the same</li>
<li>404: source.domain.tld are not part of handled domains.</li>
</ul></section></section><section>
<h2><a name="Administrating_users"></a>Administrating users</h2>
<ul>
<li><a href="#Create_a_user">Create a user</a></li>
<li><a href="#Updating_a_user_password">Updating a user password</a></li>
<li><a href="#Testing_a_user_existence">Testing a user existence</a></li>
<li><a href="#Deleting_a_user">Deleting a user</a></li>
<li><a href="#Retrieving_the_user_list">Retrieving the user list</a></li>
<li><a href="Retrieving_the_list_of_allowed_From_headers_for_a_given_user">Retrieving the list of allowed From headers for a given user</a></li>
</ul><section>
<h3><a name="Create_a_user"></a>Create a user</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/users/usernameToBeUsed \
-d '{&quot;password&quot;:&quot;passwordToBeUsed&quot;}' \
-H &quot;Content-Type: application/json&quot;
</pre></div></div>
<p>Resource name usernameToBeUsed representing valid users, hence it should match the criteria at <a href="/server/config-users.html">User Repositories documentation</a></p>
<p>Response codes:</p>
<ul>
<li>204: The user was successfully created</li>
<li>400: The user name or the payload is invalid</li>
<li>409: The user name already exists</li>
</ul>
<p>Note: If the user exists already, its password cannot be updated using this. If you want to update a user&#x2019;s password, please have a look at <a href="#Updating_a_user_password">Update a user password</a>.</p></section><section>
<h3><a name="Updating_a_user_password"></a>Updating a user password</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/users/usernameToBeUsed?force \
-d '{&quot;password&quot;:&quot;passwordToBeUsed&quot;}' \
-H &quot;Content-Type: application/json&quot;
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: The user&#x2019;s password was successfully updated</li>
<li>400: The user name or the payload is invalid</li>
</ul>
<p>This also can be used to create a new user.</p></section><section>
<h3><a name="Testing_a_user_existence"></a>Testing a user existence</h3>
<div class="source">
<div class="source">
<pre>curl -XHEAD http://ip:port/users/usernameToBeUsed
</pre></div></div>
<p>Resource name &#x201c;usernameToBeUsed&#x201d; represents a valid user, hence it should match the criteria at <a href="/server/config-users.html">User Repositories documentation</a></p>
<p>Response codes:</p>
<ul>
<li>200: The user exists</li>
<li>400: The user name is invalid</li>
<li>404: The user does not exist</li>
</ul></section><section>
<h3><a name="Updating_a_user_password"></a>Updating a user password</h3>
<p>Same than Create, but a user need to exist.</p>
<p>If the user do not exist, then it will be created.</p></section><section>
<h3><a name="Deleting_a_user"></a>Deleting a user</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/users/{userToBeDeleted}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: The user was successfully deleted</li>
</ul></section><section>
<h3><a name="Retrieving_the_user_list"></a>Retrieving the user list</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/users
</pre></div></div>
<p>The answer looks like:</p>
<div class="source">
<div class="source">
<pre>[{&quot;username&quot;:&quot;username@domain-jmapauthentication.tld&quot;},{&quot;username&quot;:&quot;username@domain.tld&quot;}]
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: The user name list was successfully retrieved</li>
</ul></section><section>
<h3><a name="Retrieving_the_list_of_allowed_From_headers_for_a_given_user"></a>Retrieving the list of allowed From headers for a given user</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/users/givenUser/allowedFromHeaders
</pre></div></div>
<p>The answer looks like:</p>
<div class="source">
<div class="source">
<pre>[&quot;user@domain.tld&quot;,&quot;alias@domain.tld&quot;]
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: The list was successfully retrieved</li>
<li>400: The user is invalid</li>
<li>404: The user is unknown</li>
</ul></section></section><section>
<h2><a name="Administrating_mailboxes"></a>Administrating mailboxes</h2><section>
<h3><a name="All_mailboxes"></a>All mailboxes</h3>
<p>Several actions can be performed on the server mailboxes.</p>
<p>Request pattern is:</p>
<div class="source">
<div class="source">
<pre>curl -XPOST /mailboxes?action={action1},...
</pre></div></div>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes:</p>
<ul>
<li>201: Success. Corresponding task id is returned.</li>
<li>400: Error in the request. Details can be found in the reported error.</li>
</ul>
<p>The kind of task scheduled depends on the action parameter. See below for details.</p><section>
<h4><a name="Fixing_mailboxes_inconsistencies"></a>Fixing mailboxes inconsistencies</h4>
<p>This task is only available on top of Guice Cassandra products.</p>
<div class="source">
<div class="source">
<pre>curl -XPOST /mailboxes?task=SolveInconsistencies
</pre></div></div>
<p>Will schedule a task for fixing inconsistencies for the mailbox deduplicated object stored in Cassandra.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>The I-KNOW-WHAT-I-M-DOING header is mandatory (you can read more information about it in the warning section below).</p>
<p>The scheduled task will have the following type solve-mailbox-inconsistencies and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;type&quot;:&quot;solve-mailbox-inconsistencies&quot;,
&quot;processedMailboxEntries&quot;: 3,
&quot;processedMailboxPathEntries&quot;: 3,
&quot;fixedInconsistencies&quot;: 2,
&quot;errors&quot;: 1,
&quot;conflictingEntries&quot;:[{
&quot;mailboxDaoEntry&quot;:{
&quot;mailboxPath&quot;:&quot;#private:user:mailboxName&quot;,
&quot;mailboxId&quot;:&quot;464765a0-e4e7-11e4-aba4-710c1de3782b&quot;
},&quot; +
&quot;mailboxPathDaoEntry&quot;:{
&quot;mailboxPath&quot;:&quot;#private:user:mailboxName2&quot;,
&quot;mailboxId&quot;:&quot;464765a0-e4e7-11e4-aba4-710c1de3782b&quot;
}
}]
}
</pre></div></div>
<p>Note that conflicting entry inconsistencies will not be fixed and will require to explicitly use <a href="#correcting-ghost-mailbox">ghost mailbox</a> endpoint in order to merge the conflicting mailboxes and prevent any message loss.</p>
<p><b>WARNING</b>: this task can cancel concurrently running legitimate user operations upon dirty read. As such this task should be run offline.</p>
<p>A dirty read is when data is read between the two writes of the denormalization operations (no isolation).</p>
<p>In order to ensure being offline, stop the traffic on SMTP, JMAP and IMAP ports, for example via re-configuration or firewall rules.</p>
<p>Due to all of those risks, a I-KNOW-WHAT-I-M-DOING header should be positioned to ALL-SERVICES-ARE-OFFLINE in order to prevent accidental calls.</p></section><section>
<h4><a name="Recomputing_mailbox_counters"></a>Recomputing mailbox counters</h4>
<p>This task is only available on top of Guice Cassandra products.</p>
<div class="source">
<div class="source">
<pre>curl -XPOST /mailboxes?task=RecomputeMailboxCounters
</pre></div></div>
<p>Will recompute counters (unseen &amp; total count) for the mailbox object stored in Cassandra.</p>
<p>Cassandra maintains a per mailbox projection for message count and unseen message count. As with any projection, it can go out of sync, leading to inconsistent results being returned to the client.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>The scheduled task will have the following type recompute-mailbox-counters and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;type&quot;:&quot;recompute-mailbox-counters&quot;,
&quot;processedMailboxes&quot;: 3,
&quot;failedMailboxes&quot;: [&quot;464765a0-e4e7-11e4-aba4-710c1de3782b&quot;]
}
</pre></div></div>
<p>Note that conflicting inconsistencies entries will not be fixed and will require to explicitly use <a href="#correcting-ghost-mailbox">ghost mailbox</a> endpoint in order to merge the conflicting mailboxes and prevent any message loss.</p>
<p><b>WARNING</b>: this task do not take into account concurrent modifications upon a single mailbox counter recomputation. Rerunning the task will <i>eventually</i> provide the consistent result. As such we advise to run this task offline.</p>
<p>In order to ensure being offline, stop the traffic on SMTP, JMAP and IMAP ports, for example via re-configuration or firewall rules.</p>
<p>trustMessageProjection query parameter can be set to true. Content of messageIdTable (listing messages by their mailbox context) table will be trusted and not compared against content of imapUidTable table (listing messages by their messageId mailbox independent identifier). This will result in a better performance running the task at the cost of safety in the face of message denormalization inconsistencies.</p>
<p>Defaults to false, which generates additional checks. You can read <a class="externalLink" href="https://github.com/apache/james-project/blob/master/src/adr/0022-cassandra-message-inconsistency.md">this ADR</a> to better understand the message projection and how it can become inconsistent.</p></section><section>
<h4><a name="Recomputing_Global_JMAP_fast_message_view_projection"></a>Recomputing Global JMAP fast message view projection</h4>
<p>This action is only available for backends supporting JMAP protocol.</p>
<p>Message fast view projection stores message properties expected to be fast to fetch but are actually expensive to compute, in order for GetMessages operation to be fast to execute for these properties.</p>
<p>These projection items are asynchronously computed on mailbox events.</p>
<p>You can force the full projection recomputation by calling the following endpoint:</p>
<div class="source">
<div class="source">
<pre>curl -XPOST /mailboxes?task=recomputeFastViewProjectionItems
</pre></div></div>
<p>Will schedule a task for recomputing the fast message view projection for all mailboxes.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>An admin can specify the concurrency that should be used when running the task:</p>
<ul>
<li>messagesPerSecond rate at which messages should be processed, per second. Defaults to 10.</li>
</ul>
<p>This optional parameter must have a strictly positive integer as a value and be passed as query parameters.</p>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>curl -XPOST /mailboxes?task=recomputeFastViewProjectionItems&amp;messagesPerSecond=20
</pre></div></div>
<p>The scheduled task will have the following type RecomputeAllFastViewProjectionItemsTask and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;type&quot;:&quot;RecomputeAllPreviewsTask&quot;,
&quot;processedUserCount&quot;: 3,
&quot;processedMessageCount&quot;: 3,
&quot;failedUserCount&quot;: 2,
&quot;failedMessageCount&quot;: 1,
&quot;runningOptions&quot;: {
&quot;messagesPerSecond&quot;:20
}
}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>201: Success. Corresponding task id is returned.</li>
<li>400: Error in the request. Details can be found in the reported error.</li>
</ul></section><section>
<h4><a name="ReIndexing_action"></a>ReIndexing action</h4>
<p>These tasks are only available on top of Guice Cassandra products or Guice JPA products. They are not part of Memory Guice product.</p>
<p>Be also aware of the limits of this API:</p>
<p>Warning: During the re-indexing, the result of search operations might be altered.</p>
<p>Warning: Canceling this task should be considered unsafe as it will leave the currently reIndexed mailbox as partially indexed.</p>
<p>Warning: While we have been trying to reduce the inconsistency window to a maximum (by keeping track of ongoing events), concurrent changes done during the reIndexing might be ignored.</p>
<p>The following actions can be performed:</p>
<ul>
<li><a href="#ReIndexing_all_mails">ReIndexing all mails</a></li>
<li><a href="#Fixing_previously_failed_ReIndexing">Fixing previously failed ReIndexing</a></li>
</ul><section>
<h5><a name="ReIndexing_all_mails"></a>ReIndexing all mails</h5>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/mailboxes?task=reIndex
</pre></div></div>
<p>Will schedule a task for reIndexing all the mails stored on this James server.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>An admin can specify the concurrency that should be used when running the task:</p>
<ul>
<li>messagesPerSecond rate at which messages should be processed per second. Default is 50.</li>
</ul>
<p>This optional parameter must have a strictly positive integer as a value and be passed as query parameter.</p>
<p>An admin can also specify the reindexing mode it wants to use when running the task:</p>
<ul>
<li>mode the reindexing mode used. There are 2 modes for the moment:</li>
<li>rebuildAll allows to rebuild all indexes. It drops indexed entries prior reindexing. This is the default mode.</li>
<li>rebuildAllNoCleanup allows to rebuild all indexes. It skips the cleanup phase thus will not remove evicted entries upon reindex. However it yields better performances on a known to be empty index.</li>
<li>fixOutdated will check for outdated indexed document and reindex only those.</li>
</ul>
<p>This optional parameter must be passed as query parameter.</p>
<p>It&#x2019;s good to note as well that there is a limitation with the fixOutdated mode. As we first collect metadata of stored messages to compare them with the ones in the index, a failed expunged operation might not be well corrected (as the message might not exist anymore but still be indexed).</p>
<p>Example:</p>
<p>curl -XPOST http://ip:port/mailboxes?task=reIndex&amp;messagesPerSecond=200&amp;mode=rebuildAll</p>
<p>The scheduled task will have the following type full-reindexing and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;type&quot;:&quot;full-reindexing&quot;,
&quot;runningOptions&quot;:{
&quot;messagesPerSecond&quot;:200,
&quot;mode&quot;:&quot;REBUILD_ALL&quot;
},
&quot;successfullyReprocessedMailCount&quot;:18,
&quot;failedReprocessedMailCount&quot;: 3,
&quot;mailboxFailures&quot;: [&quot;12&quot;, &quot;23&quot; ],
&quot;messageFailures&quot;: [
{
&quot;mailboxId&quot;: &quot;1&quot;,
&quot;uids&quot;: [1, 36]
}]
}
</pre></div></div>
</section><section>
<h5><a name="Fixing_previously_failed_ReIndexing"></a>Fixing previously failed ReIndexing</h5>
<p>Will schedule a task for reIndexing all the mails which had failed to be indexed from the ReIndexingAllMails task.</p>
<p>Given bbdb69c9-082a-44b0-a85a-6e33e74287a5 being a taskId generated for a reIndexing tasks</p>
<div class="source">
<div class="source">
<pre>curl -XPOST 'http://ip:port/mailboxes?task=reIndex&amp;reIndexFailedMessagesOf=bbdb69c9-082a-44b0-a85a-6e33e74287a5'
</pre></div></div>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>An admin can specify the concurrency that should be used when running the task:</p>
<ul>
<li>messagesPerSecond rate at which messages should be processed per second. Default is 50.</li>
</ul>
<p>This optional parameter must have a strictly positive integer as a value and be passed as query parameter.</p>
<p>An admin can also specify the reindexing mode it wants to use when running the task:</p>
<ul>
<li>mode the reindexing mode used. There are 2 modes for the moment:</li>
<li>rebuildAll allows to rebuild all indexes. It drops indexed entries prior reindexing. This is the default mode.</li>
<li>rebuildAllNoCleanup allows to rebuild all indexes. It skips the cleanup phase thus will not remove evicted entries upon reindex. However it yields better performances on a known to be empty index.</li>
<li>fixOutdated will check for outdated indexed document and reindex only those.</li>
</ul>
<p>This optional parameter must be passed as query parameter.</p>
<p>It&#x2019;s good to note as well that there is a limitation with the fixOutdated mode. As we first collect metadata of stored messages to compare them with the ones in the index, a failed expunged operation might not be well corrected (as the message might not exist anymore but still be indexed).</p>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/mailboxes?task=reIndex&amp;reIndexFailedMessagesOf=bbdb69c9-082a-44b0-a85a-6e33e74287a5&amp;messagesPerSecond=200&amp;mode=rebuildAll
</pre></div></div>
<p>The scheduled task will have the following type error-recovery-indexation and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;type&quot;:&quot;error-recovery-indexation&quot;
&quot;runningOptions&quot;:{
&quot;messagesPerSecond&quot;:200,
&quot;mode&quot;:&quot;REBUILD_ALL&quot;
},
&quot;successfullyReprocessedMailCount&quot;:18,
&quot;failedReprocessedMailCount&quot;: 3,
&quot;mailboxFailures&quot;: [&quot;12&quot;, &quot;23&quot; ],
&quot;messageFailures&quot;: [{
&quot;mailboxId&quot;: &quot;1&quot;,
&quot;uids&quot;: [1, 36]
}]
}
</pre></div></div>
</section><section>
<h5><a name="Create_missing_parent_mailboxes"></a>Create missing parent mailboxes</h5>
<p>Will schedule a task for creating all the missing parent mailboxes in a hierarchical mailbox tree, which is the result of a partially failed rename operation of a child mailbox.</p>
<div class="source">
<div class="source">
<pre>curl -XPOST 'http://ip:port/mailboxes?task=createMissingParents'
</pre></div></div>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes:</p>
<ul>
<li>201: Success. Corresponding task id is returned.</li>
<li>400: Error in the request. Details can be found in the reported error.</li>
</ul>
<p>The scheduled task will have the following type createMissingParents and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;type&quot;:&quot;createMissingParents&quot;
&quot;created&quot;: [&quot;1&quot;, &quot;2&quot; ],
&quot;totalCreated&quot;: 2,
&quot;failures&quot;: [],
&quot;totalFailure&quot;: 0
}
</pre></div></div>
</section></section></section><section>
<h3><a name="Single_mailbox"></a>Single mailbox</h3><section>
<h4><a name="ReIndexing_a_mailbox_mails"></a>ReIndexing a mailbox mails</h4>
<p>This task is only available on top of Guice Cassandra products or Guice JPA products. It is not part of Memory Guice product.</p>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/mailboxes/{mailboxId}?task=reIndex
</pre></div></div>
<p>Will schedule a task for reIndexing all the mails in one mailbox.</p>
<p>Note that &#x2018;mailboxId&#x2019; path parameter needs to be a (implementation dependent) valid mailboxId.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>An admin can specify the concurrency that should be used when running the task:</p>
<ul>
<li>messagesPerSecond rate at which messages should be processed per second. Default is 50.</li>
</ul>
<p>This optional parameter must have a strictly positive integer as a value and be passed as query parameter.</p>
<p>An admin can also specify the reindexing mode it wants to use when running the task:</p>
<ul>
<li>mode the reindexing mode used. There are 2 modes for the moment:</li>
<li>rebuildAll allows to rebuild all indexes. It drops indexed entries prior reindexing. This is the default mode.</li>
<li>rebuildAllNoCleanup allows to rebuild all indexes. It skips the cleanup phase thus will not remove evicted entries upon reindex. However it yields better performances on a known to be empty index.</li>
<li>fixOutdated will check for outdated indexed document and reindex only those.</li>
</ul>
<p>This optional parameter must be passed as query parameter.</p>
<p>It&#x2019;s good to note as well that there is a limitation with the fixOutdated mode. As we first collect metadata of stored messages to compare them with the ones in the index, a failed expunged operation might not be well corrected (as the message might not exist anymore but still be indexed).</p>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/mailboxes/{mailboxId}?task=reIndex&amp;messagesPerSecond=200&amp;mode=fixOutdated
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>201: Success. Corresponding task id is returned.</li>
<li>400: Error in the request. Details can be found in the reported error.</li>
</ul>
<p>The scheduled task will have the following type mailbox-reindexing and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;type&quot;:&quot;mailbox-reindexing&quot;,
&quot;runningOptions&quot;:{
&quot;messagesPerSecond&quot;:200,
&quot;mode&quot;:&quot;FIX_OUTDATED&quot;
},
&quot;mailboxId&quot;:&quot;{mailboxId}&quot;,
&quot;successfullyReprocessedMailCount&quot;:18,
&quot;failedReprocessedMailCount&quot;: 3,
&quot;mailboxFailures&quot;: [&quot;12&quot;],
&quot;messageFailures&quot;: [
{
&quot;mailboxId&quot;: &quot;1&quot;,
&quot;uids&quot;: [1, 36]
}]
}
</pre></div></div>
<p>Warning: During the re-indexing, the result of search operations might be altered.</p>
<p>Warning: Canceling this task should be considered unsafe as it will leave the currently reIndexed mailbox as partially indexed.</p>
<p>Warning: While we have been trying to reduce the inconsistency window to a maximum (by keeping track of ongoing events), concurrent changes done during the reIndexing might be ignored.</p></section><section>
<h4><a name="ReIndexing_a_single_mail"></a>ReIndexing a single mail</h4>
<p>This task is only available on top of Guice Cassandra products or Guice JPA products. It is not part of Memory Guice product.</p>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/mailboxes/{mailboxId}/uid/{uid}?task=reIndex
</pre></div></div>
<p>Will schedule a task for reIndexing a single email.</p>
<p>Note that &#x2018;mailboxId&#x2019; path parameter needs to be a (implementation dependent) valid mailboxId.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes:</p>
<ul>
<li>201: Success. Corresponding task id is returned.</li>
<li>400: Error in the request. Details can be found in the reported error.</li>
</ul>
<p>The scheduled task will have the following type message-reindexing and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;mailboxId&quot;:&quot;{mailboxId}&quot;,
&quot;uid&quot;:18
}
</pre></div></div>
<p>Warning: During the re-indexing, the result of search operations might be altered.</p>
<p>Warning: Canceling this task should be considered unsafe as it will leave the currently reIndexed mailbox as partially indexed.</p></section></section></section><section>
<h2><a name="Administrating_Messages"></a>Administrating Messages</h2><section>
<h3><a name="ReIndexing_a_single_mail_by_messageId"></a>ReIndexing a single mail by messageId</h3>
<p>This task is only available on top of Guice Cassandra products or Guice JPA products. It is not part of Memory Guice product.</p>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/messages/{messageId}?task=reIndex
</pre></div></div>
<p>Will schedule a task for reIndexing a single email in all the mailboxes containing it.</p>
<p>Note that &#x2018;messageId&#x2019; path parameter needs to be a (implementation dependent) valid messageId.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes:</p>
<ul>
<li>201: Success. Corresponding task id is returned.</li>
<li>400: Error in the request. Details can be found in the reported error.</li>
</ul>
<p>The scheduled task will have the following type messageId-reindexing and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;messageId&quot;:&quot;18&quot;
}
</pre></div></div>
<p>Warning: During the re-indexing, the result of search operations might be altered.</p></section><section>
<h3><a name="Fixing_message_inconsistencies"></a>Fixing message inconsistencies</h3>
<p>This task is only available on top of Guice Cassandra products.</p>
<div class="source">
<div class="source">
<pre>curl -XPOST /messages?task=SolveInconsistencies
</pre></div></div>
<p>Will schedule a task for fixing message inconsistencies created by the message denormalization process.</p>
<p>Messages are denormalized and stored in separated data tables in Cassandra, so they can be accessed by their unique identifier or mailbox identifier &amp; local mailbox identifier through different protocols.</p>
<p>Failure in the denormalization process will lead to inconsistencies, for example:</p>
<div class="source">
<div class="source">
<pre>BOB receives a message
The denormalization process fails
BOB can read the message via JMAP
BOB cannot read the message via IMAP
BOB marks a message as SEEN
The denormalization process fails
The message is SEEN via JMAP
The message is UNSEEN via IMAP
</pre></div></div>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>An admin can specify the concurrency that should be used when running the task:</p>
<ul>
<li>messagesPerSecond rate of messages to be processed per second. Default is 100.</li>
</ul>
<p>This optional parameter must have a strictly positive integer as a value and be passed as query parameter.</p>
<p>An admin can also specify the reindexing mode it wants to use when running the task:</p>
<ul>
<li>mode the reindexing mode used. There are 2 modes for the moment:</li>
<li>rebuildAll allows to rebuild all indexes. It drops indexed entries prior reindexing. This is the default mode.</li>
<li>rebuildAllNoCleanup allows to rebuild all indexes. It skips the cleanup phase thus will not remove evicted entries upon reindex. However it yields better performances on a known to be empty index.</li>
<li>fixOutdated will check for outdated indexed document and reindex only those.</li>
</ul>
<p>This optional parameter must be passed as query parameter.</p>
<p>It&#x2019;s good to note as well that there is a limitation with the fixOutdated mode. As we first collect metadata of stored messages to compare them with the ones in the index, a failed expunged operation might not be well corrected (as the message might not exist anymore but still be indexed).</p>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>curl -XPOST /messages?task=SolveInconsistencies&amp;messagesPerSecond=200&amp;mode=rebuildAll
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>201: Success. Corresponding task id is returned.</li>
<li>400: Error in the request. Details can be found in the reported error.</li>
</ul>
<p>The scheduled task will have the following type solve-message-inconsistencies and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;type&quot;:&quot;solve-message-inconsistencies&quot;,
&quot;timestamp&quot;:&quot;2007-12-03T10:15:30Z&quot;,
&quot;processedImapUidEntries&quot;: 2,
&quot;processedMessageIdEntries&quot;: 1,
&quot;addedMessageIdEntries&quot;: 1,
&quot;updatedMessageIdEntries&quot;: 0,
&quot;removedMessageIdEntries&quot;: 1,
&quot;runningOptions&quot;:{
&quot;messagesPerSecond&quot;: 200,
&quot;mode&quot;:&quot;REBUILD_ALL&quot;
},
&quot;fixedInconsistencies&quot;: [
{
&quot;mailboxId&quot;: &quot;551f0580-82fb-11ea-970e-f9c83d4cf8c2&quot;,
&quot;messageId&quot;: &quot;d2bee791-7e63-11ea-883c-95b84008f979&quot;,
&quot;uid&quot;: 1
},
{
&quot;mailboxId&quot;: &quot;551f0580-82fb-11ea-970e-f9c83d4cf8c2&quot;,
&quot;messageId&quot;: &quot;d2bee792-7e63-11ea-883c-95b84008f979&quot;,
&quot;uid&quot;: 2
}
],
&quot;errors&quot;: [
{
&quot;mailboxId&quot;: &quot;551f0580-82fb-11ea-970e-f9c83d4cf8c2&quot;,
&quot;messageId&quot;: &quot;ffffffff-7e63-11ea-883c-95b84008f979&quot;,
&quot;uid&quot;: 3
}
]
}
</pre></div></div>
<p>User actions concurrent to the inconsistency fixing task could result in concurrency issues. New inconsistencies could be created.</p>
<p>However the source of truth will not be impacted, hence rerunning the task will eventually fix all issues.</p>
<p>This task could be run safely online and can be scheduled on a recurring basis outside of peak traffic by an admin to ensure Cassandra message consistency.</p></section></section><section>
<h2><a name="Administrating_user_mailboxes"></a>Administrating user mailboxes</h2>
<ul>
<li><a href="#Creating_a_mailbox">Creating a mailbox</a></li>
<li><a href="#Deleting_a_mailbox_and_its_children">Deleting a mailbox and its children</a></li>
<li><a href="#Testing_existence_of_a_mailbox">Testing existence of a mailbox</a></li>
<li><a href="#Listing_user_mailboxes">Listing user mailboxes</a></li>
<li><a href="#Deleting_user_mailboxes">Deleting user mailboxes</a></li>
<li><a href="#Exporting_user_mailboxes">Exporting user mailboxes</a></li>
<li><a href="#ReIndexing_a_user_mails">ReIndexing a user mails</a></li>
<li><a href="#Recomputing_User_JMAP_fast_message_view_projection">Recomputing User JMAP fast message view projection</a></li>
<li><a href="#Counting_emails">Counting emails</a></li>
<li><a href="#Couting_unseen_emails">Counting unseen emails</a></li>
<li>[Clearing mailbox content][#Clearing_mailbox_content]</li>
</ul><section>
<h3><a name="Creating_a_mailbox"></a>Creating a mailbox</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/users/{usernameToBeUsed}/mailboxes/{mailboxNameToBeCreated}
</pre></div></div>
<p>Resource name usernameToBeUsed should be an existing user Resource name mailboxNameToBeCreated should not be empty, nor contain % * characters, nor starting with #.</p>
<p>Response codes:</p>
<ul>
<li>204: The mailbox now exists on the server</li>
<li>400: Invalid mailbox name</li>
<li>404: The user name does not exist</li>
</ul>
<p>To create nested mailboxes, for instance a work mailbox inside the INBOX mailbox, people should use the . separator. The sample query is:</p>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/users/{usernameToBeUsed}/mailboxes/INBOX.work
</pre></div></div>
</section><section>
<h3><a name="Deleting_a_mailbox_and_its_children"></a>Deleting a mailbox and its children</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/users/{usernameToBeUsed}/mailboxes/{mailboxNameToBeDeleted}
</pre></div></div>
<p>Resource name usernameToBeUsed should be an existing user Resource name mailboxNameToBeDeleted should not be empty</p>
<p>Response codes:</p>
<ul>
<li>204: The mailbox now does not exist on the server</li>
<li>400: Invalid mailbox name</li>
<li>404: The user name does not exist</li>
</ul></section><section>
<h3><a name="Testing_existence_of_a_mailbox"></a>Testing existence of a mailbox</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/users/{usernameToBeUsed}/mailboxes/{mailboxNameToBeTested}
</pre></div></div>
<p>Resource name usernameToBeUsed should be an existing user Resource name mailboxNameToBeTested should not be empty</p>
<p>Response codes:</p>
<ul>
<li>204: The mailbox exists</li>
<li>400: Invalid mailbox name</li>
<li>404: The user name does not exist, the mailbox does not exist</li>
</ul></section><section>
<h3><a name="Listing_user_mailboxes"></a>Listing user mailboxes</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/users/{usernameToBeUsed}/mailboxes
</pre></div></div>
<p>The answer looks like:</p>
<div class="source">
<div class="source">
<pre>[{&quot;mailboxName&quot;:&quot;INBOX&quot;},{&quot;mailboxName&quot;:&quot;outbox&quot;}]
</pre></div></div>
<p>Resource name usernameToBeUsed should be an existing user</p>
<p>Response codes:</p>
<ul>
<li>200: The mailboxes list was successfully retrieved</li>
<li>404: The user name does not exist</li>
</ul></section><section>
<h3><a name="Deleting_user_mailboxes"></a>Deleting user mailboxes</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/users/{usernameToBeUsed}/mailboxes
</pre></div></div>
<p>Resource name usernameToBeUsed should be an existing user</p>
<p>Response codes:</p>
<ul>
<li>204: The user do not have mailboxes anymore</li>
<li>404: The user name does not exist</li>
</ul></section><section>
<h3><a name="Exporting_user_mailboxes"></a>Exporting user mailboxes</h3>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/users/{usernameToBeUsed}/mailboxes?action=export
</pre></div></div>
<p>Resource name usernameToBeUsed should be an existing user</p>
<p>Response codes:</p>
<ul>
<li>201: Success. Corresponding task id is returned</li>
<li>404: The user name does not exist</li>
</ul>
<p>The scheduled task will have the following type MailboxesExportTask and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;type&quot;:&quot;MailboxesExportTask&quot;,
&quot;timestamp&quot;:&quot;2007-12-03T10:15:30Z&quot;,
&quot;username&quot;: &quot;user&quot;,
&quot;stage&quot;: &quot;STARTING&quot;
}
</pre></div></div>
</section><section>
<h3><a name="ReIndexing_a_user_mails"></a>ReIndexing a user mails</h3>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/users/{usernameToBeUsed}/mailboxes?task=reIndex
</pre></div></div>
<p>Will schedule a task for reIndexing all the mails in &#x201c;<a class="externalLink" href="mailto:user@domain.com">user@domain.com</a>&#x201d; mailboxes (encoded above).</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>An admin can specify the concurrency that should be used when running the task:</p>
<ul>
<li>messagesPerSecond rate at which messages should be processed per second. Default is 50.</li>
</ul>
<p>This optional parameter must have a strictly positive integer as a value and be passed as query parameter.</p>
<p>An admin can also specify the reindexing mode it wants to use when running the task:</p>
<ul>
<li>mode the reindexing mode used. There are 2 modes for the moment:</li>
<li>rebuildAll allows to rebuild all indexes. It drops indexed entries prior reindexing. This is the default mode.</li>
<li>rebuildAllNoCleanup allows to rebuild all indexes. It skips the cleanup phase thus will not remove evicted entries upon reindex. However it yields better performances on a known to be empty index.</li>
<li>fixOutdated will check for outdated indexed document and reindex only those.</li>
</ul>
<p>This optional parameter must be passed as query parameter.</p>
<p>It&#x2019;s good to note as well that there is a limitation with the fixOutdated mode. As we first collect metadata of stored messages to compare them with the ones in the index, a failed expunged operation might not be well corrected (as the message might not exist anymore but still be indexed).</p>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/users/{usernameToBeUsed}/mailboxes?task=reIndex&amp;messagesPerSecond=200&amp;mode=fixOutdated
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>201: Success. Corresponding task id is returned.</li>
<li>400: Error in the request. Details can be found in the reported error.</li>
</ul>
<p>The scheduled task will have the following type user-reindexing and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;type&quot;:&quot;user-reindexing&quot;,
&quot;runningOptions&quot;:{
&quot;messagesPerSecond&quot;:200,
&quot;mode&quot;:&quot;FIX_OUTDATED&quot;
},
&quot;user&quot;:&quot;user@domain.com&quot;,
&quot;successfullyReprocessedMailCount&quot;:18,
&quot;failedReprocessedMailCount&quot;: 3,
&quot;mailboxFailures&quot;: [&quot;12&quot;, &quot;23&quot; ],
&quot;messageFailures&quot;: [
{
&quot;mailboxId&quot;: &quot;1&quot;,
&quot;uids&quot;: [1, 36]
}]
}
</pre></div></div>
<p>Warning: During the re-indexing, the result of search operations might be altered.</p>
<p>Warning: Canceling this task should be considered unsafe as it will leave the currently reIndexed mailbox as partially indexed.</p>
<p>Warning: While we have been trying to reduce the inconsistency window to a maximum (by keeping track of ongoing events), concurrent changes done during the reIndexing might be ignored.</p></section><section>
<h3><a name="Counting_emails"></a>Counting emails</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/users/{usernameToBeUsed}/mailboxes/{mailboxName}/messageCount
</pre></div></div>
<p>Will return the total count of messages within the mailbox of that user.</p>
<p>Resource name usernameToBeUsed should be an existing user.<br />
Resource name mailboxName should not be empty, nor contain % * characters, nor starting with #.</p>
<p>Response codes:</p>
<ul>
<li>200: The number of emails in a given mailbox</li>
<li>400: Invalid mailbox name</li>
<li>404: Invalid get on user mailboxes. The usernameToBeUsed or mailboxName does not exit&#x2019;</li>
</ul></section><section>
<h3><a name="Counting_unseen_emails"></a>Counting unseen emails</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/users/{usernameToBeUsed}/mailboxes/{mailboxName}/unseenMessageCount
</pre></div></div>
<p>Will return the total count of unseen messages within the mailbox of that user.</p>
<p>Resource name usernameToBeUsed should be an existing user.<br />
Resource name mailboxName should not be empty, nor contain % * characters, nor starting with #.</p>
<p>Response codes:</p>
<ul>
<li>200: The number of unseen emails in a given mailbox</li>
<li>400: Invalid mailbox name</li>
<li>404: Invalid get on user mailboxes. The usernameToBeUsed or mailboxName does not exit&#x2019;</li>
</ul></section><section>
<h3><a name="Clearing_mailbox_content"></a>Clearing mailbox content</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/users/{usernameToBeUsed}/mailboxes/{mailboxName}/messages
</pre></div></div>
<p>Will schedule a task for clearing all the mails in mailboxName mailbox of usernameToBeUsed.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Resource name usernameToBeUsed should be an existing user.</p>
<p>Resource name mailboxName should not be empty, nor contain % * characters, nor starting with #.</p>
<p>Response codes:</p>
<ul>
<li>201: Success. Corresponding task id is returned.</li>
<li>400: Invalid mailbox name</li>
<li>404: Invalid get on user mailboxes. The username or mailboxName does not exit</li>
</ul>
<p>The scheduled task will have the following type ClearMailboxContentTask and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;mailboxName&quot;: &quot;mbx1&quot;,
&quot;messagesFailCount&quot;: 9,
&quot;messagesSuccessCount&quot;: 10,
&quot;timestamp&quot;: &quot;2007-12-03T10:15:30Z&quot;,
&quot;type&quot;: &quot;ClearMailboxContentTask&quot;,
&quot;username&quot;: &quot;bob@domain.tld&quot;
}
</pre></div></div>
</section><section>
<h3><a name="Subscribing_a_user_to_all_of_its_mailboxes"></a>Subscribing a user to all of its mailboxes</h3>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/users/{usernameToBeUsed}/mailboxes?task=subscribeAll
</pre></div></div>
<p>Will schedule a task for subscribing a user to all of its mailboxes.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Most users are unaware of what an IMAP subscription is, nor how they can manage it. If the subscription list gets out of sync with the mailbox list, it could result in downgraded user experience (see MAILBOX-405). This task allow to reset the subscription list to the mailbox list on a per user basis thus working around the aforementioned issues.</p>
<p>Response codes:</p>
<ul>
<li>201: Success. Corresponding task id is returned.</li>
<li>404: No such user</li>
</ul>
<p>The scheduled task will have the following type SubscribeAllTask and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;type&quot;:&quot;SubscribeAllTask&quot;,
&quot;username&quot;:&quot;user@domain.com&quot;,
&quot;subscribedCount&quot;:18,
&quot;unsubscribedCount&quot;: 3
}
</pre></div></div>
</section><section>
<h3><a name="Recomputing_User_JMAP_fast_message_view_projection"></a>Recomputing User JMAP fast message view projection</h3>
<p>This action is only available for backends supporting JMAP protocol.</p>
<p>Message fast view projection stores message properties expected to be fast to fetch but are actually expensive to compute, in order for GetMessages operation to be fast to execute for these properties.</p>
<p>These projection items are asynchronously computed on mailbox events.</p>
<p>You can force the full projection recomputation by calling the following endpoint:</p>
<div class="source">
<div class="source">
<pre>curl -XPOST /users/{usernameToBeUsed}/mailboxes?task=recomputeFastViewProjectionItems
</pre></div></div>
<p>Will schedule a task for recomputing the fast message view projection for all mailboxes of usernameToBeUsed.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>An admin can specify the concurrency that should be used when running the task:</p>
<ul>
<li>messagesPerSecond rate at which messages should be processed, per second. Defaults to 10.</li>
</ul>
<p>This optional parameter must have a strictly positive integer as a value and be passed as query parameters.</p>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>curl -XPOST /mailboxes?task=recomputeFastViewProjectionItems&amp;messagesPerSecond=20
</pre></div></div>
<p>The scheduled task will have the following type RecomputeUserFastViewProjectionItemsTask and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;type&quot;:&quot;RecomputeUserFastViewProjectionItemsTask&quot;,
&quot;username&quot;: &quot;{usernameToBeUsed}&quot;,
&quot;processedMessageCount&quot;: 3,
&quot;failedMessageCount&quot;: 1,
&quot;runningOptions&quot;: {
&quot;messagesPerSecond&quot;:20
}
}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>201: Success. Corresponding task id is returned.</li>
<li>400: Error in the request. Details can be found in the reported error.</li>
<li>404: User not found.</li>
</ul></section></section><section>
<h2><a name="Administrating_quotas_by_users"></a>Administrating quotas by users</h2>
<ul>
<li><a href="#Getting_the_quota_for_a_user">Getting the quota for a user</a></li>
<li><a href="#Updating_the_quota_for_a_user">Updating the quota for a user</a></li>
<li><a href="#Getting_the_quota_count_for_a_user">Getting the quota count for a user</a></li>
<li><a href="#Updating_the_quota_count_for_a_user">Updating the quota count for a user</a></li>
<li><a href="#Deleting_the_quota_count_for_a_user">Deleting the quota count for a user</a></li>
<li><a href="#Getting_the_quota_size_for_a_user">Getting the quota size for a user</a></li>
<li><a href="#Updating_the_quota_size_for_a_user">Updating the quota size for a user</a></li>
<li><a href="#Deleting_the_quota_size_for_a_user">Deleting the quota size for a user</a></li>
<li><a href="#Searching_user_by_quota_ratio">Searching user by quota ratio</a></li>
<li><a href="#Recomputing_current_quotas_for_users">Recomputing current quotas for users</a></li>
</ul><section>
<h3><a name="Getting_the_quota_for_a_user"></a>Getting the quota for a user</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/quota/users/{usernameToBeUsed}
</pre></div></div>
<p>Resource name usernameToBeUsed should be an existing user</p>
<p>The answer is the details of the quota of that user.</p>
<div class="source">
<div class="source">
<pre>{
&quot;global&quot;: {
&quot;count&quot;:252,
&quot;size&quot;:242
},
&quot;domain&quot;: {
&quot;count&quot;:152,
&quot;size&quot;:142
},
&quot;user&quot;: {
&quot;count&quot;:52,
&quot;size&quot;:42
},
&quot;computed&quot;: {
&quot;count&quot;:52,
&quot;size&quot;:42
},
&quot;occupation&quot;: {
&quot;size&quot;:13,
&quot;count&quot;:21,
&quot;ratio&quot;: {
&quot;size&quot;:0.25,
&quot;count&quot;:0.5,
&quot;max&quot;:0.5
}
}
}
</pre></div></div>
<ul>
<li>The global entry represent the quota limit allowed on this James server.</li>
<li>The domain entry represent the quota limit allowed for the user of that domain.</li>
<li>The user entry represent the quota limit allowed for this specific user.</li>
<li>The computed entry represent the quota limit applied for this user, resolved from the upper values.</li>
<li>The occupation entry represent the occupation of the quota for this user. This includes used count and size as well as occupation ratio (used / limit).</li>
</ul>
<p>Note that quota object can contain a fixed value, an empty value (null) or an unlimited value (-1):</p>
<div class="source">
<div class="source">
<pre>{&quot;count&quot;:52,&quot;size&quot;:42}
{&quot;count&quot;:null,&quot;size&quot;:null}
{&quot;count&quot;:52,&quot;size&quot;:-1}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: The user&#x2019;s quota was successfully retrieved</li>
<li>404: The user does not exist</li>
</ul></section><section>
<h3><a name="Updating_the_quota_for_a_user"></a>Updating the quota for a user</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/quota/users/{usernameToBeUsed}
</pre></div></div>
<p>Resource name usernameToBeUsed should be an existing user</p>
<p>The body can contain a fixed value, an empty value (null) or an unlimited value (-1):</p>
<div class="source">
<div class="source">
<pre>{&quot;count&quot;:52,&quot;size&quot;:42}
{&quot;count&quot;:null,&quot;size&quot;:null}
{&quot;count&quot;:52,&quot;size&quot;:-1}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: The quota has been updated</li>
<li>400: The body is not a positive integer neither an unlimited value (-1).</li>
<li>404: The user does not exist</li>
</ul></section><section>
<h3><a name="Getting_the_quota_count_for_a_user"></a>Getting the quota count for a user</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/quota/users/{usernameToBeUsed}/count
</pre></div></div>
<p>Resource name usernameToBeUsed should be an existing user</p>
<p>The answer looks like:</p>
<div class="source">
<div class="source">
<pre>52
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: The user&#x2019;s quota was successfully retrieved</li>
<li>204: No quota count limit is defined at the user level for this user</li>
<li>404: The user does not exist</li>
</ul></section><section>
<h3><a name="Updating_the_quota_count_for_a_user"></a>Updating the quota count for a user</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/quota/users/{usernameToBeUsed}/count
</pre></div></div>
<p>Resource name usernameToBeUsed should be an existing user</p>
<p>The body can contain a fixed value or an unlimited value (-1):</p>
<div class="source">
<div class="source">
<pre>52
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: The quota has been updated</li>
<li>400: The body is not a positive integer neither an unlimited value (-1).</li>
<li>404: The user does not exist</li>
</ul></section><section>
<h3><a name="Deleting_the_quota_count_for_a_user"></a>Deleting the quota count for a user</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/quota/users/{usernameToBeUsed}/count
</pre></div></div>
<p>Resource name usernameToBeUsed should be an existing user</p>
<p>Response codes:</p>
<ul>
<li>204: The quota has been updated to unlimited value.</li>
<li>404: The user does not exist</li>
</ul></section><section>
<h3><a name="Getting_the_quota_size_for_a_user"></a>Getting the quota size for a user</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/quota/users/{usernameToBeUsed}/size
</pre></div></div>
<p>Resource name usernameToBeUsed should be an existing user</p>
<p>The answer looks like:</p>
<div class="source">
<div class="source">
<pre>52
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: The user&#x2019;s quota was successfully retrieved</li>
<li>204: No quota size limit is defined at the user level for this user</li>
<li>404: The user does not exist</li>
</ul></section><section>
<h3><a name="Updating_the_quota_size_for_a_user"></a>Updating the quota size for a user</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/quota/users/{usernameToBeUsed}/size
</pre></div></div>
<p>Resource name usernameToBeUsed should be an existing user</p>
<p>The body can contain a fixed value or an unlimited value (-1):</p>
<div class="source">
<div class="source">
<pre>52
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: The quota has been updated</li>
<li>400: The body is not a positive integer neither an unlimited value (-1).</li>
<li>404: The user does not exist</li>
</ul></section><section>
<h3><a name="Deleting_the_quota_size_for_a_user"></a>Deleting the quota size for a user</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/quota/users/{usernameToBeUsed}/size
</pre></div></div>
<p>Resource name usernameToBeUsed should be an existing user</p>
<p>Response codes:</p>
<ul>
<li>204: The quota has been updated to unlimited value.</li>
<li>404: The user does not exist</li>
</ul></section><section>
<h3><a name="Searching_user_by_quota_ratio"></a>Searching user by quota ratio</h3>
<div class="source">
<div class="source">
<pre>curl -XGET 'http://ip:port/quota/users?minOccupationRatio=0.8&amp;maxOccupationRatio=0.99&amp;limit=100&amp;offset=200&amp;domain=domain.com'
</pre></div></div>
<p>Will return:</p>
<div class="source">
<div class="source">
<pre>[
{
&quot;username&quot;:&quot;user@domain.com&quot;,
&quot;detail&quot;: {
&quot;global&quot;: {
&quot;count&quot;:252,
&quot;size&quot;:242
},
&quot;domain&quot;: {
&quot;count&quot;:152,
&quot;size&quot;:142
},
&quot;user&quot;: {
&quot;count&quot;:52,
&quot;size&quot;:42
},
&quot;computed&quot;: {
&quot;count&quot;:52,
&quot;size&quot;:42
},
&quot;occupation&quot;: {
&quot;size&quot;:48,
&quot;count&quot;:21,
&quot;ratio&quot;: {
&quot;size&quot;:0.9230,
&quot;count&quot;:0.5,
&quot;max&quot;:0.9230
}
}
}
},
...
]
</pre></div></div>
<p>Where:</p>
<ul>
<li><b>minOccupationRatio</b> is a query parameter determining the minimum occupation ratio of users to be returned.</li>
<li><b>maxOccupationRatio</b> is a query parameter determining the maximum occupation ratio of users to be returned.</li>
<li><b>domain</b> is a query parameter determining the domain of users to be returned.</li>
<li><b>limit</b> is a query parameter determining the maximum number of users to be returned.</li>
<li><b>offset</b> is a query parameter determining the number of users to skip.</li>
</ul>
<p>Please note that users are alphabetically ordered on username.</p>
<p>The response is a list of usernames, with attached quota details as defined <a href="#getting-the-quota-for-a-user">here</a>.</p>
<p>Response codes:</p>
<ul>
<li>200: List of users had successfully been returned.</li>
<li>400: Validation issues with parameters</li>
</ul></section><section>
<h3><a name="Recomputing_current_quotas_for_users"></a>Recomputing current quotas for users</h3>
<p>This task is available on top of Cassandra &amp; JPA products.</p>
<div class="source">
<div class="source">
<pre>curl -XPOST /quota/users?task=RecomputeCurrentQuotas
</pre></div></div>
<p>Will recompute current quotas (count and size) for all users stored in James.</p>
<p>James maintains per quota a projection for current quota count and size. As with any projection, it can go out of sync, leading to inconsistent results being returned to the client.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>An admin can specify the concurrency that should be used when running the task:</p>
<ul>
<li>usersPerSecond rate at which users quotas should be reprocessed, per second. Defaults to 1.</li>
</ul>
<p>This optional parameter must have a strictly positive integer as a value and be passed as query parameters.</p>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>curl -XPOST /quota/users?task=RecomputeCurrentQuotas&amp;usersPerSecond=20
</pre></div></div>
<p>The scheduled task will have the following type recompute-current-quotas and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;type&quot;:&quot;recompute-current-quotas&quot;,
&quot;processedQuotaRoots&quot;: 3,
&quot;failedQuotaRoots&quot;: [&quot;#private&amp;bob@localhost&quot;],
&quot;runningOptions&quot;: {
&quot;usersPerSecond&quot;:20
}
}
</pre></div></div>
<p><b>WARNING</b>: this task do not take into account concurrent modifications upon a single current quota recomputation. Rerunning the task will <i>eventually</i> provide the consistent result.</p></section></section><section>
<h2><a name="Administrating_quotas_by_domains"></a>Administrating quotas by domains</h2>
<ul>
<li><a href="#Getting_the_quota_for_a_domain">Getting the quota for a domain</a></li>
<li><a href="#Updating_the_quota_for_a_domain">Updating the quota for a domain</a></li>
<li><a href="#Getting_the_quota_count_for_a_domain">Getting the quota count for a domain</a></li>
<li><a href="#Updating_the_quota_count_for_a_domain">Updating the quota count for a domain</a></li>
<li><a href="#Deleting_the_quota_count_for_a_domain">Deleting the quota count for a domain</a></li>
<li><a href="#Getting_the_quota_size_for_a_domain">Getting the quota size for a domain</a></li>
<li><a href="#Updating_the_quota_size_for_a_domain">Updating the quota size for a domain</a></li>
<li><a href="#Deleting_the_quota_size_for_a_domain">Deleting the quota size for a domain</a></li>
</ul><section>
<h3><a name="Getting_the_quota_for_a_domain"></a>Getting the quota for a domain</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/quota/domains/{domainToBeUsed}
</pre></div></div>
<p>Resource name domainToBeUsed should be an existing domain. For example:</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/quota/domains/james.org
</pre></div></div>
<p>The answer will detail the default quota applied to users belonging to that domain:</p>
<div class="source">
<div class="source">
<pre>{
&quot;global&quot;: {
&quot;count&quot;:252,
&quot;size&quot;:null
},
&quot;domain&quot;: {
&quot;count&quot;:null,
&quot;size&quot;:142
},
&quot;computed&quot;: {
&quot;count&quot;:252,
&quot;size&quot;:142
}
}
</pre></div></div>
<ul>
<li>The global entry represents the quota limit defined on this James server by default.</li>
<li>The domain entry represents the quota limit allowed for the user of that domain by default.</li>
<li>The computed entry represents the quota limit applied for the users of that domain, by default, resolved from the upper values.</li>
</ul>
<p>Note that quota object can contain a fixed value, an empty value (null) or an unlimited value (-1):</p>
<div class="source">
<div class="source">
<pre>{&quot;count&quot;:52,&quot;size&quot;:42}
{&quot;count&quot;:null,&quot;size&quot;:null}
{&quot;count&quot;:52,&quot;size&quot;:-1}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: The domain&#x2019;s quota was successfully retrieved</li>
<li>404: The domain does not exist</li>
<li>405: Domain Quota configuration not supported when virtual hosting is desactivated.</li>
</ul></section><section>
<h3><a name="Updating_the_quota_for_a_domain"></a>Updating the quota for a domain</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/quota/domains/{domainToBeUsed}
</pre></div></div>
<p>Resource name domainToBeUsed should be an existing domain.</p>
<p>The body can contain a fixed value, an empty value (null) or an unlimited value (-1):</p>
<div class="source">
<div class="source">
<pre>{&quot;count&quot;:52,&quot;size&quot;:42}
{&quot;count&quot;:null,&quot;size&quot;:null}
{&quot;count&quot;:52,&quot;size&quot;:-1}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: The quota has been updated</li>
<li>400: The body is not a positive integer neither an unlimited value (-1).</li>
<li>404: The domain does not exist</li>
<li>405: Domain Quota configuration not supported when virtual hosting is desactivated.</li>
</ul></section><section>
<h3><a name="Getting_the_quota_count_for_a_domain"></a>Getting the quota count for a domain</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/quota/domains/{domainToBeUsed}/count
</pre></div></div>
<p>Resource name domainToBeUsed should be an existing domain.</p>
<p>The answer looks like:</p>
<div class="source">
<div class="source">
<pre>52
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: The domain&#x2019;s quota was successfully retrieved</li>
<li>204: No quota count limit is defined at the domain level for this domain</li>
<li>404: The domain does not exist</li>
<li>405: Domain Quota configuration not supported when virtual hosting is desactivated.</li>
</ul></section><section>
<h3><a name="Updating_the_quota_count_for_a_domain"></a>Updating the quota count for a domain</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/quota/domains/{domainToBeUsed}/count
</pre></div></div>
<p>Resource name domainToBeUsed should be an existing domain.</p>
<p>The body can contain a fixed value or an unlimited value (-1):</p>
<div class="source">
<div class="source">
<pre>52
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: The quota has been updated</li>
<li>400: The body is not a positive integer neither an unlimited value (-1).</li>
<li>404: The domain does not exist</li>
<li>405: Domain Quota configuration not supported when virtual hosting is desactivated.</li>
</ul></section><section>
<h3><a name="Deleting_the_quota_count_for_a_domain"></a>Deleting the quota count for a domain</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/quota/domains/{domainToBeUsed}/count
</pre></div></div>
<p>Resource name domainToBeUsed should be an existing domain.</p>
<p>Response codes:</p>
<ul>
<li>204: The quota has been updated to unlimited value.</li>
<li>404: The domain does not exist</li>
<li>405: Domain Quota configuration not supported when virtual hosting is desactivated.</li>
</ul></section><section>
<h3><a name="Getting_the_quota_size_for_a_domain"></a>Getting the quota size for a domain</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/quota/domains/{domainToBeUsed}/size
</pre></div></div>
<p>Resource name domainToBeUsed should be an existing domain.</p>
<p>The answer looks like:</p>
<div class="source">
<div class="source">
<pre>52
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: The domain&#x2019;s quota was successfully retrieved</li>
<li>204: No quota size limit is defined at the domain level for this domain</li>
<li>404: The domain does not exist</li>
<li>405: Domain Quota configuration not supported when virtual hosting is desactivated.</li>
</ul></section><section>
<h3><a name="Updating_the_quota_size_for_a_domain"></a>Updating the quota size for a domain</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/quota/domains/{domainToBeUsed}/size
</pre></div></div>
<p>Resource name domainToBeUsed should be an existing domain.</p>
<p>The body can contain a fixed value or an unlimited value (-1):</p>
<div class="source">
<div class="source">
<pre>52
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: The quota has been updated</li>
<li>400: The body is not a positive integer neither an unlimited value (-1).</li>
<li>404: The domain does not exist</li>
<li>405: Domain Quota configuration not supported when virtual hosting is desactivated.</li>
</ul></section><section>
<h3><a name="Deleting_the_quota_size_for_a_domain"></a>Deleting the quota size for a domain</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/quota/domains/{domainToBeUsed}/size
</pre></div></div>
<p>Resource name domainToBeUsed should be an existing domain.</p>
<p>Response codes:</p>
<ul>
<li>204: The quota has been updated to unlimited value.</li>
<li>404: The domain does not exist</li>
</ul></section></section><section>
<h2><a name="Administrating_global_quotas"></a>Administrating global quotas</h2>
<ul>
<li><a href="#Getting_the_global_quota">Getting the global quota</a></li>
<li><a href="#Updating_global_quota">Updating global quota</a></li>
<li><a href="#Getting_the_global_quota_count">Getting the global quota count</a></li>
<li><a href="#Updating_the_global_quota_count">Updating the global quota count</a></li>
<li><a href="#Deleting_the_global_quota_count">Deleting the global quota count</a></li>
<li><a href="#Getting_the_global_quota_size">Getting the global quota size</a></li>
<li><a href="#Updating_the_global_quota_size">Updating the global quota size</a></li>
<li><a href="#Deleting_the_global_quota_size">Deleting the global quota size</a></li>
</ul><section>
<h3><a name="Getting_the_global_quota"></a>Getting the global quota</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/quota
</pre></div></div>
<p>The answer is the details of the global quota.</p>
<div class="source">
<div class="source">
<pre>{
&quot;count&quot;:252,
&quot;size&quot;:242
}
</pre></div></div>
<p>Note that quota object can contain a fixed value, an empty value (null) or an unlimited value (-1):</p>
<div class="source">
<div class="source">
<pre>{&quot;count&quot;:52,&quot;size&quot;:42}
{&quot;count&quot;:null,&quot;size&quot;:null}
{&quot;count&quot;:52,&quot;size&quot;:-1}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: The quota was successfully retrieved</li>
</ul></section><section>
<h3><a name="Updating_global_quota"></a>Updating global quota</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/quota
</pre></div></div>
<p>The body can contain a fixed value, an empty value (null) or an unlimited value (-1):</p>
<div class="source">
<div class="source">
<pre>{&quot;count&quot;:52,&quot;size&quot;:42}
{&quot;count&quot;:null,&quot;size&quot;:null}
{&quot;count&quot;:52,&quot;size&quot;:-1}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: The quota has been updated</li>
<li>400: The body is not a positive integer neither an unlimited value (-1).</li>
</ul></section><section>
<h3><a name="Getting_the_global_quota_count"></a>Getting the global quota count</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/quota/count
</pre></div></div>
<p>Resource name usernameToBeUsed should be an existing user</p>
<p>The answer looks like:</p>
<div class="source">
<div class="source">
<pre>52
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: The quota was successfully retrieved</li>
<li>204: No quota count limit is defined at the global level</li>
</ul></section><section>
<h3><a name="Updating_the_global_quota_count"></a>Updating the global quota count</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/quota/count
</pre></div></div>
<p>The body can contain a fixed value or an unlimited value (-1):</p>
<div class="source">
<div class="source">
<pre>52
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: The quota has been updated</li>
<li>400: The body is not a positive integer neither an unlimited value (-1).</li>
</ul></section><section>
<h3><a name="Deleting_the_global_quota_count"></a>Deleting the global quota count</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/quota/count
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: The quota has been updated to unlimited value.</li>
</ul></section><section>
<h3><a name="Getting_the_global_quota_size"></a>Getting the global quota size</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/quota/size
</pre></div></div>
<p>The answer looks like:</p>
<div class="source">
<div class="source">
<pre>52
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: The quota was successfully retrieved</li>
<li>204: No quota size limit is defined at the global level</li>
</ul></section><section>
<h3><a name="Updating_the_global_quota_size"></a>Updating the global quota size</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/quota/size
</pre></div></div>
<p>The body can contain a fixed value or an unlimited value (-1):</p>
<div class="source">
<div class="source">
<pre>52
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: The quota has been updated</li>
<li>400: The body is not a positive integer neither an unlimited value (-1).</li>
</ul></section><section>
<h3><a name="Deleting_the_global_quota_size"></a>Deleting the global quota size</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/quota/size
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: The quota has been updated to unlimited value.</li>
</ul></section></section><section>
<h2><a name="Cassandra_Schema_upgrades"></a>Cassandra Schema upgrades</h2>
<p>Cassandra upgrades implies the creation of a new table. Thus restarting James is needed, as new tables are created on restart.</p>
<p>Once done, we ship code that tries to read from new tables, and if not possible backs up to old tables. You can thus safely run without running additional migrations.</p>
<p>On the fly migration can be enabled. However, one might want to force the migration in a controlled fashion, and update automatically current schema version used (assess in the database old versions is no more used, as the corresponding tables are empty). Note that this process is safe: we ensure the service is not running concurrently on this James instance, that it does not bump version upon partial failures, that race condition in version upgrades will be idempotent, etc&#x2026;</p>
<p>These schema updates can be triggered by webadmin using the Cassandra backend.</p>
<p>Note that currently the progress can be tracked by logs.</p>
<ul>
<li><a href="#Retrieving_current_Cassandra_schema_version">Retrieving current Cassandra schema version</a></li>
<li><a href="#Retrieving_latest_available_Cassandra_schema_version">Retrieving latest available Cassandra schema version</a></li>
<li><a href="#Upgrading_to_a_specific_version">Upgrading to a specific version</a></li>
<li><a href="#Upgrading_to_the_latest_version">Upgrading to the latest version</a></li>
</ul><section>
<h3><a name="Retrieving_current_Cassandra_schema_version"></a>Retrieving current Cassandra schema version</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/cassandra/version
</pre></div></div>
<p>Will return:</p>
<div class="source">
<div class="source">
<pre>{&quot;version&quot;: 2}
</pre></div></div>
<p>Where the number corresponds to the current schema version of the database you are using.</p>
<p>Response codes:</p>
<ul>
<li>200: Success</li>
</ul></section><section>
<h3><a name="Retrieving_latest_available_Cassandra_schema_version"></a>Retrieving latest available Cassandra schema version</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/cassandra/version/latest
</pre></div></div>
<p>Will return:</p>
<div class="source">
<div class="source">
<pre>{&quot;version&quot;: 3}
</pre></div></div>
<p>Where the number corresponds to the latest available schema version of the database you are using. This means you can be migrating to this schema version.</p>
<p>Response codes:</p>
<ul>
<li>200: Success</li>
</ul></section><section>
<h3><a name="Upgrading_to_a_specific_version"></a>Upgrading to a specific version</h3>
<div class="source">
<div class="source">
<pre>curl -XPOST -H &quot;Content-Type: application/json http://ip:port/cassandra/version/upgrade -d '3'
</pre></div></div>
<p>Will schedule the run of the migrations you need to reach schema version 3.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes:</p>
<ul>
<li>200: Success. The scheduled task taskId is returned.</li>
<li>400: The version is invalid. The version should be a strictly positive number.</li>
<li>410: Error while planning this migration. This resource is gone away. Reason is mentionned in the body.</li>
</ul>
<p>Note that several calls to this endpoint will be run in a sequential pattern.</p>
<p>If the server restarts during the migration, the migration is silently aborted.</p>
<p>The scheduled task will have the following type cassandra-migration and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{&quot;targetVersion&quot;:3}
</pre></div></div>
</section><section>
<h3><a name="Upgrading_to_the_latest_version"></a>Upgrading to the latest version</h3>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/cassandra/version/upgrade/latest
</pre></div></div>
<p>Will schedule the run of the migrations you need to reach the latest schema version.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes:</p>
<ul>
<li>200: Success. The scheduled task taskId is returned.</li>
<li>410: Error while planning this migration. This resource is gone away. Reason is mentionned in the body.</li>
</ul>
<p>Note that several calls to this endpoint will be run in a sequential pattern.</p>
<p>If the server restarts during the migration, the migration is silently aborted.</p>
<p>The scheduled task will have the following type cassandra-migration and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{&quot;toVersion&quot;:2}
</pre></div></div>
</section></section><section>
<h2><a name="Correcting_ghost_mailbox"></a>Correcting ghost mailbox</h2>
<p>This is a temporary workaround for the <b>Ghost mailbox</b> bug encountered using the Cassandra backend, as described in MAILBOX-322.</p>
<p>You can use the mailbox merging feature in order to merge the old &#x201c;ghosted&#x201d; mailbox with the new one.</p>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/cassandra/mailbox/merging \
-d '{&quot;mergeOrigin&quot;:&quot;{id1}&quot;, &quot;mergeDestination&quot;:&quot;{id2}&quot;}' \
-H &quot;Content-Type: application/json&quot;
</pre></div></div>
<p>Will scedule a task for :</p>
<ul>
<li>Delete references to id1 mailbox</li>
<li>Move it&#x2019;s messages into id2 mailbox</li>
<li>Union the rights of both mailboxes</li>
</ul>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes:</p>
<ul>
<li>201: Task generation succeeded. Corresponding task id is returned.</li>
<li>400: Unable to parse the body.</li>
</ul>
<p>The scheduled task will have the following type mailbox-merging and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;oldMailboxId&quot;:&quot;5641376-02ed-47bd-bcc7-76ff6262d92a&quot;,
&quot;newMailboxId&quot;:&quot;4555159-52ae-895f-ccb7-586a4412fb50&quot;,
&quot;totalMessageCount&quot;: 1,
&quot;messageMovedCount&quot;: 1,
&quot;messageFailedCount&quot;: 0
}
</pre></div></div>
</section><section>
<h2><a name="Creating_address_group"></a>Creating address group</h2>
<p>You can use <b>webadmin</b> to define address groups.</p>
<p>When a specific email is sent to the group mail address, every group member will receive it.</p>
<p>Note that the group mail address is virtual: it does not correspond to an existing user.</p>
<p>This feature uses <a href="/server/config-recipientrewritetable.html">Recipients rewrite table</a> and requires the <a class="externalLink" href="https://github.com/apache/james-project/blob/master/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTable.java">RecipientRewriteTable mailet</a> to be configured.</p>
<p>Note that email addresses are restricted to ASCII character set. Mail addresses not matching this criteria will be rejected.</p>
<ul>
<li><a href="#Listing_groups">Listing groups</a></li>
<li><a href="#Listing_members_of_a_group">Listing members of a group</a></li>
<li><a href="#Adding_a_group_member">Adding a group member</a></li>
<li><a href="#Removing_a_group_member">Removing a group member</a></li>
</ul><section>
<h3><a name="Listing_groups"></a>Listing groups</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/address/groups
</pre></div></div>
<p>Will return the groups as a list of JSON Strings representing mail addresses. For instance:</p>
<div class="source">
<div class="source">
<pre>[&quot;group1@domain.com&quot;, &quot;group2@domain.com&quot;]
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: Success</li>
</ul></section><section>
<h3><a name="Listing_members_of_a_group"></a>Listing members of a group</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/address/groups/group@domain.com
</pre></div></div>
<p>Will return the group members as a list of JSON Strings representing mail addresses. For instance:</p>
<div class="source">
<div class="source">
<pre>[&quot;member1@domain.com&quot;, &quot;member2@domain.com&quot;]
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: Success</li>
<li>400: Group structure is not valid</li>
<li>404: The group does not exist</li>
</ul></section><section>
<h3><a name="Adding_a_group_member"></a>Adding a group member</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/address/groups/group@domain.com/member@domain.com
</pre></div></div>
<p>Will add <a class="externalLink" href="mailto:member@domain.com">member@domain.com</a> to <a class="externalLink" href="mailto:group@domain.com">group@domain.com</a>, creating the group if needed</p>
<p>Response codes:</p>
<ul>
<li>204: Success</li>
<li>400: Group structure or member is not valid</li>
<li>400: Domain in the source is not managed by the DomainList</li>
<li>409: Requested group address is already used for another purpose</li>
<li>409: The addition of the group member would lead to a loop and thus cannot be performed</li>
</ul></section><section>
<h3><a name="Removing_a_group_member"></a>Removing a group member</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/address/groups/group@domain.com/member@domain.com
</pre></div></div>
<p>Will remove <a class="externalLink" href="mailto:member@domain.com">member@domain.com</a> from <a class="externalLink" href="mailto:group@domain.com">group@domain.com</a>, removing the group if group is empty after deletion</p>
<p>Response codes:</p>
<ul>
<li>204: Success</li>
<li>400: Group structure or member is not valid</li>
</ul></section></section><section>
<h2><a name="Creating_address_forwards"></a>Creating address forwards</h2>
<p>You can use <b>webadmin</b> to define address forwards.</p>
<p>When a specific email is sent to the base mail address, every forward destination addresses will receive it.</p>
<p>Please note that the base address can be optionaly part of the forward destination. In that case, the base recipient also receive a copy of the mail. Otherwise he is ommitted.</p>
<p>Forwards can be defined for existing users. It then defers from &#x201c;groups&#x201d;.</p>
<p>This feature uses <a href="/server/config-recipientrewritetable.html">Recipients rewrite table</a> and requires the <a class="externalLink" href="https://github.com/apache/james-project/blob/master/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTable.java">RecipientRewriteTable mailet</a> to be configured.</p>
<p>Note that email addresses are restricted to ASCII character set. Mail addresses not matching this criteria will be rejected.</p>
<ul>
<li><a href="#Listing_Forwards">Listing Forwards</a></li>
<li><a href="#Listing_destinations_in_a_forward">Listing destinations in a forward</a></li>
<li><a href="#Adding_a_new_destination_to_a_forward">Adding a new destination to a forward</a></li>
<li><a href="#Removing_a_destination_of_a_forward">Removing a destination of a forward</a></li>
</ul><section>
<h3><a name="Listing_Forwards"></a>Listing Forwards</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/address/forwards
</pre></div></div>
<p>Will return the users having forwards configured as a list of JSON Strings representing mail addresses. For instance:</p>
<div class="source">
<div class="source">
<pre>[&quot;user1@domain.com&quot;, &quot;user2@domain.com&quot;]
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: Success</li>
</ul></section><section>
<h3><a name="Listing_destinations_in_a_forward"></a>Listing destinations in a forward</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/address/forwards/user@domain.com
</pre></div></div>
<p>Will return the destination addresses of this forward as a list of JSON Strings representing mail addresses. For instance:</p>
<div class="source">
<div class="source">
<pre>[
{&quot;mailAddress&quot;:&quot;destination1@domain.com&quot;},
{&quot;mailAddress&quot;:&quot;destination2@domain.com&quot;}
]
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: Success</li>
<li>400: Forward structure is not valid</li>
<li>404: The given user don&#x2019;t have forwards or does not exist</li>
</ul></section><section>
<h3><a name="Adding_a_new_destination_to_a_forward"></a>Adding a new destination to a forward</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/address/forwards/user@domain.com/targets/destination@domain.com
</pre></div></div>
<p>Will add <a class="externalLink" href="mailto:destination@domain.com">destination@domain.com</a> to <a class="externalLink" href="mailto:user@domain.com">user@domain.com</a>, creating the forward if needed</p>
<p>Response codes:</p>
<ul>
<li>204: Success</li>
<li>400: Forward structure or member is not valid</li>
<li>400: Domain in the source is not managed by the DomainList</li>
<li>404: Requested forward address does not match an existing user</li>
<li>409: The creation of the forward would lead to a loop and thus cannot be performed</li>
</ul></section><section>
<h3><a name="Removing_a_destination_of_a_forward"></a>Removing a destination of a forward</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/address/forwards/user@domain.com/targets/destination@domain.com
</pre></div></div>
<p>Will remove <a class="externalLink" href="mailto:destination@domain.com">destination@domain.com</a> from <a class="externalLink" href="mailto:user@domain.com">user@domain.com</a>, removing the forward if forward is empty after deletion</p>
<p>Response codes:</p>
<ul>
<li>204: Success</li>
<li>400: Forward structure or member is not valid</li>
</ul></section></section><section>
<h2><a name="Creating_address_aliases"></a>Creating address aliases</h2>
<p>You can use <b>webadmin</b> to define aliases for an user.</p>
<p>When a specific email is sent to the alias address, the destination address of the alias will receive it.</p>
<p>Aliases can be defined for existing users.</p>
<p>This feature uses <a href="/server/config-recipientrewritetable.html">Recipients rewrite table</a> and requires the <a class="externalLink" href="https://github.com/apache/james-project/blob/master/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTable.java">RecipientRewriteTable mailet</a> to be configured.</p>
<p>Note that email addresses are restricted to ASCII character set. Mail addresses not matching this criteria will be rejected.</p>
<ul>
<li><a href="#Listing_users_with_aliases">Listing users with aliases</a></li>
<li><a href="#Listing_alias_sources_of_an_user">Listing alias sources of an user</a></li>
<li><a href="#Adding_a_new_alias_to_an_user">Adding a new alias to an user</a></li>
<li><a href="#Removing_an_alias_of_an_user">Removing an alias of an user</a></li>
</ul><section>
<h3><a name="Listing_users_with_aliases"></a>Listing users with aliases</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/address/aliases
</pre></div></div>
<p>Will return the users having aliases configured as a list of JSON Strings representing mail addresses. For instance:</p>
<div class="source">
<div class="source">
<pre>[&quot;user1@domain.com&quot;, &quot;user2@domain.com&quot;]
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: Success</li>
</ul></section><section>
<h3><a name="Listing_alias_sources_of_an_user"></a>Listing alias sources of an user</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/address/aliases/user@domain.com
</pre></div></div>
<p>Will return the aliases of this user as a list of JSON Strings representing mail addresses. For instance:</p>
<div class="source">
<div class="source">
<pre>[
{&quot;source&quot;:&quot;alias1@domain.com&quot;},
{&quot;source&quot;:&quot;alias2@domain.com&quot;}
]
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: Success</li>
<li>400: Alias structure is not valid</li>
</ul></section><section>
<h3><a name="Adding_a_new_alias_to_an_user"></a>Adding a new alias to an user</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/address/aliases/user@domain.com/sources/alias@domain.com
</pre></div></div>
<p>Will add <a class="externalLink" href="mailto:alias@domain.com">alias@domain.com</a> to <a class="externalLink" href="mailto:user@domain.com">user@domain.com</a>, creating the alias if needed</p>
<p>Response codes:</p>
<ul>
<li>204: OK</li>
<li>400: Alias structure or member is not valid</li>
<li>400: The alias source exists as an user already</li>
<li>400: Source and destination can&#x2019;t be the same!</li>
<li>400: Domain in the destination or source is not managed by the DomainList</li>
<li>409: The creation of the alias would lead to a loop and thus cannot be performed</li>
</ul></section><section>
<h3><a name="Removing_an_alias_of_an_user"></a>Removing an alias of an user</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/address/aliases/user@domain.com/sources/alias@domain.com
</pre></div></div>
<p>Will remove <a class="externalLink" href="mailto:alias@domain.com">alias@domain.com</a> from <a class="externalLink" href="mailto:user@domain.com">user@domain.com</a>, removing the alias if needed</p>
<p>Response codes:</p>
<ul>
<li>204: OK</li>
<li>400: Alias structure or member is not valid</li>
</ul></section></section><section>
<h2><a name="Creating_domain_mappings"></a>Creating domain mappings</h2>
<p>You can use <b>webadmin</b> to define domain mappings.</p>
<p>Given a configured source (from) domain and a destination (to) domain, when an email is sent to an address belonging to the source domain, then the domain part of this address is overwritten, the destination domain is then used. A source (from) domain can have many destination (to) domains.</p>
<p>For example: with a source domain james.apache.org maps to two destination domains james.org and apache-james.org, when a mail is sent to admin@james.apache.org, then it will be routed to admin@james.org and admin@apache-james.org</p>
<p>This feature uses <a href="/server/config-recipientrewritetable.html">Recipients rewrite table</a> and requires the <a class="externalLink" href="https://github.com/apache/james-project/blob/master/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTable.java">RecipientRewriteTable mailet</a> to be configured.</p>
<p>Note that email addresses are restricted to ASCII character set. Mail addresses not matching this criteria will be rejected.</p>
<ul>
<li><a href="#Listing_all_domain_mappings">Listing all domain mappings</a></li>
<li><a href="#Listing_all_destination_domains_for_a_source_domain">Listing all destination domains for a source domain</a></li>
<li><a href="#Adding_a_domain_mapping">Adding a domain mapping</a></li>
<li><a href="#Removing_a_domain_mapping">Removing a domain mapping</a></li>
</ul><section>
<h3><a name="Listing_all_domain_mappings"></a>Listing all domain mappings</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/domainMappings
</pre></div></div>
<p>Will return all configured domain mappings</p>
<div class="source">
<div class="source">
<pre>{
&quot;firstSource.org&quot; : [&quot;firstDestination.com&quot;, &quot;secondDestination.net&quot;],
&quot;secondSource.com&quot; : [&quot;thirdDestination.com&quot;, &quot;fourthDestination.net&quot;],
}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: OK</li>
</ul></section><section>
<h3><a name="Listing_all_destination_domains_for_a_source_domain"></a>Listing all destination domains for a source domain</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/domainMappings/sourceDomain.tld
</pre></div></div>
<p>With sourceDomain.tld as the value passed to fromDomain resource name, the API will return all destination domains configured to that domain</p>
<div class="source">
<div class="source">
<pre>[&quot;firstDestination.com&quot;, &quot;secondDestination.com&quot;]
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: OK</li>
<li>400: The fromDomain resource name is invalid</li>
<li>404: The fromDomain resource name is not found</li>
</ul></section><section>
<h3><a name="Adding_a_domain_mapping"></a>Adding a domain mapping</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/domainMappings/sourceDomain.tld
</pre></div></div>
<p>Body:</p>
<div class="source">
<div class="source">
<pre>destination.tld
</pre></div></div>
<p>With sourceDomain.tld as the value passed to fromDomain resource name, the API will add a destination domain specified in the body to that domain</p>
<p>Response codes:</p>
<ul>
<li>204: OK</li>
<li>400: The fromDomain resource name is invalid</li>
<li>400: The destination domain specified in the body is invalid</li>
</ul>
<p>Be aware that no checks to find possible loops that would result of this creation will be performed.</p></section><section>
<h3><a name="Removing_a_domain_mapping"></a>Removing a domain mapping</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/domainMappings/sourceDomain.tld
</pre></div></div>
<p>Body:</p>
<div class="source">
<div class="source">
<pre>destination.tld
</pre></div></div>
<p>With sourceDomain.tld as the value passed to fromDomain resource name, the API will remove a destination domain specified in the body mapped to that domain</p>
<p>Response codes:</p>
<ul>
<li>204: OK</li>
<li>400: The fromDomain resource name is invalid</li>
<li>400: The destination domain specified in the body is invalid</li>
</ul></section></section><section>
<h2><a name="Creating_regex_mapping"></a>Creating regex mapping</h2>
<p>You can use <b>webadmin</b> to create regex mappings.</p>
<p>A regex mapping contains a mapping source and a Java Regular Expression (regex) in String as the mapping value. Everytime, if a mail containing a recipient matched with the mapping source, then that mail will be re-routed to a new recipient address which is re written by the regex.</p>
<p>This feature uses <a href="/server/config-recipientrewritetable.html">Recipients rewrite table</a> and requires the <a class="externalLink" href="https://github.com/apache/james-project/blob/master/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTable.java">RecipientRewriteTable API</a> to be configured.</p>
<ul>
<li><a href="#Adding_a_regex_mapping">Adding a regex mapping</a></li>
<li><a href="#Removing_a_regex_mapping">Removing a regex mapping</a></li>
</ul><section>
<h3><a name="Adding_a_regex_mapping"></a>Adding a regex mapping</h3>
<div class="source">
<div class="source">
<pre>POST /mappings/regex/mappingSource/targets/regex
</pre></div></div>
<p>Where:</p>
<ul>
<li>the mappingSource is the path parameter represents for the Regex Mapping mapping source</li>
<li>the regex is the path parameter represents for the Regex Mapping regex</li>
</ul>
<p>The route will add a regex mapping made from mappingSource and regex to RecipientRewriteTable.</p>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/mappings/regex/james@domain.tld/targets/james@.*:james-intern@james.org
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: Mapping added successfully.</li>
<li>400: Invalid mappingSource path parameter.</li>
<li>400: Invalid regex path parameter.</li>
</ul>
<p>Be aware that no checks to find possible loops that would result of this creation will be performed.</p></section><section>
<h3><a name="Removing_a_regex_mapping"></a>Removing a regex mapping</h3>
<div class="source">
<div class="source">
<pre>DELETE /mappings/regex/{mappingSource}/targets/{regex}
</pre></div></div>
<p>Where:</p>
<ul>
<li>the mappingSource is the path parameter representing the Regex Mapping mapping source</li>
<li>the regex is the path parameter representing the Regex Mapping regex</li>
</ul>
<p>The route will remove the regex mapping made from regex from the mapping source mappingSource to RecipientRewriteTable.</p>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/mappings/regex/james@domain.tld/targets/[O_O]:james-intern@james.org
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: Mapping deleted successfully.</li>
<li>400: Invalid mappingSource path parameter.</li>
<li>400: Invalid regex path parameter.</li>
</ul></section></section><section>
<h2><a name="Address_Mappings"></a>Address Mappings</h2>
<p>You can use <b>webadmin</b> to define address mappings.</p>
<p>When a specific email is sent to the base mail address, every destination addresses will receive it.</p>
<p>This feature uses <a href="/server/config-recipientrewritetable.html">Recipients rewrite table</a> and requires the <a class="externalLink" href="https://github.com/apache/james-project/blob/master/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTable.java">RecipientRewriteTable mailet</a> to be configured.</p>
<p>Note that email addresses are restricted to ASCII character set. Mail addresses not matching this criteria will be rejected.</p>
<p>Please use address mappings with caution, as it&#x2019;s not a typed address. If you know the type of your address (forward, alias, domain, group, etc), prefer using the corresponding routes to those types.</p>
<p>Here are the following actions available on address mappings:</p>
<ul>
<li><a href="#List_all_address_mappings">List all address mappings</a></li>
<li><a href="#Add_an_address_mapping">Add an address mapping</a></li>
<li><a href="#Remove_an_address_mapping">Remove an address mapping</a></li>
</ul><section>
<h3><a name="List_all_address_mappings"></a>List all address mappings</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/mappings
</pre></div></div>
<p>Get all mappings from the <a href="/server/config-recipientrewritetable.html">Recipients rewrite table</a> Supported mapping types are the following:</p>
<ul>
<li><a href="#Creating_address_aliases">Alias</a></li>
<li><a href="#Address_Mappings">Address</a></li>
<li><a href="#Creating_address_domain">Domain</a></li>
<li>Error</li>
<li><a href="#Creating_address_forwards">Forward</a></li>
<li><a href="#Creating_address_group">Group</a></li>
<li>Regex</li>
</ul>
<p>Response body:</p>
<div class="source">
<div class="source">
<pre>{
&quot;alias@domain.tld&quot;: [
{
&quot;type&quot;: &quot;Alias&quot;,
&quot;mapping&quot;: &quot;user@domain.tld&quot;
},
{
&quot;type&quot;: &quot;Group&quot;,
&quot;mapping&quot;: &quot;group-user@domain.tld&quot;
}
],
&quot;aliasdomain.tld&quot;: [
{
&quot;type&quot;: &quot;Domain&quot;,
&quot;mapping&quot;: &quot;realdomain.tld&quot;
}
],
&quot;group@domain.tld&quot;: [
{
&quot;type&quot;: &quot;Address&quot;,
&quot;mapping&quot;: &quot;user@domain.tld&quot;
}
]
}
</pre></div></div>
<p>Response code:</p>
<ul>
<li>200: OK</li>
</ul></section><section>
<h3><a name="Add_an_address_mapping"></a>Add an address mapping</h3>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/mappings/address/{mappingSource}/targets/{destinationAddress}
</pre></div></div>
<p>Add an address mapping to the <a href="/server/config-recipientrewritetable.html">Recipients rewrite table</a> Mapping source is the value of {mappingSource} Mapping destination is the value of {destinationAddress} Type of mapping destination is Address</p>
<p>Response codes:</p>
<ul>
<li>204: Action successfully performed</li>
<li>400: Invalid parameters</li>
<li>409: The creation of the address mapping would lead to a loop and thus cannot be performed</li>
</ul></section><section>
<h3><a name="Remove_an_address_mapping"></a>Remove an address mapping</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/mappings/address/{mappingSource}/targets/{destinationAddress}
</pre></div></div>
<ul>
<li>Remove an address mapping from the <a href="/server/config-recipientrewritetable.html">Recipients rewrite table</a></li>
<li>Mapping source is the value of mappingSource</li>
<li>Mapping destination is the value of destinationAddress</li>
<li>Type of mapping destination is Address</li>
</ul>
<p>Response codes:</p>
<ul>
<li>204: Action successfully performed</li>
<li>400: Invalid parameters</li>
</ul></section></section><section>
<h2><a name="User_Mappings"></a>User Mappings</h2>
<ul>
<li><a href="#Listing_User_Mappings">Listing User Mappings</a></li>
</ul><section>
<h3><a name="Listing_User_Mappings"></a>Listing User Mappings</h3>
<p>This endpoint allows receiving all mappings of a corresponding user.</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/mappings/user/{userAddress}
</pre></div></div>
<p>Return all mappings of a user where:</p>
<ul>
<li>userAddress: is the selected user</li>
</ul>
<p>Response body:</p>
<div class="source">
<div class="source">
<pre>[
{
&quot;type&quot;: &quot;Address&quot;,
&quot;mapping&quot;: &quot;user123@domain.tld&quot;
},
{
&quot;type&quot;: &quot;Alias&quot;,
&quot;mapping&quot;: &quot;aliasuser123@domain.tld&quot;
},
{
&quot;type&quot;: &quot;Group&quot;,
&quot;mapping&quot;: &quot;group123@domain.tld&quot;
}
]
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: OK</li>
<li>400: Invalid parameter value</li>
</ul></section></section><section>
<h2><a name="Administrating_mail_repositories"></a>Administrating mail repositories</h2>
<ul>
<li><a href="#Create_a_mail_repository">Create a mail repository</a></li>
<li><a href="#Listing_mail_repositories">Listing mail repositories</a></li>
<li><a href="#Getting_additional_information_for_a_mail_repository">Getting additional information for a mail repository</a></li>
<li><a href="#Listing_mails_contained_in_a_mail_repository">Listing mails contained in a mail repository</a></li>
<li><a href="#Reading.2Fdownloading_a_mail_details">Reading/downloading a mail details</a></li>
<li><a href="#Removing_a_mail_from_a_mail_repository">Removing a mail from a mail repository</a></li>
<li><a href="#Removing_all_mails_from_a_mail_repository">Removing all mails from a mail repository</a></li>
<li><a href="#Reprocessing_mails_from_a_mail_repository">Reprocessing mails from a mail repository</a></li>
<li><a href="#Reprocessing_a_specific_mail_from_a_mail_repository">Reprocessing a specific mail from a mail repository</a></li>
</ul><section>
<h3><a name="Create_a_mail_repository"></a>Create a mail repository</h3>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/mailRepositories/{encodedPathOfTheRepository}?protocol={someProtocol}
</pre></div></div>
<p>Resource name encodedPathOfTheRepository should be the resource path of the created mail repository. Example:</p>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/mailRepositories/mailRepo?protocol=file
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: The repository is created</li>
</ul></section><section>
<h3><a name="Listing_mail_repositories"></a>Listing mail repositories</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/mailRepositories
</pre></div></div>
<p>The answer looks like:</p>
<div class="source">
<div class="source">
<pre>[
{
&quot;repository&quot;: &quot;var/mail/error/&quot;,
&quot;path&quot;: &quot;var%2Fmail%2Ferror%2F&quot;
},
{
&quot;repository&quot;: &quot;var/mail/relay-denied/&quot;,
&quot;path&quot;: &quot;var%2Fmail%2Frelay-denied%2F&quot;
},
{
&quot;repository&quot;: &quot;var/mail/spam/&quot;,
&quot;path&quot;: &quot;var%2Fmail%2Fspam%2F&quot;
},
{
&quot;repository&quot;: &quot;var/mail/address-error/&quot;,
&quot;path&quot;: &quot;var%2Fmail%2Faddress-error%2F&quot;
}
]
</pre></div></div>
<p>You can use id, the encoded URL of the repository, to access it in later requests.</p>
<p>Response codes:</p>
<ul>
<li>200: The list of mail repositories</li>
</ul></section><section>
<h3><a name="Getting_additional_information_for_a_mail_repository"></a>Getting additional information for a mail repository</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/mailRepositories/{encodedPathOfTheRepository}
</pre></div></div>
<p>Resource name encodedPathOfTheRepository should be the resource path of an existing mail repository. Example:</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/mailRepositories/var%2Fmail%2Ferror%2F
</pre></div></div>
<p>The answer looks like:</p>
<div class="source">
<div class="source">
<pre>{
&quot;repository&quot;: &quot;var/mail/error/&quot;,
&quot;path&quot;: &quot;mail%2Ferror%2F&quot;,
&quot;size&quot;: 243
}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: Additonnal information for that repository</li>
<li>404: This repository can not be found</li>
</ul></section><section>
<h3><a name="Listing_mails_contained_in_a_mail_repository"></a>Listing mails contained in a mail repository</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/mailRepositories/{encodedPathOfTheRepository}/mails
</pre></div></div>
<p>Resource name encodedPathOfTheRepository should be the resource path of an existing mail repository. Example:</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/mailRepositories/var%2Fmail%2Ferror%2F/mails
</pre></div></div>
<p>The answer will contains all mailKey contained in that repository.</p>
<div class="source">
<div class="source">
<pre>[
&quot;mail-key-1&quot;,
&quot;mail-key-2&quot;,
&quot;mail-key-3&quot;
]
</pre></div></div>
<p>Note that this can be used to read mail details.</p>
<p>You can pass additional URL parameters to this call in order to limit the output: - A limit: no more elements than the specified limit will be returned. This needs to be strictly positive. If no value is specified, no limit will be applied. - An offset: allow to skip elements. This needs to be positive. Default value is zero.</p>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>curl -XGET 'http://ip:port/mailRepositories/var%2Fmail%2Ferror%2F/mails?limit=100&amp;offset=500'
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: The list of mail keys contained in that mail repository</li>
<li>400: Invalid parameters</li>
<li>404: This repository can not be found</li>
</ul></section><section>
<h3><a name="Reading.2Fdownloading_a_mail_details"></a>Reading/downloading a mail details</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/mailRepositories/{encodedPathOfTheRepository}/mails/mailKey
</pre></div></div>
<p>Resource name encodedPathOfTheRepository should be the resource path of an existing mail repository. Resource name mailKey should be the key of a mail stored in that repository. Example:</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/mailRepositories/var%2Fmail%2Ferror%2F/mails/mail-key-1
</pre></div></div>
<p>If the Accept header in the request is &#x201c;application/json&#x201d;, then the response looks like:</p>
<div class="source">
<div class="source">
<pre>{
&quot;name&quot;: &quot;mail-key-1&quot;,
&quot;sender&quot;: &quot;sender@domain.com&quot;,
&quot;recipients&quot;: [&quot;recipient1@domain.com&quot;, &quot;recipient2@domain.com&quot;],
&quot;state&quot;: &quot;address-error&quot;,
&quot;error&quot;: &quot;A small message explaining what happened to that mail...&quot;,
&quot;remoteHost&quot;: &quot;111.222.333.444&quot;,
&quot;remoteAddr&quot;: &quot;127.0.0.1&quot;,
&quot;lastUpdated&quot;: null
}
</pre></div></div>
<p>If the Accept header in the request is &#x201c;message/rfc822&#x201d;, then the response will be the <i>eml</i> file itself.</p>
<p>Additional query parameter additionalFields add the existing information to the response for the supported values (only work with &#x201c;application/json&#x201d; Accept header):</p>
<ul>
<li>attributes</li>
<li>headers</li>
<li>textBody</li>
<li>htmlBody</li>
<li>messageSize</li>
<li>perRecipientsHeaders</li>
</ul>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/mailRepositories/file%3A%2F%2Fvar%2Fmail%2Ferror%2F/mails/mail-key-1?additionalFields=attributes,headers,textBody,htmlBody,messageSize,perRecipientsHeaders
</pre></div></div>
<p>Give the following kind of response:</p>
<div class="source">
<div class="source">
<pre>{
&quot;name&quot;: &quot;mail-key-1&quot;,
&quot;sender&quot;: &quot;sender@domain.com&quot;,
&quot;recipients&quot;: [&quot;recipient1@domain.com&quot;, &quot;recipient2@domain.com&quot;],
&quot;state&quot;: &quot;address-error&quot;,
&quot;error&quot;: &quot;A small message explaining what happened to that mail...&quot;,
&quot;remoteHost&quot;: &quot;111.222.333.444&quot;,
&quot;remoteAddr&quot;: &quot;127.0.0.1&quot;,
&quot;lastUpdated&quot;: null,
&quot;attributes&quot;: {
&quot;name2&quot;: &quot;value2&quot;,
&quot;name1&quot;: &quot;value1&quot;
},
&quot;perRecipientsHeaders&quot;: {
&quot;third@party&quot;: {
&quot;headerName1&quot;: [
&quot;value1&quot;,
&quot;value2&quot;
],
&quot;headerName2&quot;: [
&quot;value3&quot;,
&quot;value4&quot;
]
}
},
&quot;headers&quot;: {
&quot;headerName4&quot;: [
&quot;value6&quot;,
&quot;value7&quot;
],
&quot;headerName3&quot;: [
&quot;value5&quot;,
&quot;value8&quot;
]
},
&quot;textBody&quot;: &quot;My body!!&quot;,
&quot;htmlBody&quot;: &quot;My &lt;em&gt;body&lt;/em&gt;!!&quot;,
&quot;messageSize&quot;: 42424242
}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: Details of the mail</li>
<li>404: This repository or mail can not be found</li>
</ul></section><section>
<h3><a name="Removing_a_mail_from_a_mail_repository"></a>Removing a mail from a mail repository</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/mailRepositories/{encodedPathOfTheRepository}/mails/mailKey
</pre></div></div>
<p>Resource name encodedPathOfTheRepository should be the resource path of an existing mail repository. Resource name mailKey should be the key of a mail stored in that repository. Example:</p>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/mailRepositories/var%2Fmail%2Ferror%2F/mails/mail-key-1
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: This mail no longer exists in this repository</li>
<li>404: This repository can not be found</li>
</ul></section><section>
<h3><a name="Removing_all_mails_from_a_mail_repository"></a>Removing all mails from a mail repository</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/mailRepositories/{encodedPathOfTheRepository}/mails
</pre></div></div>
<p>Resource name encodedPathOfTheRepository should be the resource path of an existing mail repository. Example:</p>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/mailRepositories/var%2Fmail%2Ferror%2F/mails
</pre></div></div>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes:</p>
<ul>
<li>201: Task generation succeeded. Corresponding task id is returned.</li>
<li>404: Could not find that mail repository</li>
</ul>
<p>The scheduled task will have the following type clear-mail-repository and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;mailRepositoryPath&quot;:&quot;var/mail/error/&quot;,
&quot;initialCount&quot;: 243,
&quot;remainingCount&quot;: 17
}
</pre></div></div>
</section><section>
<h3><a name="Reprocessing_mails_from_a_mail_repository"></a>Reprocessing mails from a mail repository</h3>
<p>Sometime, you want to re-process emails stored in a mail repository. For instance, you can make a configuration error, or there can be a James bug that makes processing of some mails fail. Those mail will be stored in a mail repository. Once you solved the problem, you can reprocess them.</p>
<p>To reprocess mails from a repository:</p>
<div class="source">
<div class="source">
<pre>curl -XPATCH http://ip:port/mailRepositories/{encodedPathOfTheRepository}/mails?action=reprocess
</pre></div></div>
<p>Resource name encodedPathOfTheRepository should be the resource path of an existing mail repository. Example:</p>
<p>For instance:</p>
<div class="source">
<div class="source">
<pre>curl -XPATCH http://ip:port/mailRepositories/var%2Fmail%2Ferror%2F/mails?action=reprocess
</pre></div></div>
<p>Additional query parameters are supported: - queue allows you to target the mail queue you want to enqueue the mails in. Defaults to spool. - processor allows you to overwrite the state of the reprocessing mails, and thus select the processors they will start their processing in. Defaults to the state field of each processed email.</p>
<p>For instance:</p>
<div class="source">
<div class="source">
<pre>curl -XPATCH 'http://ip:port/mailRepositories/var%2Fmail%2Ferror%2F/mails?action=reprocess&amp;processor=transport&amp;queue=spool'
</pre></div></div>
<p>Note that the action query parameter is compulsary and can only take value reprocess.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes:</p>
<ul>
<li>201: Task generation succeeded. Corresponding task id is returned.</li>
<li>404: Could not find that mail repository</li>
</ul>
<p>The scheduled task will have the following type reprocessing-all and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;mailRepositoryPath&quot;:&quot;var/mail/error/&quot;,
&quot;targetQueue&quot;:&quot;spool&quot;,
&quot;targetProcessor&quot;:&quot;transport&quot;,
&quot;initialCount&quot;: 243,
&quot;remainingCount&quot;: 17
}
</pre></div></div>
</section><section>
<h3><a name="Reprocessing_a_specific_mail_from_a_mail_repository"></a>Reprocessing a specific mail from a mail repository</h3>
<p>To reprocess a specific mail from a mail repository:</p>
<div class="source">
<div class="source">
<pre>curl -XPATCH http://ip:port/mailRepositories/{encodedPathOfTheRepository}/mails/mailKey?action=reprocess
</pre></div></div>
<p>Resource name encodedPathOfTheRepository should be the resource id of an existing mail repository. Resource name mailKey should be the key of a mail stored in that repository. Example:</p>
<p>For instance:</p>
<div class="source">
<div class="source">
<pre>curl -XPATCH http://ip:port/mailRepositories/var%2Fmail%2Ferror%2F/mails/name1?action=reprocess
</pre></div></div>
<p>Additional query parameters are supported: - queue allows you to target the mail queue you want to enqueue the mails in. Defaults to spool. - processor allows you to overwrite the state of the reprocessing mails, and thus select the processors they will start their processing in. Defaults to the state field of each processed email.</p>
<p>While processor being an optional parameter, not specifying it will result reprocessing the mails in their current state (<a class="externalLink" href="https://james.apache.org/server/feature-mailetcontainer.html#Processors">see documentation about processors and state</a>). Consequently, only few cases will give a different result, definitively storing them out of the mail repository.</p>
<p>For instance:</p>
<div class="source">
<div class="source">
<pre>curl -XPATCH 'http://ip:port/mailRepositories/var%2Fmail%2Ferror%2F/mails/name1?action=reprocess&amp;processor=transport&amp;queue=spool'
</pre></div></div>
<p>Note that the action query parameter is compulsary and can only take value reprocess.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes:</p>
<ul>
<li>201: Task generation succeeded. Corresponding task id is returned.</li>
<li>404: Could not find that mail repository</li>
</ul>
<p>The scheduled task will have the following type reprocessing-one and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;mailRepositoryPath&quot;:&quot;var/mail/error/&quot;,
&quot;targetQueue&quot;:&quot;spool&quot;,
&quot;targetProcessor&quot;:&quot;transport&quot;,
&quot;mailKey&quot;:&quot;name1&quot;
}
</pre></div></div>
</section></section><section>
<h2><a name="Administrating_mail_queues"></a>Administrating mail queues</h2>
<ul>
<li><a href="#Listing_mail_queues">Listing mail queues</a></li>
<li><a href="#Getting_a_mail_queue_details">Getting a mail queue details</a></li>
<li><a href="#Listing_the_mails_of_a_mail_queue">Listing the mails of a mail queue</a></li>
<li><a href="#Deleting_mails_from_a_mail_queue">Deleting mails from a mail queue</a></li>
<li><a href="#Clearing_a_mail_queue">Clearing a mail queue</a></li>
<li><a href="#Flushing_mails_from_a_mail_queue">Flushing mails from a mail queue</a></li>
<li><a href="#RabbitMQ_republishing_a_mail_queue_from_cassandra">RabbitMQ republishing a mail queue from cassandra</a></li>
</ul><section>
<h3><a name="Listing_mail_queues"></a>Listing mail queues</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/mailQueues
</pre></div></div>
<p>The answer looks like:</p>
<div class="source">
<div class="source">
<pre>[&quot;outgoing&quot;,&quot;spool&quot;]
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: The list of mail queues</li>
</ul></section><section>
<h3><a name="Getting_a_mail_queue_details"></a>Getting a mail queue details</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/mailQueues/{mailQueueName}
</pre></div></div>
<p>Resource name mailQueueName is the name of a mail queue, this command will return the details of the given mail queue. For instance:</p>
<div class="source">
<div class="source">
<pre>{&quot;name&quot;:&quot;outgoing&quot;,&quot;size&quot;:0}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: Success</li>
<li>400: Mail queue is not valid</li>
<li>404: The mail queue does not exist</li>
</ul></section><section>
<h3><a name="Listing_the_mails_of_a_mail_queue"></a>Listing the mails of a mail queue</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/mailQueues/{mailQueueName}/mails
</pre></div></div>
<p>Additional URL query parameters:</p>
<ul>
<li>limit: Maximum number of mails returned in a single call. Only strictly positive integer values are accepted. Example:</li>
</ul>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/mailQueues/{mailQueueName}/mails?limit=100
</pre></div></div>
<p>The answer looks like:</p>
<div class="source">
<div class="source">
<pre>[{
&quot;name&quot;: &quot;Mail1516976156284-8b3093b9-eebf-4c40-9c26-1450f4fcdc3c-to-test.com&quot;,
&quot;sender&quot;: &quot;user@james.linagora.com&quot;,
&quot;recipients&quot;: [&quot;someone@test.com&quot;],
&quot;nextDelivery&quot;: &quot;1969-12-31T23:59:59.999Z&quot;
}]
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: Success</li>
<li>400: Mail queue is not valid or limit is invalid</li>
<li>404: The mail queue does not exist</li>
</ul></section><section>
<h3><a name="Deleting_mails_from_a_mail_queue"></a>Deleting mails from a mail queue</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/mailQueues/{mailQueueName}/mails?sender=senderMailAddress
</pre></div></div>
<p>This request should have exactly one query parameter from the following list:</p>
<ul>
<li>sender: which is a mail address (i.e. <a class="externalLink" href="mailto:sender@james.org">sender@james.org</a>)</li>
<li>name: which is a string</li>
<li>recipient: which is a mail address (i.e. <a class="externalLink" href="mailto:recipient@james.org">recipient@james.org</a>)</li>
</ul>
<p>The mails from the given mail queue matching the query parameter will be deleted.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes:</p>
<ul>
<li>201: Task generation succeeded. Corresponding task id is returned.</li>
<li>400: Invalid request</li>
<li>404: The mail queue does not exist</li>
</ul>
<p>The scheduled task will have the following type delete-mails-from-mail-queue and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;queue&quot;:&quot;outgoing&quot;,
&quot;initialCount&quot;:10,
&quot;remainingCount&quot;: 5,
&quot;sender&quot;: &quot;sender@james.org&quot;,
&quot;name&quot;: &quot;Java Developer&quot;,
&quot;recipient: &quot;recipient@james.org&quot;
}
</pre></div></div>
</section><section>
<h3><a name="Clearing_a_mail_queue"></a>Clearing a mail queue</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/mailQueues/{mailQueueName}/mails
</pre></div></div>
<p>All mails from the given mail queue will be deleted.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes:</p>
<ul>
<li>201: Task generation succeeded. Corresponding task id is returned.</li>
<li>400: Invalid request</li>
<li>404: The mail queue does not exist</li>
</ul>
<p>The scheduled task will have the following type clear-mail-queue and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;queue&quot;:&quot;outgoing&quot;,
&quot;initialCount&quot;:10,
&quot;remainingCount&quot;: 0
}
</pre></div></div>
</section><section>
<h3><a name="Flushing_mails_from_a_mail_queue"></a>Flushing mails from a mail queue</h3>
<div class="source">
<div class="source">
<pre>curl -XPATCH http://ip:port/mailQueues/{mailQueueName}?delayed=true \
-d '{&quot;delayed&quot;: false}' \
-H &quot;Content-Type: application/json&quot;
</pre></div></div>
<p>This request should have the query parameter <i>delayed</i> set to <i>true</i>, in order to indicate only delayed mails are affected. The payload should set the delayed field to false inorder to remove the delay. This is the only supported combination, and it performs a flush.</p>
<p>The mails delayed in the given mail queue will be flushed.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes:</p>
<ul>
<li>204: Success (No content)</li>
<li>400: Invalid request</li>
<li>404: The mail queue does not exist</li>
</ul></section><section>
<h3><a name="RabbitMQ_republishing_a_mail_queue_from_cassandra"></a>RabbitMQ republishing a mail queue from cassandra</h3>
<div class="source">
<div class="source">
<pre>curl -XPOST 'http://ip:port/mailQueues/{mailQueueName}?action=RepublishNotProcessedMails&amp;olderThan=1d'
</pre></div></div>
<p>This method is specific to the distributed flavor of James, which relies on Cassandra and RabbitMQ for implementing a mail queue. In case of a RabbitMQ crash resulting in a loss of messages, this task can be launched to repopulate the mailQueueName queue in RabbitMQ using the information stored in Cassandra.</p>
<p>The olderThan parameter is mandatory. It filters the mails to be restored, by taking into account only the mails older than the given value. The expected value should be expressed in the following format: Nunit. N should be strictly positive. unit could be either in the short form (h, d, w, etc.), or in the long form (day, week, month, etc.).</p>
<p>Examples:</p>
<ul>
<li>5h</li>
<li>7d</li>
<li>1y</li>
</ul>
<p>Response codes:</p>
<ul>
<li>201: Task created</li>
<li>400: Invalid request</li>
</ul>
<p>The response body contains the id of the republishing task.</p>
<div class="source">
<div class="source">
<pre>{
&quot;taskId&quot;: &quot;a650a66a-5984-431e-bdad-f1baad885856&quot;
}
</pre></div></div>
</section></section><section>
<h2><a name="Sending_email_over_webAdmin"></a>Sending email over webAdmin</h2>
<div class="source">
<div class="source">
<pre>curl -XPOST /mail-transfer-service
{MIME message}
</pre></div></div>
<p>Will send the following email to the recipients specified in the MIME message.</p>
<p>The {MIME message} payload must match message/rfc822 format.</p></section><section>
<h2><a name="Administrating_DLP_Configuration"></a>Administrating DLP Configuration</h2>
<p>DLP (stands for Data Leak Prevention) is supported by James. A DLP matcher will, on incoming emails, execute regular expressions on email sender, recipients or content, in order to report suspicious emails to an administrator. WebAdmin can be used to manage these DLP rules on a per senderDomain basis.</p>
<p>senderDomain is domain of the sender of incoming emails, for example: apache.org, james.org,&#x2026; Each senderDomain correspond to a distinct DLP configuration.</p>
<ul>
<li><a href="#List_DLP_configuration_by_sender_domain">List DLP configuration by sender domain</a></li>
<li><a href="#Store_DLP_configuration_by_sender_domain">Store DLP configuration by sender domain</a></li>
<li><a href="#Remove_DLP_configuration_by_sender_domain">Remove DLP configuration by sender domain</a></li>
<li><a href="#Fetch_a_DLP_configuration_item_by_sender_domain_and_rule_id">Fetch a DLP configuration item by sender domain and rule id</a></li>
</ul><section>
<h3><a name="List_DLP_configuration_by_sender_domain"></a>List DLP configuration by sender domain</h3>
<p>Retrieve a DLP configuration for corresponding senderDomain, a configuration contains list of configuration items</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/dlp/rules/{senderDomain}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: A list of dlp configuration items is returned</li>
<li>400: Invalid senderDomain or payload in request</li>
<li>404: The domain does not exist.</li>
</ul>
<p>This is an example of returned body. The rules field is a list of rules as described below.</p>
<div class="source">
<div class="source">
<pre>{&quot;rules : [
{
&quot;id&quot;: &quot;1&quot;,
&quot;expression&quot;: &quot;james.org&quot;,
&quot;explanation&quot;: &quot;Find senders or recipients containing james[any char]org&quot;,
&quot;targetsSender&quot;: true,
&quot;targetsRecipients&quot;: true,
&quot;targetsContent&quot;: false
},
{
&quot;id&quot;: &quot;2&quot;,
&quot;expression&quot;: &quot;Find senders containing apache[any char]org&quot;,
&quot;explanation&quot;: &quot;apache.org&quot;,
&quot;targetsSender&quot;: true,
&quot;targetsRecipients&quot;: false,
&quot;targetsContent&quot;: false
}
]}
</pre></div></div>
</section><section>
<h3><a name="Store_DLP_configuration_by_sender_domain"></a>Store DLP configuration by sender domain</h3>
<p>Store a DLP configuration for corresponding senderDomain, if any item of DLP configuration in the request is stored before, it will not be stored anymore</p>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/dlp/rules/{senderDomain}
</pre></div></div>
<p>The body can contain a list of DLP configuration items formed by those fields: - id(String) is mandatory, unique identifier of the configuration item - expression(String) is mandatory, regular expression to match contents of targets - explanation(String) is optional, description of the configuration item - targetsSender(boolean) is optional and defaults to false. If true, expression will be applied to Sender and to From headers of the mail - targetsContent(boolean) is optional and defaults to false. If true, expression will be applied to Subject headers and textual bodies (text/plain and text/html) of the mail - targetsRecipients(boolean) is optional and defaults to false. If true, expression will be applied to recipients of the mail</p>
<p>This is an example of returned body. The rules field is a list of rules as described below.</p>
<div class="source">
<div class="source">
<pre>{&quot;rules&quot;: [
{
&quot;id&quot;: &quot;1&quot;,
&quot;expression&quot;: &quot;james.org&quot;,
&quot;explanation&quot;: &quot;Find senders or recipients containing james[any char]org&quot;,
&quot;targetsSender&quot;: true,
&quot;targetsRecipients&quot;: true,
&quot;targetsContent&quot;: false
},
{
&quot;id&quot;: &quot;2&quot;,
&quot;expression&quot;: &quot;Find senders containing apache[any char]org&quot;,
&quot;explanation&quot;: &quot;apache.org&quot;,
&quot;targetsSender&quot;: true,
&quot;targetsRecipients&quot;: false,
&quot;targetsContent&quot;: false
}
]}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: List of dlp configuration items is stored</li>
<li>400: Invalid senderDomain or payload in request</li>
<li>404: The domain does not exist.</li>
</ul></section><section>
<h3><a name="Remove_DLP_configuration_by_sender_domain"></a>Remove DLP configuration by sender domain</h3>
<p>Remove a DLP configuration for corresponding senderDomain</p>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/dlp/rules/{senderDomain}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: DLP configuration is removed</li>
<li>400: Invalid senderDomain or payload in request</li>
<li>404: The domain does not exist.</li>
</ul></section><section>
<h3><a name="Fetch_a_DLP_configuration_item_by_sender_domain_and_rule_id"></a>Fetch a DLP configuration item by sender domain and rule id</h3>
<p>Retrieve a DLP configuration rule for corresponding senderDomain and a ruleId</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/dlp/rules/{senderDomain}/rules/{ruleId}
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: A dlp configuration item is returned</li>
<li>400: Invalid senderDomain or payload in request</li>
<li>404: The domain and/or the rule does not exist.</li>
</ul>
<p>This is an example of returned body.</p>
<div class="source">
<div class="source">
<pre>{
&quot;id&quot;: &quot;1&quot;,
&quot;expression&quot;: &quot;james.org&quot;,
&quot;explanation&quot;: &quot;Find senders or recipients containing james[any char]org&quot;,
&quot;targetsSender&quot;: true,
&quot;targetsRecipients&quot;: true,
&quot;targetsContent&quot;: false
}
</pre></div></div>
</section></section><section>
<h2><a name="Administrating_Sieve_quotas"></a>Administrating Sieve quotas</h2>
<p>Some limitations on space Users Sieve script can occupy can be configured by default, and overridden by user.</p>
<ul>
<li><a href="#Retrieving_global_sieve_quota">Retrieving global sieve quota</a></li>
<li><a href="#Updating_global_sieve_quota">Updating global sieve quota</a></li>
<li><a href="#Removing_global_sieve_quota">Removing global sieve quota</a></li>
<li><a href="#Retrieving_user_sieve_quota">Retrieving user sieve quota</a></li>
<li><a href="#Updating_user_sieve_quota">Updating user sieve quota</a></li>
<li><a href="#Removing_user_sieve_quota">Removing user sieve quota</a></li>
</ul><section>
<h3><a name="Retrieving_global_sieve_quota"></a>Retrieving global sieve quota</h3>
<p>This endpoints allows to retrieve the global Sieve quota, which will be users default:</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/sieve/quota/default
</pre></div></div>
<p>Will return the bytes count allowed by user per default on this server.</p>
<div class="source">
<div class="source">
<pre>102400
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: Request is a success and the value is returned</li>
<li>204: No default quota is being configured</li>
</ul></section><section>
<h3><a name="Updating_global_sieve_quota"></a>Updating global sieve quota</h3>
<p>This endpoints allows to update the global Sieve quota, which will be users default:</p>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/sieve/quota/default
</pre></div></div>
<p>With the body being the bytes count allowed by user per default on this server.</p>
<div class="source">
<div class="source">
<pre>102400
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: Operation succeeded</li>
<li>400: Invalid payload</li>
</ul></section><section>
<h3><a name="Removing_global_sieve_quota"></a>Removing global sieve quota</h3>
<p>This endpoints allows to remove the global Sieve quota. There will no more be users default:</p>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/sieve/quota/default
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: Operation succeeded</li>
</ul></section><section>
<h3><a name="Retrieving_user_sieve_quota"></a>Retrieving user sieve quota</h3>
<p>This endpoints allows to retrieve the Sieve quota of a user, which will be this users quota:</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/sieve/quota/users/user@domain.com
</pre></div></div>
<p>Will return the bytes count allowed for this user.</p>
<div class="source">
<div class="source">
<pre>102400
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: Request is a success and the value is returned</li>
<li>204: No quota is being configured for this user</li>
</ul></section><section>
<h3><a name="Updating_user_sieve_quota"></a>Updating user sieve quota</h3>
<p>This endpoints allows to update the Sieve quota of a user, which will be users default:</p>
<div class="source">
<div class="source">
<pre>curl -XPUT http://ip:port/sieve/quota/users/user@domain.com
</pre></div></div>
<p>With the body being the bytes count allowed for this user on this server.</p>
<div class="source">
<div class="source">
<pre>102400
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: Operation succeeded</li>
<li>400: Invalid payload</li>
</ul></section><section>
<h3><a name="Removing_user_sieve_quota"></a>Removing user sieve quota</h3>
<p>This endpoints allows to remove the Sieve quota of a user. There will no more quota for this user:</p>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/sieve/quota/users/user@domain.com
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: Operation succeeded</li>
</ul></section></section><section>
<h2><a name="Running_blob_garbage_collection"></a>Running blob garbage collection</h2>
<p>When deduplication is enabled one needs to explicitly run a garbage collection in order to delete no longer referenced blobs.</p>
<p>To do so:</p>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/blobs?scope=unreferenced
</pre></div></div>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Additional parameters include Bloom filter tuning parameters:</p>
<ul>
<li><b>associatedProbability</b>: Allow to define the targeted false positive rate. Note that subsequent runs do not have the same false-positives.</li>
<li><b>expectedBlobCount</b>: Expected count of blobs used to size the bloom filters.</li>
</ul>
<p>The created task has the following additional information:</p>
<div class="source">
<div class="source">
<pre>{
&quot;referenceSourceCount&quot;: 3456,
&quot;blobCount&quot;: 5678,
&quot;gcedBlobCount&quot;: 1234,
&quot;bloomFilterExpectedBlobCount&quot;: 10000,
&quot;bloomFilterAssociatedProbability&quot;: 0.01
}
</pre></div></div>
<p>Where:</p>
<ul>
<li><b>bloomFilterExpectedBlobCount</b> correspond to the supplied <b>expectedBlobCount</b> query parameter.</li>
<li><b>bloomFilterAssociatedProbability</b> correspond to the supplied <b>associatedProbability</b> query parameter.</li>
<li><b>referenceSourceCount</b> is the count of distinct blob references encountered while populating the bloom filter.</li>
<li><b>blobCount</b> is the count of blobs tried against the bloom filter. This value can be used to better size the bloom filter in later runs.</li>
<li><b>gcedBlobCount</b> is the count of blobs that were garbage collected.</li>
</ul></section><section>
<h2><a name="Administrating_Jmap_Uploads"></a>Administrating Jmap Uploads</h2>
<ul>
<li><a href="#Cleaning_upload_repository">Cleaning upload repository</a></li>
</ul><section>
<h3><a name="Cleaning_upload_repository"></a>Cleaning upload repository</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/jmap/uploads?scope=expired
</pre></div></div>
<p>Will schedule a task for clearing expired upload entries.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Query parameter scope is required and have the value expired.</p>
<p>Response codes:</p>
<ul>
<li>201: Success. Corresponding task id is returned.</li>
<li>400: Scope invalid</li>
</ul>
<p>The scheduled task will have the following type UploadRepositoryCleanupTask and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;scope&quot;: &quot;expired&quot;,
&quot;timestamp&quot;: &quot;2007-12-03T10:15:30Z&quot;,
&quot;type&quot;: &quot;UploadRepositoryCleanupTask&quot;
}
</pre></div></div>
</section></section><section>
<h2><a name="Event_Dead_Letter"></a>Event Dead Letter</h2>
<p>The EventBus allows to register &#x2018;group listeners&#x2019; that are called in a (potentially) distributed fashion. These group listeners enable the implementation of some advanced mailbox manager feature like indexing, spam reporting, quota management and the like.</p>
<p>Upon exceptions, a bounded number of retries are performed (with exponential backoff delays). If after those retries the listener is still failing, then the event will be stored in the &#x201c;Event Dead Letter&#x201d;. This API allows diagnosing issues, as well as performing event replay (not implemented yet).</p>
<ul>
<li><a href="#Event_Dead_Letter">Event Dead Letter</a></li>
<li><a href="#Listing_mailbox_listener_groups">Listing mailbox listener groups</a></li>
<li><a href="#Listing_failed_events">Listing failed events</a></li>
<li><a href="#Getting_event_details">Getting event details</a></li>
<li><a href="#Deleting_an_event">Deleting an event</a></li>
<li><a href="#Redeliver_all_events">Redeliver all events</a></li>
<li><a href="#Redeliver_group_events">Redeliver group events</a></li>
<li><a href="#Redeliver_a_single_event">Redeliver a single event</a></li>
<li><a href="#Rescheduling_group_execution">Rescheduling group execution</a></li>
</ul><section>
<h3><a name="Listing_mailbox_listener_groups"></a>Listing mailbox listener groups</h3>
<p>This endpoint allows discovering the list of mailbox listener groups.</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/events/deadLetter/groups
</pre></div></div>
<p>Will return a list of group names that can be further used to interact with the dead letter API:</p>
<div class="source">
<div class="source">
<pre>[&quot;org.apache.james.mailbox.events.EventBusTestFixture$GroupA&quot;, &quot;org.apache.james.mailbox.events.GenericGroup-abc&quot;]
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: Success. A list of group names is returned.</li>
</ul></section><section>
<h3><a name="Listing_failed_events"></a>Listing failed events</h3>
<p>This endpoint allows listing failed events for a given group:</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/events/deadLetter/groups/org.apache.james.mailbox.events.EventBusTestFixture$GroupA
</pre></div></div>
<p>Will return a list of insertionIds:</p>
<div class="source">
<div class="source">
<pre>[&quot;6e0dd59d-660e-4d9b-b22f-0354479f47b4&quot;, &quot;58a8f59d-660e-4d9b-b22f-0354486322a2&quot;]
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>200: Success. A list of insertion ids is returned.</li>
<li>400: Invalid group name</li>
</ul></section><section>
<h3><a name="Getting_event_details"></a>Getting event details</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/events/deadLetter/groups/org.apache.james.mailbox.events.EventBusTestFixture$GroupA/6e0dd59d-660e-4d9b-b22f-0354479f47b4
</pre></div></div>
<p>Will return the full JSON associated with this event.</p>
<p>Response codes:</p>
<ul>
<li>200: Success. A JSON representing this event is returned.</li>
<li>400: Invalid group name or insertionId</li>
<li>404: No event with this insertionId</li>
</ul></section><section>
<h3><a name="Deleting_an_event"></a>Deleting an event</h3>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/events/deadLetter/groups/org.apache.james.mailbox.events.EventBusTestFixture$GroupA/6e0dd59d-660e-4d9b-b22f-0354479f47b4
</pre></div></div>
<p>Will delete this event.</p>
<p>Response codes:</p>
<ul>
<li>204: Success</li>
<li>400: Invalid group name or insertionId</li>
</ul></section><section>
<h3><a name="Redeliver_all_events"></a>Redeliver all events</h3>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/events/deadLetter?action=redeliver
</pre></div></div>
<p>Will create a task that will attempt to redeliver all events stored in &#x201c;Event Dead Letter&#x201d;. If successful, redelivered events will then be removed from &#x201c;Dead Letter&#x201d;.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes:</p>
<ul>
<li>201: the taskId of the created task</li>
<li>400: Invalid action argument</li>
</ul></section><section>
<h3><a name="Redeliver_group_events"></a>Redeliver group events</h3>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/events/deadLetter/groups/org.apache.james.mailbox.events.EventBusTestFixture$GroupA
</pre></div></div>
<p>Will create a task that will attempt to redeliver all events of a particular group stored in &#x201c;Event Dead Letter&#x201d;. If successful, redelivered events will then be removed from &#x201c;Dead Letter&#x201d;.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes:</p>
<ul>
<li>201: the taskId of the created task</li>
<li>400: Invalid group name or action argument</li>
</ul></section><section>
<h3><a name="Redeliver_a_single_event"></a>Redeliver a single event</h3>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/events/deadLetter/groups/org.apache.james.mailbox.events.EventBusTestFixture$GroupA/6e0dd59d-660e-4d9b-b22f-0354479f47b4?action=reDeliver
</pre></div></div>
<p>Will create a task that will attempt to redeliver a single event of a particular group stored in &#x201c;Event Dead Letter&#x201d;. If successful, redelivered event will then be removed from &#x201c;Dead Letter&#x201d;.</p>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes:</p>
<ul>
<li>201: the taskId of the created task</li>
<li>400: Invalid group name, insertion id or action argument</li>
<li>404: No event with this insertionId</li>
</ul></section><section>
<h3><a name="Rescheduling_group_execution"></a>Rescheduling group execution</h3>
<p>Not implemented yet.</p></section></section><section>
<h2><a name="Deleted_Messages_Vault"></a>Deleted Messages Vault</h2>
<p>The &#x2018;Deleted Message Vault plugin&#x2019; allows you to keep users deleted messages during a given retention time. This set of routes allow you to <i>restore</i> users deleted messages or export them in an archive.</p>
<p>To move deleted messages in the vault, you need to specifically configure the DeletedMessageVault PreDeletionHook.</p>
<p>Here are the following actions available on the &#x2018;Deleted Messages Vault&#x2019;</p>
<ul>
<li><a href="#Restore_Deleted_Messages">Restore Deleted Messages</a></li>
<li><a href="#Export_Deleted_Messages">Export Deleted Messages</a></li>
<li><a href="#Purge_Deleted_Messages">Purge Deleted Messages</a></li>
<li><a href="#Permanently_Remove_Deleted_Message">Permanently Remove Deleted Message</a></li>
</ul>
<p>Note that the &#x2018;Deleted Messages Vault&#x2019; feature is supported on top of all available Guice products.</p><section>
<h3><a name="Restore_Deleted_Messages"></a>Restore Deleted Messages</h3>
<p>Deleted messages of a specific user can be restored by calling the following endpoint:</p>
<div class="source">
<div class="source">
<pre>curl -XPOST http://ip:port/deletedMessages/users/userToRestore@domain.ext?action=restore
{
&quot;combinator&quot;: &quot;and&quot;,
&quot;criteria&quot;: [
{
&quot;fieldName&quot;: &quot;subject&quot;,
&quot;operator&quot;: &quot;containsIgnoreCase&quot;,
&quot;value&quot;: &quot;Apache James&quot;
},
{
&quot;fieldName&quot;: &quot;deliveryDate&quot;,
&quot;operator&quot;: &quot;beforeOrEquals&quot;,
&quot;value&quot;: &quot;2014-10-30T14:12:00Z&quot;
},
{
&quot;fieldName&quot;: &quot;deletionDate&quot;,
&quot;operator&quot;: &quot;afterOrEquals&quot;,
&quot;value&quot;: &quot;2015-10-20T09:08:00Z&quot;
},
{
&quot;fieldName&quot;: &quot;recipients&quot;,&quot;
&quot;operator&quot;: &quot;contains&quot;,&quot;
&quot;value&quot;: &quot;recipient@james.org&quot;
},
{
&quot;fieldName&quot;: &quot;hasAttachment&quot;,
&quot;operator&quot;: &quot;equals&quot;,
&quot;value&quot;: &quot;false&quot;
},
{
&quot;fieldName&quot;: &quot;sender&quot;,
&quot;operator&quot;: &quot;equals&quot;,
&quot;value&quot;: &quot;sender@apache.org&quot;
},
{
&quot;fieldName&quot;: &quot;originMailboxes&quot;,
&quot;operator&quot;: &quot;contains&quot;,
&quot;value&quot;: &quot;02874f7c-d10e-102f-acda-0015176f7922&quot;
}
]
};
</pre></div></div>
<p>The requested Json body is made from a list of criterion objects which have the following structure:</p>
<div class="source">
<div class="source">
<pre>{
&quot;fieldName&quot;: &quot;supportedFieldName&quot;,
&quot;operator&quot;: &quot;supportedOperator&quot;,
&quot;value&quot;: &quot;A plain string representing the matching value of the corresponding field&quot;
}
</pre></div></div>
<p>Deleted Messages which are matched with the <b>all</b> criterion in the query body will be restored. Here are a list of supported fieldName for the restoring:</p>
<ul>
<li>subject: represents for deleted message subject field matching. Supports below string operators:</li>
<li>contains</li>
<li>containsIgnoreCase</li>
<li>equals</li>
<li>equalsIgnoreCase</li>
<li>deliveryDate: represents for deleted message deliveryDate field matching. Tested value should follow the right date time with zone offset format (ISO-8601) like 2008-09-15T15:53:00+05:00 or 2008-09-15T15:53:00Z Supports below date time operators:</li>
<li>beforeOrEquals: is the deleted message&#x2019;s deliveryDate before or equals the time of tested value.</li>
<li>afterOrEquals: is the deleted message&#x2019;s deliveryDate after or equals the time of tested value</li>
<li>deletionDate: represents for deleted message deletionDate field matching. Tested value &amp; Supports operators: similar to deliveryDate</li>
<li>sender: represents for deleted message sender field matching. Tested value should be a valid mail address. Supports mail address operator:</li>
<li>equals: does the tested sender equal to the sender of the tested deleted message ?</li>
<li>recipients: represents for deleted message recipients field matching. Tested value should be a valid mail address. Supports list mail address operator:</li>
<li>contains: does the tested deleted message&#x2019;s recipients contain tested recipient ?</li>
<li>hasAttachment: represents for deleted message hasAttachment field matching. Tested value could be false or true. Supports boolean operator:</li>
<li>equals: does the tested deleted message&#x2019;s hasAttachment property equal to the tested hasAttachment value?</li>
<li>originMailboxes: represents for deleted message originMailboxes field matching. Tested value is a string serialized of mailbox id. Supports list mailbox id operators:</li>
<li>contains: does the tested deleted message&#x2019;s originMailbox ids contain tested mailbox id ?</li>
</ul>
<p>Messages in the Deleted Messages Vault of a specified user that are matched with Query Json Object in the body will be appended to his &#x2018;Restored-Messages&#x2019; mailbox, which will be created if needed.</p>
<p><b>Note</b>:</p>
<ul>
<li>Query parameter action is required and should have the value restore to represent the restoring feature. Otherwise, a bad request response will be returned</li>
<li>Query parameter action is case sensitive</li>
<li>fieldName &amp; operator passed to the routes are case sensitive</li>
<li>Currently, we only support query combinator and value, otherwise, requests will be rejected</li>
<li>If you only want to restore by only one criterion, the json body could be simplified to a single criterion:</li>
</ul>
<div class="source">
<div class="source">
<pre>{
&quot;fieldName&quot;: &quot;subject&quot;,
&quot;operator&quot;: &quot;containsIgnoreCase&quot;,
&quot;value&quot;: &quot;Apache James&quot;
}
</pre></div></div>
<ul>
<li>For restoring all deleted messages, passing a query json with an empty criterion list to represent matching all deleted messages:</li>
</ul>
<div class="source">
<div class="source">
<pre>{
&quot;combinator&quot;: &quot;and&quot;,
&quot;criteria&quot;: []
}
</pre></div></div>
<p><b>Warning</b>: Current web-admin uses US locale as the default. Therefore, there might be some conflicts when using String containsIgnoreCase comparators to apply on the String data of other special locales stored in the Vault. More details at <a class="externalLink" href="https://issues.apache.org/jira/browse/MAILBOX-384">JIRA</a></p>
<p>Response code:</p>
<ul>
<li>201: Task for restoring deleted has been created</li>
<li>400: Bad request:</li>
<li>action query param is not present</li>
<li>action query param is not a valid action</li>
<li>user parameter is invalid</li>
<li>can not parse the JSON body</li>
<li>Json query object contains unsupported operator, fieldName</li>
<li>Json query object values violate parsing rules</li>
<li>404: User not found</li>
</ul>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>The scheduled task will have the following type deleted-messages-restore and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;successfulRestoreCount&quot;: 47,
&quot;errorRestoreCount&quot;: 0,
&quot;user&quot;: &quot;userToRestore@domain.ext&quot;
}
</pre></div></div>
<p>while:</p>
<ul>
<li>successfulRestoreCount: number of restored messages</li>
<li>errorRestoreCount: number of messages that failed to restore</li>
<li>user: owner of deleted messages need to restore</li>
</ul></section><section>
<h3><a name="Export_Deleted_Messages"></a>Export Deleted Messages</h3>
<p>Retrieve deleted messages matched with requested query from an user then share the content to a targeted mail address (exportTo)</p>
<div class="source">
<div class="source">
<pre>curl -XPOST 'http://ip:port/deletedMessages/users/userExportFrom@domain.ext?action=export&amp;exportTo=userReceiving@domain.ext'
BODY: is the json query has the same structure with Restore Deleted Messages section
</pre></div></div>
<p><b>Note</b>: Json query passing into the body follows the same rules &amp; restrictions like in <a href="#Restore_deleted_messages">Restore Deleted Messages</a></p>
<p>Response code:</p>
<ul>
<li>201: Task for exporting has been created</li>
<li>400: Bad request:</li>
<li>exportTo query param is not present</li>
<li>exportTo query param is not a valid mail address</li>
<li>action query param is not present</li>
<li>action query param is not a valid action</li>
<li>user parameter is invalid</li>
<li>can not parse the JSON body</li>
<li>Json query object contains unsupported operator, fieldName</li>
<li>Json query object values violate parsing rules</li>
<li>404: User not found</li>
</ul>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>The scheduled task will have the following type deleted-messages-export and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre>{
&quot;userExportFrom&quot;: &quot;userToRestore@domain.ext&quot;,
&quot;exportTo&quot;: &quot;userReceiving@domain.ext&quot;,
&quot;totalExportedMessages&quot;: 1432
}
</pre></div></div>
<p>while: - userExportFrom: export deleted messages from this user - exportTo: content of deleted messages have been shared to this mail address - totalExportedMessages: number of deleted messages match with json query, then being shared to sharee</p></section><section>
<h3><a name="Purge_Deleted_Messages"></a>Purge Deleted Messages</h3>
<p>You can overwrite &#x2018;retentionPeriod&#x2019; configuration in &#x2018;deletedMessageVault&#x2019; configuration file or use the default value of 1 year.</p>
<p>Purge all deleted messages older than the configured &#x2018;retentionPeriod&#x2019;</p>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/deletedMessages?scope=expired
</pre></div></div>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response code:</p>
<ul>
<li>201: Task for purging has been created</li>
<li>400: Bad request:</li>
<li>action query param is not present</li>
<li>action query param is not a valid action</li>
</ul>
<p>You may want to call this endpoint on a regular basis.</p></section><section>
<h3><a name="Permanently_Remove_Deleted_Message"></a>Permanently Remove Deleted Message</h3>
<p>Delete a Deleted Message with MessageId</p>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/deletedMessages/users/user@domain.ext/messages/3294a976-ce63-491e-bd52-1b6f465ed7a2
</pre></div></div>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response code:</p>
<ul>
<li>201: Task for deleting message has been created</li>
<li>400: Bad request:</li>
<li>user parameter is invalid</li>
<li>messageId parameter is invalid</li>
<li>404: User not found</li>
</ul>
<p>The scheduled task will have the following type deleted-messages-delete and the following additionalInformation:</p>
<div class="source">
<div class="source">
<pre> {
&quot;userName&quot;: &quot;user@domain.ext&quot;,
&quot;messageId&quot;: &quot;3294a976-ce63-491e-bd52-1b6f465ed7a2&quot;
}
</pre></div></div>
<p>while: - user: delete deleted messages from this user - deleteMessageId: messageId of deleted messages will be delete</p></section></section><section>
<h2><a name="Task_management"></a>Task management</h2>
<p>Some webadmin features schedules tasks. The task management API allow to monitor and manage the execution of the following tasks.</p>
<p>Note that the taskId used in the following APIs is returned by other WebAdmin APIs scheduling tasks.</p>
<ul>
<li><a href="#Getting_a_task_details">Getting a task details</a></li>
<li><a href="#Awaiting_a_task">Awaiting a task</a></li>
<li><a href="#Cancelling_a_task">Cancelling a task</a></li>
<li><a href="#Listing_tasks">Listing tasks</a></li>
<li><a href="#Endpoints_returning_a_task">Endpoints returning a task</a></li>
</ul><section>
<h3><a name="Getting_a_task_details"></a>Getting a task details</h3>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/tasks/3294a976-ce63-491e-bd52-1b6f465ed7a2
</pre></div></div>
<p>An Execution Report will be returned:</p>
<div class="source">
<div class="source">
<pre>{
&quot;submitDate&quot;: &quot;2017-12-27T15:15:24.805+0700&quot;,
&quot;startedDate&quot;: &quot;2017-12-27T15:15:24.809+0700&quot;,
&quot;completedDate&quot;: &quot;2017-12-27T15:15:24.815+0700&quot;,
&quot;cancelledDate&quot;: null,
&quot;failedDate&quot;: null,
&quot;taskId&quot;: &quot;3294a976-ce63-491e-bd52-1b6f465ed7a2&quot;,
&quot;additionalInformation&quot;: {},
&quot;status&quot;: &quot;completed&quot;,
&quot;type&quot;: &quot;type-of-the-task&quot;
}
</pre></div></div>
<p>Note that:</p>
<ul>
<li>
<p>status can have the value:</p>
<ul>
<li>waiting: The task is scheduled but its execution did not start yet</li>
<li>inProgress: The task is currently executed</li>
<li>cancelled: The task had been cancelled</li>
<li>completed: The task execution is finished, and this execution is a success</li>
<li>failed: The task execution is finished, and this execution is a failure</li>
</ul>
</li>
<li>
<p>additionalInformation is a task specific object giving additional information and context about that task. The structure of this additionalInformation field is provided along the specific task submission endpoint.</p>
</li>
</ul>
<p>Response codes:</p>
<ul>
<li>200: The specific task was found and the execution report exposed above is returned</li>
<li>400: Invalid task ID</li>
<li>404: Task ID was not found</li>
</ul></section><section>
<h3><a name="Awaiting_a_task"></a>Awaiting a task</h3>
<p>One can await the end of a task, then receive it&#x2019;s final execution report.</p>
<p>That feature is especially usefull for testing purpose but still can serve real-life scenari.</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/tasks/3294a976-ce63-491e-bd52-1b6f465ed7a2/await?timeout=duration
</pre></div></div>
<p>An Execution Report will be returned.</p>
<p>timeout is optional. By default it is set to 365 days (the maximum value). The expected value is expressed in the following format: Nunit. N should be strictly positive. unit could be either in the short form (s, m, h, etc.), or in the long form (day, week, month, etc.).</p>
<p>Examples:</p>
<ul>
<li>30s</li>
<li>5m</li>
<li>7d</li>
<li>1y</li>
</ul>
<p>Response codes:</p>
<ul>
<li>200: The specific task was found and the execution report exposed above is returned</li>
<li>400: Invalid task ID or invalid timeout</li>
<li>404: Task ID was not found</li>
<li>408: The timeout has been reached</li>
</ul></section><section>
<h3><a name="Cancelling_a_task"></a>Cancelling a task</h3>
<p>You can cancel a task by calling:</p>
<div class="source">
<div class="source">
<pre>curl -XDELETE http://ip:port/tasks/3294a976-ce63-491e-bd52-1b6f465ed7a2
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>204: Task had been cancelled</li>
<li>400: Invalid task ID</li>
</ul></section><section>
<h3><a name="Listing_tasks"></a>Listing tasks</h3>
<p>A list of all tasks can be retrieved:</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/tasks
</pre></div></div>
<p>Will return a list of Execution reports</p>
<p>One can filter the above results by status. For example:</p>
<div class="source">
<div class="source">
<pre>curl -XGET http://ip:port/tasks?status=inProgress
</pre></div></div>
<p>Will return a list of Execution reports that are currently in progress.</p>
<p>Response codes:</p>
<ul>
<li>200: A list of corresponding tasks is returned</li>
<li>400: Invalid status value</li>
</ul></section><section>
<h3><a name="Endpoints_returning_a_task"></a>Endpoints returning a task</h3>
<p>Many endpoints do generate a task.</p>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>curl -XPOST /endpoint?action={action}
</pre></div></div>
<p>The response to these requests will be the scheduled taskId :</p>
<div class="source">
<div class="source">
<pre>{&quot;taskId&quot;:&quot;5641376-02ed-47bd-bcc7-76ff6262d92a&quot;}
</pre></div></div>
<p>Positionned headers:</p>
<ul>
<li>Location header indicates the location of the resource associated with the scheduled task. Example:</li>
</ul>
<div class="source">
<div class="source">
<pre>Location: /tasks/3294a976-ce63-491e-bd52-1b6f465ed7a2
</pre></div></div>
<p>Response codes:</p>
<ul>
<li>201: Task generation succeeded. Corresponding task id is returned.</li>
<li>Other response codes might be returned depending on the endpoint</li>
</ul>
<p>The additional information returned depends on the scheduled task type and is documented in the endpoint documentation.</p></section></section><section>
<h2><a name="Cassandra_extra_operations"></a>Cassandra extra operations</h2>
<p>Some webadmin features to manage some extra operations on Cassandra tables, like solving inconsistencies on projection tables. Such inconsistencies can be for example created by a fail of the DAO to add a mapping into &#x2019;mappings_sources, while it was successful regarding therrt` table.</p>
<ul>
<li><a href="#Operations_on_mappings_sources">Operations on mappings sources</a></li>
</ul><section>
<h3><a name="Operations_on_mappings_sources"></a>Operations on mappings sources</h3>
<p>You can do a series of action on mappings_sources projection table :</p>
<div class="source">
<div class="source">
<pre>curl -XPOST /cassandra/mappings?action={action}
</pre></div></div>
<p>Will return the taskId corresponding to the related task. Actions supported so far are :</p>
<ul>
<li>SolveInconsistencies : cleans up first all the mappings in mappings_sources index and then repopulate it correctly. In the meantime, listing sources of a mapping might create temporary inconsistencies during the process.</li>
</ul>
<p>For example :</p>
<div class="source">
<div class="source">
<pre>curl -XPOST /cassandra/mappings?action=SolveInconsistencies
</pre></div></div>
<p><a href="#Endpoints_returning_a_task">More details about endpoints returning a task</a>.</p>
<p>Response codes :</p>
<ul>
<li>201: the taskId of the created task</li>
<li>400: Invalid action argument for performing operation on mappings data</li>
</ul></section></section>
</div>
</div>
<div class="clear">
<hr/>
</div>
<div id="footer">
<div class="xright">Copyright &#169; 2006-2021
<a href="https://www.apache.org/">The Apache Software Foundation</a>.
All Rights Reserved.
</div>
<div class="clear">
<hr/>
</div>
</div>
</body>
</html>