Mastering Cloudflare Search for Agents: Implementing and Testing /.well-known/search
- Authors

- Name
- Nino
- Occupation
- Senior Tech Editor
Cloudflare Search for Agents is a groundbreaking beta feature that allows website owners to index their content and provide a dedicated search API specifically for autonomous AI agents. By enabling a single toggle, Cloudflare creates a search endpoint at https://<your-domain>/.well-known/search. This endpoint allows agents to retrieve relevant Markdown chunks from your site using GET parameters or the modern HTTP QUERY method. Unlike generative AI, this service provides ranked source material, ensuring that models like Claude 3.5 Sonnet or OpenAI o3 can access factual, up-to-date information directly from your domain.
For developers building high-performance AI applications, integrating these endpoints with a reliable API aggregator like n1n.ai is essential. While Cloudflare handles the data retrieval, n1n.ai provides the stable, high-speed LLM access needed to process that data effectively.
Understanding the AI Search Ecosystem
Cloudflare's approach to making the web "agent-friendly" involves three distinct but complementary technologies: llms.txt, Markdown for Agents, and Search for Agents. Understanding the differences is crucial for any Retrieval-Augmented Generation (RAG) strategy.
| Feature | llms.txt | Markdown for Agents | Search for Agents |
|---|---|---|---|
| Core Function | A static file you write manually. | Cloudflare converts a single page to Markdown. | A full-site search API. |
| Agent Request | GET /llms.txt | Accept: text/markdown | GET ?q= or QUERY |
| Output | Curated list of high-level links. | A single page converted to Markdown. | Ranked chunks from multiple pages. |
| Maintenance | Manual updates. | Automatic conversion. | Cloudflare crawler (every 24h). |
| Best Use Case | Guiding agents to key entry points. | Reading a specific, discovered page. | Finding unknown pages across a domain. |
How to Enable Search for Agents
To begin, your domain must be active on Cloudflare. Follow these steps:
- Log in to the Cloudflare dashboard and select your domain.
- Navigate to the Overview page.
- Locate the Quick Actions section and toggle Search for Agents (Beta) to On.
- Review the default settings and pricing notification, then confirm.
Once enabled, Cloudflare spins up an AI Search instance named search-for-agents-<ZONE_ID>. This instance crawls your public sitemaps and links, indexing up to 100,000 pages by default with a depth of 5. It uses a hybrid search mode (combining vector embeddings and keyword matching) to ensure high relevance.
Technical Deep Dive: The Search Endpoint
When Search for Agents is active, Cloudflare injects four specific meta tags into your site's <head> to help agents discover the API:
agent:instructions: Guidance on how to use the search API.agent:endpoint: The URL for the search query (e.g.,https://example.com/.well-known/search?q={query}).agent:method: UsuallyGETorQUERY.agent:documentation: Link to Cloudflare's technical docs.
Testing with cURL
You can test the endpoint immediately using a simple cURL command. For instance, testing against Cloudflare's own developer documentation:
curl --get "https://developers.cloudflare.com/.well-known/search" \
--data-urlencode "q=How do I verify webhook signatures?"
The response will be a Markdown-formatted list of results, each containing a header with the source path, a relevance score, and the text chunk. If you prefer the modern QUERY method (standardized as RFC 10008), you can send the query in the request body:
curl -X QUERY "https://developers.cloudflare.com/.well-known/search" \
--header "Content-Type: text/plain" \
--data "How do I turn on Search for Agents?"
Automating Tests with Apidog CLI
While enabling the feature is easy, ensuring it returns the correct pages for specific queries is where many developers struggle. Scores returned by AI search are often relative, meaning even a "nonsense" query might return results with high scores. To maintain quality, you need a regression test suite.
Using Apidog CLI, you can automate this process. Start by installing the CLI and logging in:
npm install -g apidog-cli@latest
apidog login --with-token <YOUR_TOKEN>
You can then use an AI coding agent (like Claude Code or OpenCode) to generate a test suite that checks if specific queries return expected source paths. A sample prompt for your agent might look like this:
"Build a regression suite for https://docs.example.com/.well-known/search. Create test cases asserting status 200, content-type includes text/markdown, and the body includes the expected source path for each query."
Running this suite in your CI/CD pipeline ensures that as your documentation evolves, your AI search index remains accurate. For developers who require high-volume testing or complex agentic workflows, leveraging n1n.ai ensures that your backend LLMs have the throughput needed to analyze these search results in real-time.
Best Practices and Limitations
- Privacy Concerns: Cloudflare's crawler follows sitemaps and links. If you have staging or draft pages that are linked but not intended for the public, they may be indexed. Use robots.txt or path filtering to exclude sensitive areas.
- WAF and Bot Control: Ensure your Cloudflare WAF rules don't accidentally block the agents you want to invite. If you use "AI Crawl Control" to block all bots, you must create an exception for the Search for Agents endpoint.
- Index Latency: The index typically syncs every 24 hours. Changes made to your site today may not appear in search results until tomorrow.
- Pricing: While the toggle is available on all plans (including Free), usage is billed according to AI Search pricing. Monitor your "Semantic Queries" and "Ingestion Tokens" to avoid unexpected costs.
Conclusion
Cloudflare Search for Agents is a massive step forward for the programmable web. By providing a standardized way for agents to "search" rather than just "scrape," it reduces server load and increases the accuracy of AI-driven tools. To build the most robust AI applications, combine Cloudflare's search capabilities with the versatile LLM API access provided by n1n.ai.
Get a free API key at n1n.ai