This guide covers search domain filtering on the Agent API. You will learn how to use allowlists to restrict search to trusted domains, denylists to exclude unwanted sources, and practical patterns for common use cases like news-only search, government data, and competitor exclusion.Documentation Index
Fetch the complete documentation index at: https://docs.perplexity.ai/llms.txt
Use this file to discover all available pages before exploring further.
Domain filtering is configured per-tool under the
tools array via tools[].filters.search_domain_filter. For the full reference, see Agent API Filters.Prerequisites
Install the Perplexity SDK:Get your Perplexity API Key
Navigate to the API Keys tab in the API Portal and generate a new key.
How Domain Filtering Works
Thesearch_domain_filter parameter accepts a list of domain strings:
- Allowlist (no prefix): Include only results from these domains.
["reuters.com", "apnews.com"]means search only Reuters and AP News. - Denylist (
-prefix): Exclude results from these domains.["-reddit.com", "-twitter.com"]means exclude Reddit and Twitter.
Basic Domain Filtering
Domain filters are configured per-tool under thetools array.
Pattern: Denylist Filtering
Use the- prefix to exclude specific domains from search results.
Pattern: News-Only Search
Restrict results to major news outlets for current events and breaking news.Pattern: Government and Official Sources
Restrict to government domains for policy, regulation, and official statistics.Pattern: Academic and Research Filtering
Target educational and research institutions.Pattern: Competitor Exclusion
Use denylists to exclude competitor websites from search results when building customer-facing content.Configurable Filter Builder
A reusable helper that builds domain filter configurations from named presets.Common Pitfalls
Mixing allowlist and denylist
Using wildcards incorrectly
Empty filter arrays
Tips and Best Practices
- Keep allowlists focused. 5-10 domains is usually sufficient. Too many domains dilutes the filter’s purpose.
- Use denylists for broad exclusion. When you want to exclude a few noisy sources but otherwise search the full web, denylists are more practical than trying to allowlist everything else.
-
Combine with recency filters. For time-sensitive queries, add
search_recency_filteralongside domain filters. - Test your filters. Run the same query with and without filters to verify that results change as expected.
-
TLD filters work broadly. Using
.govmatches any domain ending in.gov, includingwhitehouse.gov,irs.gov, and state domains likeca.gov. - Store presets in configuration. Define filter presets in your app configuration rather than hardcoding them in every request.
Next Steps
Agent API Filters
Full reference for domain, date range, and location filters on the Agent API.
Search API Filters
Domain filtering on the raw Search API for result-level control.
Academic Search
Specialized academic search with domain filtering.
Migration Guide
Migrate from Sonar to the Agent API for multi-provider access and tools.