{"command":{"effect":"write","timeoutSeconds":30,"inputSchema":{"type":"object","description":"Create a new AI Search instance with the given configuration. If type is omitted or null, a non-blank HTTP(S) source infers web-crawler and any other source infers r2; r2 sources must name an existing bucket. A missing or blank source without a type creates a managed upload-only instance.","properties":{"path":{"type":"object","properties":{"account_id":{"type":"string","examples":["c3dc5f0b34a14ff8e1b3ec04895e1b22"]},"namespace":{"type":"string","default":"default","examples":["my-namespace"],"description":"Namespace name."}},"required":["account_id","namespace"],"additionalProperties":false},"body":{"type":"object","properties":{"ai_gateway_id":{"type":["string","null"]},"ai_search_model":{"description":"A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.","type":["string","null"]},"cache":{"type":"boolean","default":true},"cache_threshold":{"type":"string","default":"close_enough","enum":["super_strict_match","close_enough","flexible_friend","anything_goes"]},"cache_ttl":{"description":"Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d).","default":172800,"anyOf":[{"enum":[600],"type":"number"},{"enum":[1800],"type":"number"},{"enum":[3600],"type":"number"},{"enum":[7200],"type":"number"},{"enum":[21600],"type":"number"},{"enum":[43200],"type":"number"},{"enum":[86400],"type":"number"},{"enum":[172800],"type":"number"},{"enum":[259200],"type":"number"},{"enum":[518400],"type":"number"}]},"chunk":{"type":"boolean","default":true},"chunk_overlap":{"type":"integer","default":10,"maximum":30,"minimum":0},"chunk_size":{"type":"integer","minimum":64},"custom_metadata":{"type":"array","items":{"properties":{"data_type":{"type":"string","enum":["text","number","boolean","datetime"]},"field_name":{"type":"string","maxLength":64,"minLength":1}},"required":["field_name","data_type"],"type":"object"},"maxItems":5},"embedding_model":{"type":["string","null"]},"fusion_method":{"type":"string","default":"rrf","enum":["max","rrf"]},"hybrid_search_enabled":{"description":"Deprecated — use index_method instead. Defaults to true for new instances; set false to create a vector-only instance.","type":"boolean"},"id":{"description":"AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.","type":"string","maxLength":64,"minLength":1,"pattern":"^[a-z0-9_]+(?:-[a-z0-9_]+)*$","examples":["my-ai-search"]},"index_method":{"description":"Controls which storage backends indexing uses. Defaults to vector and keyword indexing for new instances. When set, both vector and keyword are required.","type":"object","properties":{"keyword":{"description":"Enable keyword (BM25) storage backend.","type":"boolean"},"vector":{"description":"Enable vector (embedding) storage backend.","type":"boolean"}},"required":["vector","keyword"]},"indexing_options":{"type":["object","null"],"properties":{"keyword_tokenizer":{"description":"Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter.","type":"string","default":"porter","enum":["porter","trigram"]},"use_ocr":{"description":"Enables OCR ingestion for PDFs and images. Changing this triggers a full re-index. Defaults to false.","type":"boolean","default":false}}},"max_num_results":{"type":"integer","default":10,"maximum":50,"minimum":1},"metadata":{"type":"object","properties":{"created_from_aisearch_wizard":{"type":"boolean"},"created_from_emdash_plugin":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["native","rest"]},"version":{"type":"string"}},"required":["type","version"]},"worker_domain":{"type":"string"}}},"public_endpoint_params":{"type":"object","properties":{"authorized_hosts":{"type":"array","items":{"type":"string"}},"chat_completions_endpoint":{"type":"object","properties":{"disabled":{"description":"Disable chat completions endpoint for this public endpoint.","type":"boolean","default":false}}},"custom_domains":{"description":"Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged).","type":["array","null"],"items":{"description":"Custom domain hostname. Must belong to a Verified zone on this account.","maxLength":253,"minLength":1,"type":"string","examples":["search.example.com"]},"maxItems":1},"default_domain_enabled":{"description":"When false, the instance is reachable only via a registered custom domain and the default <public_endpoint_id>.search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true.","type":"boolean","default":true},"enabled":{"type":"boolean","default":false},"mcp":{"type":"object","properties":{"description":{"type":"string","default":"Finds exactly what you're looking for"},"disabled":{"description":"Disable MCP endpoint for this public endpoint.","type":"boolean","default":false}}},"rate_limit":{"type":"object","properties":{"period_ms":{"type":"integer","maximum":3600000,"minimum":60000},"requests":{"type":"integer","minimum":1},"technique":{"type":"string","enum":["fixed","sliding"]}}},"search_endpoint":{"type":"object","properties":{"disabled":{"description":"Disable search endpoint for this public endpoint.","type":"boolean","default":false}}}}},"reranking":{"type":"boolean","default":false},"reranking_model":{"type":["string","null"]},"retrieval_options":{"type":["object","null"],"properties":{"boost_by":{"description":"Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to 'asc' for numeric/datetime fields and 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field.","type":"array","items":{"properties":{"direction":{"description":"Boost direction. 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost chunks that lack the field. Optional — defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields.","type":"string","enum":["asc","desc","exists","not_exists"]},"field":{"description":"Metadata field name to boost by. Use 'timestamp' for document freshness, or any custom_metadata field. Numeric and datetime fields support all four directions (asc, desc, exists, not_exists); text/boolean fields only support exists/not_exists.","type":"string","maxLength":64,"minLength":1,"examples":["timestamp"]}},"required":["field"],"type":"object"},"maxItems":3,"examples":[[{"direction":"desc","field":"timestamp"}]]},"keyword_match_mode":{"description":"Controls which documents become candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term and ranks results according to BM25 relevance. When omitted on an update, the existing stored value stays unchanged; when never set, search falls back to 'and'.","type":"string","enum":["and","or"]}}},"rewrite_model":{"description":"A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.","type":["string","null"]},"rewrite_query":{"type":"boolean","default":false},"score_threshold":{"description":"Minimum similarity score a chunk must reach to be returned. Defaults to 0.4.","type":"number","maximum":1,"minimum":0},"source":{"type":["string","null"]},"source_params":{"type":["object","null"],"properties":{"exclude_items":{"description":"List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced). Most accounts have a limit of 10 rules; contact support to raise it.","type":"array","items":{"maxLength":500,"pattern":"^[*/\\\\]?[\\w\\-/.\\\\?*:=&%]+$","type":"string"},"maxItems":10,"examples":[["/admin/**","/private/**","**\\temp\\**"]]},"include_items":{"description":"List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post). Most accounts have a limit of 10 rules; contact support to raise it.","type":"array","items":{"maxLength":500,"pattern":"^[*/\\\\]?[\\w\\-/.\\\\?*:=&%]+$","type":"string"},"maxItems":10,"examples":[["/blog/**","/docs/**/*.html","**\\blog\\**.html"]]},"prefix":{"type":"string"},"r2_jurisdiction":{"type":"string","default":"default"},"web_crawler":{"type":"object","default":{"parse_type":"sitemap"},"properties":{"discover_options":{"description":"Options for parse_type 'discover', where Browser Run discovers URLs through link following and sitemaps. Ignored for 'sitemap'.","type":"object","properties":{"depth":{"description":"Maximum link-follow depth from the seed URL.","type":"number","default":5,"maximum":100000,"minimum":1,"examples":[5]},"include_external_links":{"description":"Follow links that point outside the source domain. Must stay `false` because discover crawls only cover the zone you own.","type":"boolean","default":false,"examples":[false]},"include_subdomains":{"description":"Follow links to subdomains of the source host.","type":"boolean","default":false,"examples":[false]},"limit":{"description":"Maximum number of pages to crawl (1-100000).","type":"number","default":100000,"maximum":100000,"minimum":1,"examples":[10000]},"max_age":{"description":"Maximum content age in seconds to accept (0–604800).","type":"number","default":86400,"maximum":604800,"minimum":0,"examples":[86400]},"source":{"description":"Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both.","type":"string","default":"all","enum":["all","sitemaps","links"],"examples":["all"]}}},"parse_options":{"type":"object","properties":{"content_selector":{"description":"List of path-to-selector mappings for extracting specific content from crawled pages. Each entry pairs a URL glob pattern with a CSS selector. The first matching path wins. The crawler stores and indexes only the matched HTML fragment. Omit the field to disable content selection; the API rejects empty arrays.","type":"array","items":{"properties":{"path":{"description":"Glob pattern to match against the page URL path. Uses standard glob syntax: * matches within a segment, ** crosses directories.","type":"string","maxLength":200,"minLength":1,"examples":["**/article/**"]},"selector":{"description":"CSS selector to extract content from pages matching the path pattern. Disallowed characters: ;, `, $, {, }, \\. Must target a single element; if multiple elements match, the crawler ignores the selector and uses the full page.","type":"string","maxLength":200,"minLength":1,"examples":["article div.post-body"]}},"required":["path","selector"],"type":"object"},"maxItems":10,"minItems":1,"examples":[[{"path":"**/blog/**","selector":"article div.post-body"},{"path":"**/docs/**","selector":"main"}]]},"include_headers":{"description":"Up to 5 custom HTTP headers sent with each crawl request. Names must use RFC-7230 token characters, excluding spaces, colons, and control characters. Values must use HTAB and printable ASCII only, excluding CR and LF.","type":"object","additionalProperties":{"maxLength":8192,"pattern":"^[\\t\\x20-\\x7E]*$","type":"string"},"examples":[{"cache-control":"no-cache, no-store"}]},"include_images":{"type":"boolean","default":false},"specific_sitemaps":{"description":"List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'.","type":"array","items":{"format":"uri","type":"string"},"maxItems":10,"examples":[["https://example.com/sitemap.xml","https://example.com/blog-sitemap.xml"]]},"use_browser_rendering":{"type":"boolean","default":true}}},"parse_type":{"description":"How the crawler finds URLs. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to belong to a Verified zone on this account.","type":"string","default":"sitemap","enum":["sitemap","discover"],"examples":["sitemap"]}}}}},"sync_interval":{"description":"Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). Defaults to 86400 (24h).","anyOf":[{"enum":[900],"type":"number"},{"enum":[1800],"type":"number"},{"enum":[3600],"type":"number"},{"enum":[7200],"type":"number"},{"enum":[14400],"type":"number"},{"enum":[21600],"type":"number"},{"enum":[43200],"type":"number"},{"enum":[86400],"type":"number"}]},"token_id":{"type":"string","format":"uuid"},"type":{"description":"Source type. When omitted or null with a non-blank source, HTTP(S) URLs infer web-crawler and existing R2 bucket names infer r2. A missing or blank source without a type uses managed upload-only storage.","type":["string","null"],"enum":["r2","web-crawler",null]}},"required":["id"]}},"required":["path"],"additionalProperties":false},"name":"Create an AI Search instance.","id":"cloudflare.ai-search-namespace-create-instance","example":{"path":{"account_id":"c3dc5f0b34a14ff8e1b3ec04895e1b22","namespace":"my-namespace"}},"maxRequests":1,"summary":false}}