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
| Parameter | Type | Required | Description |
|---|---|---|---|
stored_retention_days | integer | Optional | 7, 30 (default), 90, 180 or 365. Free plans: at most 30. null returns to the default; omit to leave unchanged. |
forward_only_retention_hours | integer | Optional | 24, 72 (default), 168 or 720. Free plans: at most 72. null returns to the default; omit to leave unchanged. |
Responses
| Status | Description |
|---|---|
200 | The updated retention, same shape as Get the inbound retention. |
400 | invalid_retention — not one of the allowed values; retention_plan_limit — longer than your plan allows. |
401 | Missing or invalid API key. |
403 | insufficient_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"])