Skip to content
AnswerWell geo Documentation

Research · 8 min read · Answerwell

Public Endpoint Search, UI Snippets, MCP, and Custom Domains

How Cloudflare AI Search public endpoints expose search, chat, and MCP; embed UI snippets; use custom domains, Access, and namespace URLs.

This page summarises Cloudflare documentation on AI Search public endpoints: unauthenticated URLs that expose /search, /chat/completions, and /mcp, plus UI snippets for site embeds, custom domains, Cloudflare Access, and namespace endpoints that query several instances at once.

Public endpoint: what it is and when to use it

Section titled “Public endpoint: what it is and when to use it”

A public endpoint is a URL your site or app can call directly, without API authentication in front of AI Search.

Public endpoints allow you to expose AI Search capabilities without requiring API authentication.

— Cloudflare, AI Search UI snippets and MCP support

That design suits public docs sites, marketing sites, and MCP clients you want to reach without baking API tokens into frontend code. The trade-off is explicit in the docs: anyone who knows the URL can query indexed content unless you add a custom domain and Cloudflare Access (see below).

Use the authenticated REST API or Workers bindings when only your backend should call search, or when you need full account-scoped control without a browser-facing URL.

Public endpoint hostnames: instance URL vs namespace URL

Section titled “Public endpoint hostnames: instance URL vs namespace URL”

Cloudflare generates the hostname when you enable the feature; it is not the instance or namespace name.

Hostname pattern Serves
https://<PUBLIC_ENDPOINT_ID>.search.ai.cloudflare.com One AI Search instance
https://ns-<NAMESPACE_ENDPOINT_ID>.search.ai.cloudflare.com A namespace; searches across allowed instances and merges results

You can enable a public endpoint on a single instance or on a whole namespace. A namespace endpoint serves the same three paths and searches across the instances you allow in that namespace, merging the results.

— Cloudflare, Public endpoint

Each enabled endpoint exposes the same three paths (paths and request bodies match the REST API shapes described in Public endpoint settings):

Path Role
/search Returns relevant chunks without generating an answer
/chat/completions Retrieves context and generates a chat completion
/mcp Model Context Protocol endpoint for agents

The identifier is created the first time you enable the endpoint and is not rotated; disabling keeps the ID so re-enabling reuses the same URL (Public endpoint settings).

How to turn on Public Endpoint in the dashboard

Section titled “How to turn on Public Endpoint in the dashboard”
  1. Open AI Search in the Cloudflare dashboard and select your instance or namespace.

  2. Go to Settings → Public Endpoint (or Public Endpoints for per-path toggles).

  3. Turn on Enable Public Endpoint, then enable /search, /chat/completions, and/or /mcp as needed.

  4. Copy the public endpoint URL (for snippets, use it as api-url; for MCP, append /mcp).

For namespace setup via API, including instances_allowed, see Namespace public endpoints.

UI snippets: embed search and chat on your website

Section titled “UI snippets: embed search and chat on your website”

UI snippets are pre-built web components that connect to your instance through its public endpoint.

UI snippets are pre-built search and chat components you can embed in your website.

— Cloudflare, AI Search UI snippets and MCP support

The library ships as @cloudflare/ai-search-snippet and as a module script from your endpoint host (UI snippets, Add search to your website).

Component Behavior
search-bar-snippet Inline bar with dropdown results
search-modal-snippet Modal; often bound to Cmd/Ctrl+K via shortcut
chat-bubble-snippet Floating chat control
chat-page-snippet Full-page chat with history

Every component needs api-url pointing at your public endpoint base URL (for example https://<PUBLIC_ENDPOINT_ID>.search.ai.cloudflare.com/).

HTML: load the ES module from your endpoint, then add a tag (UI snippets):

<script
type="module"
src="https://<PUBLIC_ENDPOINT_ID>.search.ai.cloudflare.com/assets/v0.0.25/search-snippet.es.js"
></script>
<search-modal-snippet
api-url="https://<PUBLIC_ENDPOINT_ID>.search.ai.cloudflare.com/"
placeholder="Search..."
></search-modal-snippet>

React (Vite and similar): install the package, import once to register custom elements, then use JSX tags (Add search to your website):

npm i @cloudflare/ai-search-snippet
import "@cloudflare/ai-search-snippet";
<search-bar-snippet
api-url="https://<PUBLIC_ENDPOINT_ID>.search.ai.cloudflare.com/"
placeholder="Search..."
max-results={50}
max-render-results={10}
/>

For TypeScript, add a small declare module "react" intrinsic-elements file so JSX accepts the custom tags (Add search to your website).

Styling uses CSS variables prefixed with --search-snippet-; the UI snippets doc links a playground on search.ai.cloudflare.com for attributes and themes.

Authorized hosts (CORS): local dev and production origins

Section titled “Authorized hosts (CORS): local dev and production origins”

Snippets run in the visitor’s browser, so the public endpoint must allow your site origin under Authorized hosts (Add search to your website, UI snippets).

The public endpoint uses CORS to control which sites can call it. Add the origin your site runs on during local development so the browser can reach the endpoint.

— Cloudflare, Add search to your website

MCP endpoint: connect AI agents to your indexed content

Section titled “MCP endpoint: connect AI agents to your indexed content”

The /mcp path exposes a search tool over your index so MCP clients can retrieve content without custom integration code.

The MCP endpoint allows AI agents to search your content via the Model Context Protocol. Connect your MCP client to: https://<PUBLIC_ENDPOINT_ID>.search.ai.cloudflare.com/mcp

— Cloudflare, AI Search UI snippets and MCP support

Enable Public Endpoint and the MCP toggle under Settings → Public Endpoint, then set a Tool Description so agents know when to call search (Connect your AI Search to an MCP client). Typical client config:

{
"mcpServers": {
"ai-search": {
"url": "https://<PUBLIC_ENDPOINT_ID>.search.ai.cloudflare.com/mcp"
}
}
}

Namespace hosts use the ns- prefix: https://ns-<NAMESPACE_ENDPOINT_ID>.search.ai.cloudflare.com/mcp (MCP). Test with JSON-RPC tools/call and header Accept: application/json, text/event-stream (MCP).

To require auth for agents, put a custom domain behind Access and send CF-Access-Client-Id and CF-Access-Client-Secret (MCP, Connect your AI Search to an MCP client).

Custom domains: serve search from your own hostname

Section titled “Custom domains: serve search from your own hostname”

A custom domain serves the same /search, /chat/completions, and /mcp paths from a hostname you own, for example https://search.example.com/search (Custom domains, AI Search makes it easier to build a search engine for your data).

Requirements (Custom domains):

  • Public endpoint already enabled (error 7093 if not).
  • Hostname in a zone on the same Cloudflare account, active (error 7090 if not).
  • One custom domain per instance or namespace; hostname cannot be shared (error 7091).
  • FQDN up to 253 characters; no wildcards.

Create a proxied CNAME to <PUBLIC_ENDPOINT_ID>.search.ai.cloudflare.com. Proxied routing (“orange-to-orange”) is what lets Access, WAF, and Bot Management run in your zone before AI Search (Custom domains, Cloudflare Access).

default_domain_enabled: close the generated hostname

Section titled “default_domain_enabled: close the generated hostname”

By default, both the custom domain and https://<PUBLIC_ENDPOINT_ID>.search.ai.cloudflare.com work. For Access or other zone controls, set default_domain_enabled to false so the default host returns 404 with error 60018 (Custom domains, Cloudflare Access). You cannot disable the default host without at least one custom domain (error 7096).

Section titled “Cloudflare Access: authenticated public search”

Cloudflare Access in front of a custom domain turns an otherwise public knowledge base into one that requires IdP login before requests reach AI Search (Cloudflare Access).

A public endpoint is unauthenticated by design. Anyone who knows the URL can query your indexed content. Put a custom domain in front of the public endpoint and protect it with Cloudflare Access.

— Cloudflare, Cloudflare Access

Limitations called out in the docs (Cloudflare Access):

  • UI snippets on a fully public marketing site should keep the endpoint open; behind Access, only users who pass policy can use browser embeds—suited to internal sites.
  • Cross-origin browser calls need Access CORS configuration in addition to Authorized hosts on the endpoint.
  • AI Search rate limits still apply after Access, shared across authenticated callers.

Verify with curl against the custom domain (expect an Access login response without credentials) and confirm the default hostname returns 404 / 60018 when disabled (Cloudflare Access).

Namespace public endpoint: one URL across several instances

Section titled “Namespace public endpoint: one URL across several instances”

A namespace public endpoint is for one search experience over multiple instances (docs, blog, support) in the same namespace (Namespace public endpoints).

Enable with public_endpoint_params.instances_allowed (up to 10 instance names; empty list means nothing is searchable). Unknown IDs return 7097; requests with no valid target return 404 / 60013 (Namespace public endpoints).

To search only a subset per request, set ai_search_options.instance_ids in the JSON body (Namespace public endpoints, AI Search makes it easier to build a search engine for your data):

curl https://ns-<NAMESPACE_ENDPOINT_ID>.search.ai.cloudflare.com/search \
--header "Content-Type: application/json" \
--data '{
"messages": [{ "content": "How do I configure AI Search?", "role": "user" }],
"ai_search_options": { "instance_ids": ["docs", "support"] }
}'

The same pattern exists on Workers: env.AI_SEARCH.search({ ai_search_options: { instance_ids: [...] } }) merges and ranks results; each chunk includes instance_id (Workers binding, Search across multiple instances).

Security, rate limits, and common mistakes

Section titled “Security, rate limits, and common mistakes”

If the endpoint stays open (Public endpoint settings, Connect your AI Search to an MCP client):

  • Index only content safe to expose publicly.
  • Set rate limiting under public endpoint settings.
  • Disable unused paths (for example /mcp if you only need /search).
  • Replace * in Authorized hosts with your production origin before launch (UI snippets).

Common mistakes

  1. Leaving default_domain_enabled true while using Access on a custom domain—the generated *.search.ai.cloudflare.com URL still answers without your policies (Cloudflare Access).
  2. DNS-only CNAME—traffic bypasses your zone; Access never runs (Cloudflare Access).
  3. Partial API updates—omitting default_domain_enabled or instances_allowed resets defaults (Custom domains, Namespace public endpoints).
  4. Treating Authorized hosts as auth—direct HTTP clients ignore CORS (Cloudflare Access).
  5. Skipping local Authorized hosts—snippet tests fail in the browser until you add http://localhost:5173 (or your dev port) (Add search to your website).

Retrieval options (thresholds, reranking, query rewriting, system prompt) remain configurable on the instance; see the Configuration table for what stays editable after creation.

  1. In the Cloudflare dashboard, open your AI Search instance → Settings → Public Endpoint and confirm the URL matches what your snippets or clients use (Public endpoint).
  2. From a terminal, POST to /search on that host with a JSON messages body and confirm chunks return (Public endpoint).
  3. Load your site with a snippet, search from the bar or modal, and confirm dropdown or modal results (Add search to your website).
  4. If you use a custom domain or Access, repeat curl checks from Cloudflare Access (login page on the custom host; 60018 on the disabled default host).
  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page does not match your setup or the official docs, email yimasynthetic@gmail.com with the page URL and the exact wording you think is wrong so we can correct it.