I was researching for add/edit/delete Site Policy in SharePoint Online with PowerShell/REST but with no luck.
Is it possible with SharePoint Online with PowerShell/CSOM?
CSOM for SharePoint online contains the Microsoft.SharePoint.Client.InformationPolicy namespace which contains the API for handling the site policies.
You can use it by adding the reference to the Microsoft.Office.Client.Policy.dll
and adding
using Microsoft.SharePoint.Client.InformationPolicy;
to your class.
ProjectPolicy.GetProjectPolicies method can be used to retreive all the defined policies.
Here's simple c# code for listing all the policies defined on the site collection (I'm assuming here that you have already connected to the site using the csom):
var policies = ProjectPolicy.GetProjectPolicies(context, web);
context.Load(policies);
context.ExecuteQuery();
//For example the policies.Count property would give you the count of the defined policies.
//This should list all the policies names:
foreach(var p in policies)
{
Console.WriteLine(p.Name);
}
ProjectPolicy.ApplyProjectPolicy method can be used for applying the policy to the appropriate site.
EDIT (based on the OP's comment): Unfortunately, it is currently not possible to create site policies using the API. Here's the PnP Github page which states this.