# Create an insert rule

Abstract

How to create an insert rule to restrict what users can insert under existing items.

You can assign insert rules to an insert option to dynamically redefine the effective insert options that are available for a user at runtime.

To create an insert rule:

1. Create a class that inherits from the Sitecore.Data.Masters.InsertRule class with a constructor that accepts a single System.Int32 parameter, and override the Expand() method. You can use the following code sample:

namespace Namespace.Data.InsertRules
{
public class ClassName : Sitecore.Data.Masters.InsertRule
{
public ClassName(System.Int32 count)
{
}
public override void Expand( System.Collections.Generic.List<Sitecore.Data.Items.Item> insertOptions, Sitecore.Data.Items.Item item)
{
//TODO: manipulate insertOptions
}
}
}
2. In the Content Editor, insert any required project-specific folders under /Sitecore/System/Settings/Insert Rules using the /Templates/Common/Folder data template template.

3. In the relevant project-specific folder, insert an insert rule definition item using the /System/Branches/Insert Rule data template template.

4. In the insert rule definition item, in the Data section, in the Type field, enter the signature of the class.

### Note

To assign the insert rule to other items, see Assign or copy insert options.