# Create a new fence (compliance) profile creates the fence policy ## Endpoint `POST /api/v1/mdm/compliance` ## Request ### Request URL `https://[{serverurl}](https://www.manageengine.com/mobile-device-management/help/api/cloud/oauth-authentication-endpoint-domain.html)/api/v1/mdm/compliance` ### Scope `MDMOnDemand.MDMInventory.CREATE` ### Header `Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52` ## Request Parameters ### Request Headers | Parameter | Type | Required | Value | |---|---|---|---| | Content-Type | string | Mandatory | `application/json;charset=UTF-8` | | Accept | string | Mandatory | `application/json` | ### Request Body `application/json` - JSON object - **compliance_name** — string — Mandatory - Name of the compliance (fence) profile - **description** — string — Optional - Short description of the compliance profile - **policies** — JSON array — Mandatory - Collection of policy objects with rules and actions ### Sample Request ```curl curl --request POST \ --url https://appdomain/api/v1/mdm/compliance \ --header 'Accept: application/json' \ --header 'Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52' \ --header 'Content-Type: application/json;charset=UTF-8' \ --data '{"policies":[{}],"compliance_name":"GeoFencePolicy1"}' ``` ### Sample Request Body Create a fence policy with geofence rule and lock/email alert actions ```json { "policies": [ { "rule": { "rule_name": "Tower", "evaluation_order": 1, "rule_criterions": [ { "geo_fence_id": 1, "rule_criteria_state": 2, "rule_criteria_type": 2 } ] }, "action": { "action_attributes": [ { "lock_message": "Device is lost", "body_message": "The device is outside its permitted fence.", "subject": "Warning", "is_remote_alarm": false, "is_mark_as_non_compliant": true, "alert_email_ids": [ { "user_name": "admin", "email": "admin@zylker.com" } ], "action_attribute_type": 1, "time_to_execution": 0, "execution_order": 1 } ] } } ], "description": "Compliance Profile", "compliance_name": "GeoFencePolicy1" } ``` ## Response Parameters ### HTTP Code 200 Response Body: `application/json` - JSON object - **compliance_id** — string - Profile ID of the created compliance profile - **compliance_name** — string - Name of the created compliance profile - **collection_id** — string - Collection ID assigned to the compliance - **is_moved_to_trash** — boolean - Whether the compliance profile is deleted or not (false for newly created) - **description** — string - Short description of the compliance profile - **policies** — JSON array - Collection of rule and action details for the created policy ### Possible Response Codes | Code | Type | |---|---| | 200 | HTTP code | ### Sample Response: HTTP 200 Fence policy successfully created with assigned IDs ```json { "collection_id": "9007199254741048", "is_moved_to_trash": false, "policies": [ { "rule": { "rule_id": 9007199254741084, "rule_name": "Tower", "evaluation_order": 1, "rule_criterions": [ { "geo_fence_id": 1, "rule_criteria_state": 2, "rule_criteria_type": 2 } ] }, "action": { "action_id": 9007199254741084, "action_attributes": [ { "lock_message": "Device is lost", "body_message": "The device is outside its permitted fence.", "subject": "Warning", "is_remote_alarm": false, "is_mark_as_non_compliant": true, "alert_email_ids": [ { "user_name": "admin", "email": "admin@zylker.com" } ], "action_attribute_type": 1, "time_to_execution": 0, "execution_order": 1 } ] } } ], "description": "Compliance Profile", "compliance_id": "9007199254741047", "compliance_name": "GeoFencePolicy1" } ``` ## API Rate Limit ![](https://www.zohowebstatic.com/sites/zweb/images/people/ico-help.png) **Duration:** 1 minute | **Threshold:** 30 | **Lock period:** 5 minutes Duration - Time window for the threshold. Threshold - Number of API calls allowed within the specified duration. Lock Period - Wait time before consecutive API requests.