Apply a Policy to an App No Options
This scenario describes the steps necessary for applying the App Usage policy to an app. App Usage is a basic policy that does not require you to define any options.
Use the links on this page to view a more detailed reference about the resource, including full sample requests and responses.
All the same best practices and caveats still exist when you're applying policies through the API. For more information about how to apply policies in general, see Apply Policies to an App.
Prerequisites
Before you can apply any policies, you need to determine which app you'll be applying policies to. Specifically, you need to know the app_id
attribute for the app.
Send the following request:
This request returns a list of all apps in your organization. Use the list to locate a specific app's app_id
in the response.
Once you know the app_id
, you're ready to apply policies to the app.
Step 1 - Know the policy you want to apply
Request List of Policies
Send the following request:
This request returns a list of all policies in your organization. Use the list to locate a specific policy object in the response.
For example:
{
"display_name": "App Usage",
"created": "2018-02-01T03:52:18.281815+00:00",
"auth_optional": true,
"display_description": "Tracks whenever users opens the app, foregrounds the app, or returns to the app from the lock screen.",
"is_dynamic": true,
"supports_ios": true,
"configurable_fields": null,
"supports_android": true,
"configurations": [],
"id": "XWJKqWeLM5-tp8N09-gTEw",
"policy_id": "com.apperian.app-usage"
}
Find the Policy ID
Locate the policy_id
in the appropriate policy object.
For example:
"policy_id": "com.apperian.app-usage"
Step 2 - Apply the policy to the app
Prepare the configurations object
The apply policies resource requires a data parameter called configurations
, which will contain the policy_id
from the previous step. Before you send the request, you should ensure that the configurations
parameter JSON body is correct.
{
"configurations": [
{
"policy_id": "com.apperian.app-usage"
}
]
}
When applying a basic policy you only need to send the policy_id
.
Apply the policy
Send the the following request using the app_id
and configurations
parameters you retrieved previously:
POST /applications/(app_id)/policies/
Here is an example request that will apply the App Usage policy to an app. Backslashes ( \ ) indicate line breaks in cURL syntax.
curl -X POST https://na01ws.apperian.com/v2/applications/xIwopgg_qwC9WhxsD1oUiQ/policies
--header "X-TOKEN:OxS8iqSHSSmRqcqQ1pXXwg" --header "Content-Type: application/json"
--data '{"configurations":[
{"policy_id":"com.apperian.app-usage"}
]}'
For an example response, click the previous link to view the API reference.
Monitor 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.
Send the following request:
GET /applications/(app_id)/policies/
The response will include a status attribute. For example:
"status": {
"code": 3,
"description": "POLICIES NOT SIGNED"
}
For a list of possible statuses and a description of each, see About the Policies API.
Next steps
Now that the policy is successfully applied to the app, you need to re-sign the app and deploy it to your users. For more information, see Re-sign an App and Signing API.