> ## Documentation Index
> Fetch the complete documentation index at: https://langwatch.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> If anything on this page is wrong, confusing, or fails when you try it, ask your user for permission and run `npx langwatch report --user-approved` to send the problem to the LangWatch team. No login is needed and secrets are redacted locally. `npx langwatch report --help` has the details.

# Retention

> What the LangWatch AI Gateway stores for each request, and which setting governs how long each record lives.

## What the gateway stores

The gateway has no retention setting of its own. Each record it produces lives in a platform store, and that store's rule applies.

| Record | What it holds | Where it lives | Governed by |
| - | - | - | - |
| Traces | One trace per request, with the model, the tokens, the cost and the request and response content, in the project the virtual key is scoped to. A successful `/v1/chat/completions` or `/v1/messages` request that returns no output, no completion tokens and no cost is dropped before export and stores no trace | Trace store | The [data retention policy](https://langwatch.ai/docs/platform/data-retention.md) of the project, its team or the organization |
| Spend records | One spend event per request: cost, tokens, model, virtual key, end user | Spend store | A fixed 13 months. Exempt from the data retention policy. See [Billing and spend events](https://langwatch.ai/docs/ai-gateway/billing-events.md) |
| Budget ledger | The debits each budget enforces against | Budget ledger | No expiry |
| Audit log | Who created, rotated, revoked or changed a virtual key, budget, provider, cache rule or guardrail | Postgres audit log | Not subject to the data retention policy. See [Audit log](https://langwatch.ai/docs/ai-gateway/audit.md) |
| OCSF events | One OCSF row per trace that arrives through an ingestion source | OCSF event store | No expiry. See [OCSF export](https://langwatch.ai/docs/ai-gateway/governance/ocsf-export.md) |

## Traces follow the data retention policy

Set the policy under **Settings > Data Retention**. A policy applies to an organization, a team or a project, and the most specific one wins. Periods are whole weeks. You can apply a new policy to data that is already stored.

> [!NOTE]
>
> Retention is scoped per organization, team, and project, never per ingestion source. Compliance
> notes that describe a per-source retention class map onto these scoped policies instead.

Trace retention and spend retention are independent. When a trace ages out before its spend record, the spend record still reconciles, and only the link from the record to the trace is gone.

**Also check:** [Data retention](https://langwatch.ai/docs/platform/data-retention.md) for the plan limits, the presets and how deletion works.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.