The search_after_date_filter and search_before_date_filter parameters allow you to restrict search results to a specific publication date range. Only results with publication dates falling between these dates will be returned.

The last_updated_after_filter and last_updated_before_filter parameters allow you to filter by when content was last modified or updated, rather than when it was originally published.

Dates must be provided in the “%m/%d/%Y” format (e.g., “3/1/2025”). These filters are optional—you may supply either one or both as needed.

Overview

Date range filters allow you to control which search results are returned by limiting them to specific time periods. There are two types of date filters available:

Publication Date Filters

The search_after_date_filter and search_before_date_filter parameters filter results based on when content was originally created or published. This is useful when you need to: • Find content published within a specific timeframe • Exclude outdated or overly recent publications • Focus on content from a particular publication period

Last Updated Date Filters

The last_updated_after_filter and last_updated_before_filter parameters filter results based on when content was last modified or updated. This is useful when you need to: • Find recently updated or maintained content • Exclude stale content that hasn’t been updated recently • Focus on content that has been refreshed within a specific period

Important: These filter types target different dates—publication filters use the original creation/publication date, while last updated filters use the modification date.

To constrain search results by publication date:

"search_after_date_filter": "3/1/2025",
"search_before_date_filter": "3/5/2025"

To constrain search results by last updated date:

"last_updated_after_filter": "3/1/2025",
"last_updated_before_filter": "3/5/2025"

These filters will be applied in addition to any other search parameters (for example, domain filters).

Examples

1. Limiting Results by Publication Date Range

This example limits search results to content published between March 1, 2025, and March 5, 2025.

Request Example

curl --location 'https://api.perplexity.ai/chat/completions' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "sonar-pro",
    "messages": [
      {"role": "system", "content": "You are an expert on current events."},
      {"role": "user", "content": "Show me tech news published this week."}
    ],
    "search_after_date_filter": "3/1/2025",
    "search_before_date_filter": "3/5/2025"
}'

2. Filtering with a Single Publication Date Parameter

If you only wish to restrict the results to those published on or after a specific date, include just the search_after_date_filter:

payload = {
    "model": "sonar-pro",
    "messages": [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Show me news articles published after March 1, 2025."}
    ],
    "search_after_date_filter": "3/1/2025"
}

3. Filtering by Last Updated Date Range

This example limits search results to content that was last updated between March 1, 2025, and March 5, 2025. This is useful for finding recently maintained or refreshed content.

Request Example

curl --location 'https://api.perplexity.ai/chat/completions' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "sonar-pro",
    "messages": [
      {"role": "system", "content": "You are an expert on current events."},
      {"role": "user", "content": "Show me recently updated tech articles."}
    ],
    "last_updated_after_filter": "3/1/2025",
    "last_updated_before_filter": "3/5/2025"
}'

4. Combining Publication and Last Updated Filters

You can combine both filter types to find content that was published in one timeframe and updated in another:

payload = {
    "model": "sonar-pro",
    "messages": [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Show me articles published last year but updated recently."}
    ],
    "search_after_date_filter": "1/1/2024",
    "search_before_date_filter": "12/31/2024",
    "last_updated_after_filter": "3/1/2025"
}

Best Practices

Date Format • Strict Format: Dates must match the “%m/%d/%Y” format exactly. For example, the date “3/1/2025” or “03/01/2025” is acceptable. • Consistency: Use one or both filters consistently based on your search needs. Combining both provides a clear range.

Filter Selection • Choose the Right Filter Type: Use publication date filters (search_after_date_filter/search_before_date_filter) when you care about when content was originally created. Use last updated filters (last_updated_after_filter/last_updated_before_filter) when you need recently maintained content. • Combining Filters: You can use both publication and last updated filters together to find content that meets both criteria (e.g., published in 2024 but updated recently).

Client-Side Validation • Regex Check: Validate date strings on the client side (or via the API) using a regex such as:

date_regex='^(0?[1-9]|1[0-2])/(0?[1-9]|[12][0-9]|3[01])/[0-9]{4}$'

This ensures that dates conform to the required format before sending the request.

Performance Considerations • Narrowing the Search: Applying date range filters typically reduces the number of results, which may improve response times and result relevance. • Avoid Over-Restriction: Ensure that the date range is neither too narrow (limiting useful results) nor too broad (defeating the purpose of the filter).