Create a Policy

This document describes how to programmatically get information about existing policies and to create a new policy.

Before continuing, ensure you are familiar with:

The remainder of this document assumes that you have already authenticated the user and have obtained the authentication token necessary to invoke subsequent endpoints.

Getting Information About Policies

Before creating a new policy you must obtain information about each existing policy. This is necessary because when you save a new policy you will save the entire list ("block") of policies.

Begin by invoking the /Policy/GetUsingCloudMobileGP endpoint:

POST https://tenant.my.centrify.net/Policy/GetUsingCloudMobileGP

The response contains information about the tenant:

{  
   "success":true,
   "Result":{  
      "useCloudGP":true,
      "useCloudCA":false,
      "refreshInterval":15,
      "gpUpdateInterval":300,
      "activeDirectoryCA":"Test1.tenant.my.centrify.net\\GLOBAL-1",
      "cloudOuManagement":true,
      "hasProxy":true,
      "boundMobileForest":"tenant.my.centrify.net",
      "hideMobilePolicyForAD":true
   },
   "Message":null,
   "MessageID":null,
   "Exception":null,
   "ErrorID":null,
   "ErrorCode":null,
   "InnerExceptions":null
}

Invoke the /Policy/GetNicePlinks endpoint:

POST https://tenant.my.centrify.net/policy/getniceplinks

{  
   "Args":{  
      "PageNumber":1,
      "PageSize":100000,
      "Limit":100000,
      "SortBy":"",
      "direction":"False",
      "Caching":-1
   }
}

The Results collection in the response contains information about each existing policy:

{  
   "success":true,
   "Result":{  
      "Columns":[  
         {  
            "Name":"Params",
            "IsHidden":false,
            "DDName":null,
            "Title":"Params",
            "DDTitle":null,
            "Description":null,
            "Type":16,
            "Format":null,
            "Width":0,
            "TableKey":null,
            "ForeignKey":null,
            "TableName":null
         },
         ...
      ],
      "RevStamp":"636589028480000000",
      "Count":31,
      "Results":[  
         {  
            "Entities":[  
               {  
                  "Type":"PolicyLink",
                  "Key":"/Policy/PolicySet_12",
                  "IsForeignKey":false
               }
            ],
            "Row":{  
               "Params":[  

               ],
               "ID":"/Policy/PolicySet_12",
               "EnableCompliant":true,
               "Description":"",
               "LinkType":"Global",
               "PolicySet":"/Policy/PolicySet_12"
            }
         },
         {  
            "Entities":[  
               {  
                  "Type":"PolicyLink",
                  "Key":"/Policy/louie1",
                  "IsForeignKey":false
               }
            ],
            "Row":{  
               "Params":[  
                  "Device|@Active Devices"
               ],
               "ID":"/Policy/louie1",
               "EnableCompliant":true,
               "Description":"",
               "LinkType":"Collection",
               "PolicySet":"/Policy/louie1"
            }
         },
         ...
      ],
      "FullCount":31,
      "ReturnID":"",
      "IsAggregate":false
   },
   "Message":null,
   ...
}

Invoke the /Policy/GetPolicyModifiers endpoint:

POST https://corp.my-dev.centrify.com//Policy/GetAuthPolicyModifiers

The Result element in the response contains the names of the policy modifiers:

{  
   "success":true,
   "Result":[  
      "test1"
   ],
   "Message":null,
   "MessageID":null,
   "Exception":null,
   "ErrorID":null,
   "ErrorCode":null,
   "InnerExceptions":null
}

Creating a new Policy

Gather the information to create a new plink to representing the new policy (see /Policy/GetNicePlinks for information about plnks). Add this new plink to the JSON list of plinks returned from the call to /Policy/GetNicePlinks.

Saving the Policy Block

Invoke the /policy/savepolicyblock3 endpoint to save and pass the plinks in the body to save all of the policy blocks:

POST https://corp.my-dev.centrify.com/policy/savepolicyblock3

{  
   "plinks":[  
      {  
         "Description":"test",
         "PolicySet":"/Policy/PolicySet_1",
         "LinkType":"Global",
         "Priority":1,
         "Params":[  

         ],
         "Filters":[  

         ],
         "Allowedpolicies":[  

         ]
      },
      {  
         "Params":[  

         ],
         "ID":"/Policy/PolicySet_12",
         "EnableCompliant":true,
         "Description":"",
         "LinkType":"Global",
         "PolicySet":"/Policy/PolicySet_12"
      },
      {  
         "Params":[  
            "Device|@Active Devices"
         ],
         "ID":"/Policy/louie1",
         "EnableCompliant":true,
         "Description":"",
         "LinkType":"Collection",
         "PolicySet":"/Policy/louie1"
      },
      ...
   ],
   "policy":{  
      "Path":"/Policy/PolicySet_1",
      "Version":1,
      "Description":"test",
      "Settings":{  

      },
      "Newpolicy":true
   }
}

The success field in the response indicates if the save was successful and the RevStamp indicates the revision number of the policy block save:

{  
   "success":true,
   "Result":{  
      "RevStamp":"636592282940000000"
   },
   "Message":null,
   "MessageID":null,
   "Exception":null,
   "ErrorID":null,
   "ErrorCode":null,
   "InnerExceptions":null
}

Try the API in Postman:
Try the API in Postman.
Click here for help with using our sample Postman collection.