> For the complete documentation index, see [llms.txt](https://docs.defguard.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.defguard.net/2.1/for-developers/rest-api/core/device-posture/create-a-device-posture-check-policy.md).

# Create a device posture check policy

```json
{"openapi":"3.1.0","info":{"title":"defguard Core API","version":"2.1.0"},"tags":[{"name":"device posture","description":"Device posture check policies."}],"security":[{"cookie":[]},{"api_token":[]}],"components":{"securitySchemes":{"cookie":{"type":"apiKey","in":"cookie","name":"defguard_session"},"api_token":{"type":"http","scheme":"bearer"}},"schemas":{"EditDevicePosture":{"type":"object","description":"Request body for creating or updating a device posture check policy.","required":["name","allow_prerelease_client"],"properties":{"allow_prerelease_client":{"type":"boolean"},"description":{"type":["string","null"]},"min_desktop_client_version":{"type":["string","null"]},"min_mobile_client_version":{"type":["string","null"]},"name":{"type":"string"},"os_rules":{"type":"array","items":{"$ref":"#/components/schemas/ApiOsRule"}}}},"ApiOsRule":{"oneOf":[{"type":"object","required":["os_type"],"properties":{"ad_domain_joined_required":{"type":["boolean","null"]},"antivirus_required":{"type":["boolean","null"]},"disk_encryption_required":{"type":["boolean","null"]},"min_os_version":{"type":["integer","null"],"format":"int32"},"os_type":{"type":"string","enum":["windows"]},"windows_security_update_max_age":{"type":["integer","null"],"format":"int32"}}},{"type":"object","required":["os_type"],"properties":{"device_integrity_required":{"type":["boolean","null"]},"disk_encryption_required":{"type":["boolean","null"]},"min_os_version":{"type":["integer","null"],"format":"int32"},"os_type":{"type":"string","enum":["macos"]}}},{"type":"object","required":["os_type"],"properties":{"disk_encryption_required":{"type":["boolean","null"]},"min_kernel_version":{"type":["integer","null"],"format":"int32"},"os_type":{"type":"string","enum":["linux"]}}},{"type":"object","required":["os_type"],"properties":{"min_os_version":{"type":["integer","null"],"format":"int32"},"os_type":{"type":"string","enum":["ios"]}}},{"type":"object","required":["os_type"],"properties":{"android_security_patch_level_max_age":{"type":["integer","null"],"format":"int32"},"device_integrity_required":{"type":["boolean","null"]},"min_os_version":{"type":["integer","null"],"format":"int32"},"os_type":{"type":"string","enum":["android"]}}}],"description":"Per-OS rule included in a posture check policy API.\n\nAdding this layer on top of the shared DB type allows us\nto require different fields for specific platforms."},"ApiDevicePosture":{"type":"object","description":"API response type for a device posture check policy.","required":["id","name","allow_prerelease_client","os_rules","locations"],"properties":{"allow_prerelease_client":{"type":"boolean"},"description":{"type":["string","null"]},"id":{"$ref":"#/components/schemas/i64"},"locations":{"type":"array","items":{"$ref":"#/components/schemas/i64"},"description":"IDs of VPN locations this policy is assigned to."},"min_desktop_client_version":{"type":["string","null"]},"min_mobile_client_version":{"type":["string","null"]},"name":{"type":"string"},"os_rules":{"type":"array","items":{"$ref":"#/components/schemas/ApiOsRule"}}}},"i64":{"type":"integer","format":"int64"},"ApiErrorResponse":{"type":"object","description":"Body returned with error responses.","required":["msg"],"properties":{"code":{"type":["string","null"],"description":"Machine-readable error code, returned for selected errors."},"msg":{"type":"string","description":"Human-readable error message."}}}}},"paths":{"/api/v1/device-posture":{"post":{"tags":["device posture"],"summary":"Create a device posture check policy","operationId":"create_device_posture","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EditDevicePosture"}}},"required":true},"responses":{"201":{"description":"Device posture check policy created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiDevicePosture"}}}},"400":{"description":"Invalid request data.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiErrorResponse"}}}},"401":{"description":"Session is missing or invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiErrorResponse"}}}},"403":{"description":"Requires admin privileges and an active enterprise license.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiErrorResponse"}}}},"500":{"description":"Unable to create device posture check policy.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiErrorResponse"}}}}}}}}}
```
