Show examples in:
JavascriptHTTP
Endpoint info
Available examples
Content Management API > Search Index

Create a search index

Body parameters

namestringRequired

Name of the search index

Example:"Production Website"
enabledbooleanRequired

Whether the search index is enabled or not

frontend_urlstring, nullRequired

The public URL of the website. This is the starting point from which the website's spidering will start

Example:"https://www.mywebsite.com/"
user_agent_suffixstring, nullOptional

Optional suffix to append to the DatoCmsSearchBot user agent when indexing the website

Example:"v1.0.0"
build_triggersOptional

The build triggers that can trigger this search index

Type:Array&#x3C;<a href="/docs/content-management-api/resources/build_trigger">ResourceLinkage&#x3C;"build_trigger"></a>>

Returns

Returns a resource object of type search_index

Examples

import { buildClient } from "@datocms/cma-client-node";
async function run() {
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
const searchIndex = await client.searchIndexes.create({
name: "Production Website",
enabled: true,
frontend_url: "https://www.mywebsite.com/",
});
// Check the 'Returned output' tab for the result ☝️
console.log(searchIndex);
}
run();
{
id: "1822",
name: "Production Website",
enabled: true,
frontend_url: "https://www.mywebsite.com/",
user_agent_suffix: "v1.0.0",
meta: {
indexing_status: "success",
last_indexing_completed_at: "2025-03-30T09:29:14.872Z",
},
build_triggers: [{ type: "build_trigger", id: "1822" }],
}