using the API like this
// Prepares the code name (class name) of the custom table to which the data record will be added
string customTableClassName = "customtable.sampletable";
// Gets the custom table
DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);
if (customTable != null)
{
// Creates a new custom table item
CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName);
// Sets the values for the fields of the custom table (ItemText in this case)
newCustomTableItem.SetValue("ItemText", "New text");
// Save the new custom table record into the database
newCustomTableItem.Insert();
}