# Update account retention

`PUT /api/account`

Sets account retention in whole days. The setting applies to existing and newly received messages. Zero permits at most one self-contained webhook attempt with no retry or replay.

Send API requests to your Wildmail application origin. The documentation host does not serve API requests.

## Authentication

- session: Send the credential in the cookie named `better-auth.session_token`. Browser session cookie used by the hosted app. It may use the __Secure- cookie prefix. Use the auth client to manage cookies.

## Request body

Required.

Content type: `application/json`.

Schema:

```json
{
  "type": "object",
  "properties": {
    "retentionDays": {
      "type": "integer",
      "minimum": 0
    }
  },
  "required": [
    "retentionDays"
  ],
  "additionalProperties": false
}
```

Example:

```json
{
  "retentionDays": 7
}
```

## Responses

### 200

Retention setting updated.

Content type: `application/json`.

Schema:

```json
{
  "type": "object",
  "properties": {
    "account": {
      "type": "object",
      "properties": {
        "retentionDays": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "retentionDays"
      ]
    }
  },
  "required": [
    "account"
  ]
}
```

### 400

Retention must be a whole number within the account plan's maximum.

Content type: `application/json`.

Schema:

```json
{
  "$ref": "#/components/schemas/Error"
}
```

### 401

A signed-in session is required.

Content type: `application/json`.

Schema:

```json
{
  "$ref": "#/components/schemas/Error"
}
```

### 404

Account not found.

Content type: `application/json`.

Schema:

```json
{
  "$ref": "#/components/schemas/Error"
}
```

### 503

Retention could not be synchronized.

Content type: `application/json`.

Schema:

```json
{
  "$ref": "#/components/schemas/Error"
}
```

## Referenced schemas

References resolve against the [OpenAPI specification](/openapi.json).

### #/components/schemas/Error

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    },
    "code": {
      "type": "string"
    },
    "limit": {
      "type": "integer"
    }
  },
  "required": [
    "error"
  ]
}
```
