Edit

Get resourcePolicyDefinition

Namespace: microsoft.graph

Important

APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.

Read the properties of a resourcePolicyDefinition object.

Customer-authored definition responses include the current ETag in the JSON @odata.etag annotation or the ETag header for plain-text responses. Use this value in the If-Match header of an update request.

Set Accept: text/plain to retrieve the unescaped Rego policy for an individual customer-authored, built-in, or deleted definition.

Permissions

Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.

Permission type Least privileged permissions Higher privileged permissions
Delegated (work or school account) ResourcePolicyDefinition.Read.All ResourcePolicyDefinition.ReadWrite.All
Delegated (personal Microsoft account) Not supported. Not supported.
Application ResourcePolicyDefinition.Read.All ResourcePolicyDefinition.ReadWrite.All

Important

For delegated access using work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role that grants the permissions required for this operation. Resource Policy Reader is the least privileged role supported for this operation.

HTTP request

GET /admin/resourcePolicy/definitions/{resourcePolicyDefinition-uniqueName}
GET /admin/resourcePolicy/builtInDefinitions/{resourcePolicyDefinition-uniqueName}
GET /admin/resourcePolicy/deletedItems/definitions/{resourcePolicyDefinition-uniqueName}

Optional query parameters

For the JSON representation of an active definition, use $expand to include assignments or previousVersions. For general information, see OData query parameters.

Request headers

Name Description
Accept application/json (default) or text/plain. Optional. Use text/plain to retrieve only the Rego policy.
Authorization Bearer {token}. Required. Learn more about authentication and authorization.

Request body

Don't supply a request body.

Response

If successful, this method returns 200 OK. With Accept: application/json, or when Accept is omitted, the response body is a resourcePolicyDefinition object. With Accept: text/plain, the response has Content-Type: text/plain and contains only the unescaped Rego policy instead of the JSON definition object.

Examples

Example 1: Get a definition as JSON

Request

GET https://graph.microsoft.com/beta/admin/resourcePolicy/definitions/require_application_name
Accept: application/json

Response

HTTP/1.1 200 OK
Content-Type: application/json

{
  "@odata.type": "#microsoft.graph.resourcePolicyDefinition",
  "@odata.etag": "\"972dd856-91ff-4539-be09-50ea8235b76c\"",
  "uniqueName": "require_application_name",
  "createdDateTime": "2026-10-22T12:00:00Z",
  "lastModifiedDateTime": "2026-10-22T12:00:00Z",
  "displayName": "Require an application name",
  "description": "Require applications to have a display name",
  "category": "identityAndTenant",
  "version": "1.0.0",
  "deletedDateTime": null,
  "rule": {
    "appliesTo": {
      "operations": "create,updateOrUpsert",
      "resourceName": "microsoft.graph.application",
      "includeDerivedTypes": true
    },
    "policy": "package graph.require_application_name[\"1.0.0\"]\n\n__metadata__ := {\n  \"title\": \"Require an application name\",\n  \"description\": \"Require applications to have a display name\",\n  \"category\": \"identityAndTenant\",\n  \"selector\": {\n    \"resourceName\": \"microsoft.graph.application\",\n    \"operations\": [\n      \"create\",\n      \"updateOrUpsert\"\n    ]\n  }\n}\n\ndefault deny := {\"result\": false, \"reasons\": []}\n\ndeny := {\"result\": true, \"reasons\": [\"A display name is required.\"]} if {\n  object.get(input.resource, \"displayName\", \"\") == \"\"\n}\n"
  },
  "paramsSchema": null
}

Example 2: Get a definition as a plain-text policy

Request

GET https://graph.microsoft.com/beta/admin/resourcePolicy/definitions/require_application_name
Accept: text/plain

Response

HTTP/1.1 200 OK
Content-Type: text/plain
ETag: "972dd856-91ff-4539-be09-50ea8235b76c"

package graph.require_application_name["1.0.0"]

__metadata__ := {
  "title": "Require an application name",
  "description": "Require applications to have a display name",
  "category": "identityAndTenant",
  "selector": {
    "resourceName": "microsoft.graph.application",
    "operations": ["create", "updateOrUpsert"]
  }
}

default deny := {"result": false, "reasons": []}

deny := {"result": true, "reasons": ["A display name is required."]} if {
  object.get(input.resource, "displayName", "") == ""
}

Example 3: Get a built-in definition as a plain-text policy

Request

GET https://graph.microsoft.com/beta/admin/resourcePolicy/builtInDefinitions/microsoft_block_implicit_grant_flow_enablement
Accept: text/plain

Response

The response is shortened to show only the package declaration. The full response contains the built-in policy's Rego text.

HTTP/1.1 200 OK
Content-Type: text/plain

package graph.microsoft_block_implicit_grant_flow_enablement["1.0.0"]

Example 4: Get a deleted definition as a plain-text policy

Request

GET https://graph.microsoft.com/beta/admin/resourcePolicy/deletedItems/definitions/require_application_name
Accept: text/plain

Response

HTTP/1.1 200 OK
Content-Type: text/plain
ETag: "972dd856-91ff-4539-be09-50ea8235b76e"

package graph.require_application_name["1.0.0"]

__metadata__ := {
  "title": "Require an application name",
  "description": "Require applications to have a display name",
  "category": "identityAndTenant",
  "selector": {
    "resourceName": "microsoft.graph.application",
    "operations": ["create", "updateOrUpsert"]
  }
}

default deny := {"result": false, "reasons": []}

deny := {"result": true, "reasons": ["A display name is required."]} if {
  object.get(input.resource, "displayName", "") == ""
}