About the Policies API
The Policies API allows you to programmatically configure policies and apply them to apps without using the Admin Portal user interface. All the basic concepts of working with policies still apply. For more information about policies in general, see About Policies.
Resources
The following resources are available in the Policies API. Click a path to view a complete reference for that resource.
Function | Resource |
---|---|
List All Policies | GET /v2/policies/ |
List Data for a Policy | GET /v2/policies/(policy_id)/ |
List Policies Applied to an App | GET /v2/applications/(app_id)/policies/ |
Apply Policies to an App | POST /v2/applications/(app_id)/policies/ |
Remove Policies from an App | DELETE /v2/applications/(app_id)/policies/ |
Create a Preset Policy Configuration | POST /v2/policies/(policy_id)/configurations/ |
List Data for a Preset Policy Configuration | GET /v2/policies/configurations/(configuration_id)/ |
Update a Preset Policy Configuration | PUT /v2/policies/configurations/(configuration_id)/ |
Delete a Preset Policy Configuration | DELETE /v2/policies/configurations/(configuration_id)/ |
How Policies Work
When you first apply policies to an app, Digital.ai App Management modifies the app to apply a "policy layer" that defines the app's policies. Though we modify the app to apply the policy layer, there is no new version of the app (i.e. no new binary or incremented version number). This occurs whenever you apply policies to an app, whether via the UI or the API.
Also just like when applying policies in the UI, after the new app version with policies is created, you need to re-sign it. Once the app is re-signed, it is then ready to deploy to your users.
Policy Status
You can view the status of policies on the app when managing policies via the API. The possible status codes are:
Code | Status | Description |
---|---|---|
-1 | ERROR | An error has occurred while applying the policy layer. |
0 | NO POLICIES | No policies are applied to the app. |
1 | POLICIES AND SIGNED | Policies are applied to the app and it is signed. The app is ready to be deployed to users. |
2 | APPLYING POLICIES | A policy layer with the defined policies is currently being applied to the app. |
3 | POLICIES NOT SIGNED | Policies have been applied to the app and it needs to be signed before deploying to users. |
4 | POLICIES PREVIOUSLY APPLIED | A previous version of this app had policies applied, but the app has since been updated to a new version which has not yet been configured with policies. |
Check an App's Policy Status
The GET request to /applications/(app_id)/policies/ is asynchronous, which means you can make a request to view the policy status for an app at any time, including immediately after you send the POST request.
Policy Configurations
Some policies include one or more options that should be configured in order for the policy to work as expected. For example, you can define a date range and message for the App Expiration policy. Policies can also be enabled by default so they are automatically selected on an app's Policies tab.
The term we use to describe this set of options is: configuration
In the Admin Portal, you can define these options on a specific app's Policies tab (or on the Policies page). When you use the API to apply policies to an app, you can manually define the configuration options individually, or retrieve a set of preconfigured options.
The term we use to describe these preconfigured options is: preset (or preset configuration)
When you define a policy's options on the Policies page in the Admin Portal, you are creating a preset. For information about working with presets in the Admin Portal, see Define Policy Presets.
The Policies API allows you to create and manage multiple preset configurations for each policy (the Admin Portal only allows you to configure one preset on the Policies page). This lets you refer to the stored configurations and retrieve a specific configuration when you're applying a policy to an app.
You can define the configuration for a policy when applying the policy to a specific app. It is not necessary to create or use preset configurations. They are optional, just as it's optional for administrators to define presets on the Policies page in the Admin Portal.