# Change the retention settings

Source: https://docs.vlayers.ai/reference/conversations/update-retention

`PATCH /v1/retention` · scope `retention:manage`

Changes any of the retention settings. Turning on `mailRetentionDays`, turning on `deleteConversationsWithMailbox` or shortening `trashRetentionDays` makes the daily clean-up delete conversations for good, so a key needs the permission to delete for good as well as to change retention. `legalHold: true` stops every permanent delete, whoever asks. Pass `expectedVersion` to refuse the change if someone changed the settings since you read them. Every change is recorded.

Requires an API key with the `retention:manage` scope.

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `mailRetentionDays` | body | integer | no | Delete a conversation for good this many days after its last message; `null` keeps conversations until someone deletes them. |
| `trashRetentionDays` | body | integer | no | Days a deleted conversation can be brought back (1-365). |
| `deleteConversationsWithMailbox` | body | boolean | no | Also delete for good the conversations of an inbox that is deleted. |
| `permanentDeleteAllowed` | body | boolean | no | Whether anything may be deleted for good. |
| `legalHold` | body | boolean | no | Keep everything while on. |
| `expectedVersion` | body | integer | no | The `version` you read; refused if the settings moved since. |

## Request

cURL:

```bash
curl -X PATCH https://api.vlayers.ai/v1/retention \
  -H "Authorization: Bearer $VOICELAYER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "trashRetentionDays": 14
  }'
```

TypeScript:

```ts
import { VoiceLayer } from '@voicelayer/api';

const voicelayer = new VoiceLayer();

const { summary } = await voicelayer.conversations.updateRetention({ trashRetentionDays: 14 });
console.log(summary);
```

Python:

```python
from voicelayer import VoiceLayer

vl = VoiceLayer()

result = vl.conversations.update_retention(trash_retention_days=14)
print(result.summary)
```

## Response `200`

```json
{
  "settings": {
    "mailRetentionDays": null,
    "trashRetentionDays": 14,
    "deleteConversationsWithMailbox": false,
    "permanentDeleteAllowed": true,
    "legalHold": false
  },
  "sources": {
    "mailRetentionDays": "platform",
    "trashRetentionDays": "workspace",
    "deleteConversationsWithMailbox": "platform",
    "permanentDeleteAllowed": "platform",
    "legalHold": "platform"
  },
  "version": 1,
  "lines": [
    "Conversations are kept until someone deletes them.",
    "A deleted conversation can be brought back for 14 days.",
    "Deleting an inbox keeps its conversations.",
    "Conversations may be deleted for good.",
    "No legal hold: nothing is blocking a permanent delete."
  ],
  "summary": "The trash now holds a deleted conversation for 14 days."
}
```
