# Set recording and retention

Recording decides which payloads the gateway stores with each request. Retention decides how long an environment keeps them. Both are set per environment in **Log settings**, and a new environment starts with a copy of the settings of the one it was created from.

## Choose what is recorded

Metadata is always recorded: who called, which operation, when, the status and the duration. Payloads are the bodies, headers and scripts behind each request, and you choose which of them are stored.

1. In the portal, go to [**Agent Gateway**](https://auth.faustine.ai/go?to=%2Fintegrations%2Fagent-gateway) and select your gateway.
2. Select the **Logs** tab, then **Log settings**.
3. Under **Recording**, set the options in the table.
4. Select **Save**. The change applies to new requests.

| Option | What it does | Default |
| --- | --- | --- |
| **Record payloads** | Off keeps metadata only. | On |
| **Agent requests and responses** | The arguments the agent sent and the results it got back. | On |
| **Scripts** | The scripts agents run in Code mode. | On |
| **Upstream bodies** | The bodies exchanged with your API. | On |
| **Upstream headers** | The headers exchanged with your API. | On |
| **Max size per body** | 8 KB, 32 KB or 128 KB. A longer body is cut and marked as truncated. | 32 KB |
| **Operations never recorded** | Calls to these operations keep metadata only. Select **Add operations** to choose them. | None |

## Record payloads for a limited time

When **Record payloads** is off, **Recording** shows **Record payloads for a while**. Select **15 min**, **30 min** or **60 min** to record payloads for that long. The environment goes back to metadata only on its own. To end the recording earlier, select **Stop**.

## Set the retention

1. Under **Retention**, choose how long to keep **Metadata**: 7, 30 or 90 days.
2. Choose how long to keep **Payloads**: 1, 3, 7 or 30 days. Payloads cannot be kept longer than metadata.
3. Select **Save**.

The defaults are 30 days for metadata and 7 days for payloads. Faustine deletes data older than the retention every hour. The section shows how many requests and payloads the environment stores and the date of the oldest.

> **Warning:** Shortening the retention deletes the older data immediately. A dialog shows how many requests and payloads will be deleted. Select **Shorten and delete** to confirm. This cannot be undone.

## Next steps

- [Redact sensitive fields](https://docs.faustine.ai/agent-gateway/redact-sensitive-fields/): remove values from the payloads that are recorded.
- [Log streams](https://docs.faustine.ai/agent-gateway/log-streams/): keep requests longer in your own storage.
- [Logs](https://docs.faustine.ai/agent-gateway/logs/): what a request without payloads shows.
