XMP (SiteEdit) information is stored in CMS as application data, so you can do this using TOM.NET API by simply using the SaveApplicationData
method of Page
object. The only part that needs to be known is the format of the App Data to be used to create for XPM. There is not much documentation on this topic on what the format of the data looks like.
AppData XML structure is key and format has to be the same.
Here is the code using TOM.NET API
Page pg = ....// Get the page object using TOM.NET
string xpmXMLStr = @"<configuration xmlns=""http://www.sdltridion.com/2011/SiteEdit"">
<Page xmlns=""http://www.sdltridion.com/2011/SiteEdit"">
<PageType>
<Enabled>true</Enabled>
<Description>sa</Description>
<PreviewUrl>/abc</PreviewUrl>
</PageType>
</Page>
</configuration>";
ApplicationData appData = new ApplicationData("SiteEdit");
appData.TypeId = "XmlElement:configuration, http://www.sdltridion.com/2011/SiteEdit";
appData.Data = System.Text.Encoding.Default.GetBytes(xpmXMLStr);
// save the page application data (saving the XPM settings.)
pg.SaveApplicationData(appData);
The same can be done using Core Service API as well.