InSitecore XM Cloud, the correct GraphQL mutation to create a new item using theAuthoring and Management GraphQL APIiscreateItem. This mutation allows developers to programmatically create content items within Sitecore while specifying the required parent item, template, and field values.
Correct Mutation Examplemutation {
createItem(
parent: "/sitecore/content/Home",
name: "NewPage",
template: "Sample/Sample Item",
fields: [
{ name: "Title", value: "My New Page" },
{ name: "Text", value: "This is a sample text content." }
]
) {
item {
id
name
path
}
}
}
parent→ The path or ID of the parent item where the new item should be created.
name→ The name of the new item.
template→ The template that defines the structure of the item.
fields→ The array of field values assigned to the new item.
A.createOrUpdateItem→ This mutation does not exist in Sitecore GraphQL API.
B.createTemplateItem→ This is an incorrect name; Sitecore does not provide such a mutation.
D.updateItem→ This mutation is used to update an existing item, not create a new one.
Sitecore GraphQL API for Authoring and Management
GraphQL Mutation to Create an Item
Sitecore XM Cloud Developer Documentation
Explanation of Parameters:Why Other Options Are Incorrect?Relevant XM Cloud Documentation References:
Submit