{"id":185,"date":"2026-01-20T00:00:00","date_gmt":"2026-01-20T00:00:00","guid":{"rendered":"https:\/\/wordpress.securinsight.ca\/index.php\/2026\/01\/20\/ai-search-create-ai-search-instances-programmatically-via-rest-api\/"},"modified":"2026-01-20T00:00:00","modified_gmt":"2026-01-20T00:00:00","slug":"ai-search-create-ai-search-instances-programmatically-via-rest-api","status":"publish","type":"post","link":"https:\/\/wordpress.securinsight.ca\/index.php\/2026\/01\/20\/ai-search-create-ai-search-instances-programmatically-via-rest-api\/","title":{"rendered":"AI Search &#8211; Create AI Search instances programmatically via REST API"},"content":{"rendered":"<p>You can now create <a href=\"https:\/\/developers.cloudflare.com\/ai-search\/\">AI Search<\/a> instances programmatically using the <a href=\"https:\/\/developers.cloudflare.com\/ai-search\/get-started\/api\/\">API<\/a>. For example, use the API to create instances for each customer in a multi-tenant application or manage AI Search alongside your other infrastructure.<\/p>\n<p>If you have created an AI Search instance via the <a href=\"https:\/\/developers.cloudflare.com\/ai-search\/get-started\/dashboard\/\">dashboard<\/a> before, you already have a <a href=\"https:\/\/developers.cloudflare.com\/ai-search\/configuration\/service-api-token\/\">service API token<\/a> registered and can start creating instances programmatically right away. If not, follow the <a href=\"https:\/\/developers.cloudflare.com\/ai-search\/get-started\/api\/\">API guide<\/a> to set up your first instance.<\/p>\n<p>For example, you can now create separate search instances for each language on your website:<\/p>\n<div>\n<figure>\n<pre data-language=\"bash\"><code class=\"language-bash\"><div><div><span>for<\/span><span> <\/span><span>lang<\/span><span> <\/span><span>in<\/span><span> <\/span><span>en<\/span><span> <\/span><span>fr<\/span><span> <\/span><span>es<\/span><span> <\/span><span>de<\/span><span>;<\/span><span> <\/span><span>do<\/span><\/div><\/div><div><div><span>  <\/span><span>curl<\/span><span> <\/span><span>-X<\/span><span> <\/span><span>POST<\/span><span> <\/span><span>\"https:\/\/api.cloudflare.com\/client\/v4\/accounts\/<\/span><span>$ACCOUNT_ID<\/span><span>\/ai-search\/instances\"<\/span><span> <\/span><span><\/span><\/div><\/div><div><div><span>    <\/span><span>-H<\/span><span> <\/span><span>\"Authorization: Bearer <\/span><span>$API_TOKEN<\/span><span>\"<\/span><span> <\/span><span><\/span><\/div><\/div><div><div><span>    <\/span><span>-H<\/span><span> <\/span><span>\"Content-Type: application\/json\"<\/span><span> <\/span><span><\/span><\/div><\/div><div><div><span>    <\/span><span>--data<\/span><span> <\/span><span>'{<\/span><\/div><\/div><div><div><span><span>      <\/span><\/span><span>\"id\": \"docs-'\"<\/span><span>$lang<\/span><span>\"'\",<\/span><\/div><\/div><div><div><span><span>      <\/span><\/span><span>\"type\": \"web-crawler\",<\/span><\/div><\/div><div><div><span><span>      <\/span><\/span><span>\"source\": \"example.com\",<\/span><\/div><\/div><div><div><span><span>      <\/span><\/span><span>\"source_params\": {<\/span><\/div><\/div><div><div><span><span>        <\/span><\/span><span>\"path_include\": [\"**\/'\"<\/span><span>$lang<\/span><span>\"'\/**\"]<\/span><\/div><\/div><div><div><span><span>      <\/span><\/span><span>}<\/span><\/div><\/div><div><div><span><span>    <\/span><\/span><span>}'<\/span><\/div><\/div><div><div><span>done<\/span><\/div><\/div><\/code><\/pre>\n<div><\/div>\n<\/figure>\n<\/div>\n<p>Refer to the <a href=\"https:\/\/developers.cloudflare.com\/api\/resources\/ai_search\/subresources\/instances\/methods\/create\/\">REST API reference<\/a> for additional configuration options.<\/p>","protected":false},"excerpt":{"rendered":"<p>You can now create AI Search instances programmatically using the API. For example, use the API to create instances for each customer in a multi-tenant application or manage AI Search alongside your other infrastructure. If you have created an AI Search instance via the dashboard before, you already have a service API token registered and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-185","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/posts\/185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/comments?post=185"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/posts\/185\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/media?parent=185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/categories?post=185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/tags?post=185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}