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

# query_range_exceeds_retention

> Your query requests data older than your workspace's retention period in Unkey. Narrow the time range to stay within your plan's limits.

<Danger>`err:user:bad_request:query_range_exceeds_retention`</Danger>

## What does this error mean?

This error occurs when your analytics query attempts to access data older than your workspace's configured data retention period. By default, Unkey retains analytics data for **30 days**.

**Note**: If you don't provide a time filter in your query, the system automatically adds one to scope your query to the full retention period (e.g., `time >= now() - INTERVAL 30 DAY`). This error only occurs when you explicitly specify a time range that goes beyond the retention period.

## Common causes

1. **Querying historical data beyond retention**: Your query's time filter includes dates older than your retention period
   ```sql theme={"theme":"kanagawa-wave"}
   -- If your retention is 30 days, this will fail if querying > 30 days ago
   SELECT COUNT(*) FROM key_verifications_v1 WHERE time >= 1234567890000
   ```

## How to fix

1. **Add a time filter within retention**: Ensure your query only accesses data within your retention period

   ```sql theme={"theme":"kanagawa-wave"}
   -- Query last 7 days (within 30-day retention)
   SELECT COUNT(*) FROM key_verifications_v1
   WHERE time >= now() - INTERVAL 7 DAY
   ```

2. **Adjust your query range**: If you need to analyze trends, query within your available retention window
   ```sql theme={"theme":"kanagawa-wave"}
   -- Query the full 30-day retention period
   SELECT COUNT(*) FROM key_verifications_v1
   WHERE time >= now() - INTERVAL 30 DAY
   ```

## Need longer retention?

If your use case requires data retention beyond 30 days, please [contact our support team](https://unkey.com/support) to discuss upgrading your retention period. We can configure custom retention periods based on your needs.

## Related

* [Analytics documentation](/platform/analytics/overview)
* [Analytics query examples](/platform/analytics/query-examples)
