Set the inbound retention

Choose how long inbound mail is kept: 7 days to a year for stored mail and 24 hours to 30 days for forward-only mail.

Sets the workspace retention. A domain can override it with `PUT /v3/domains/{name}/inbound`. A shorter retention deletes older mail at the next nightly cleanup; a longer one keeps the mail that still exists (deleted mail is not restored). Longer retention keeps more mail stored. Requires a `full_access` key.

PUT /v3/inbound/retention

Request body

ParameterTypeRequiredDescription
stored_retention_daysintegerOptional7, 30 (default), 90, 180 or 365. Free plans: at most 30. null returns to the default; omit to leave unchanged.
forward_only_retention_hoursintegerOptional24, 72 (default), 168 or 720. Free plans: at most 72. null returns to the default; omit to leave unchanged.

Responses

StatusDescription
200The updated retention, same shape as Get the inbound retention.
400invalid_retention — not one of the allowed values; retention_plan_limit — longer than your plan allows.
401Missing or invalid API key.
403insufficient_scope — only a full_access key may change the retention.

Code examples

cURL
curl -X PUT https://api.wemail.io/v3/inbound/retention \
  -H "Authorization: Bearer afn_live_…" \
  -H "Content-Type: application/json" \
  -d '{"stored_retention_days":90,"forward_only_retention_hours":168}'
Node.js
await fetch("https://api.wemail.io/v3/inbound/retention", {
  method: "PUT",
  headers: { Authorization: `Bearer ${process.env.WEMAIL_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({ stored_retention_days: 90, forward_only_retention_hours: 168 }),
});
Python
import os, requests

r = requests.put("https://api.wemail.io/v3/inbound/retention",
                 json={"stored_retention_days": 90, "forward_only_retention_hours": 168},
                 headers={"Authorization": f"Bearer {os.environ['WEMAIL_API_KEY']}"})
print(r.status_code, r.json()["effective"])