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)
CustomSecAttributeDefinition.Read.All
CustomSecAttributeDefinition.ReadWrite.All
Delegated (personal Microsoft account)
Not supported.
Not supported.
Application
CustomSecAttributeDefinition.Read.All
CustomSecAttributeDefinition.ReadWrite.All
The signed-in user must also be assigned one of the following directory roles:
Attribute Definition Reader
Attribute Assignment Administrator
Attribute Definition Administrator
By default, Global Administrator and other administrator roles do not have permissions to read, define, or assign custom security attributes.
HTTP request
GET /directory/customSecurityAttributeDefinitions
Optional query parameters
This method supports the $select, $top, $expand, and $filter (eq) OData query parameters to help customize the response. For general information, see OData query parameters.
The allowedValues navigation property is not returned or expanded by default and must be specified in an $expand query. For example, /directory/customSecurityAttributeDefinitions?$expand=allowedValues.
Request headers
Name
Description
Authorization
Bearer {token}. Required.
Request body
Don't supply a request body for this method.
Response
If successful, this method returns a 200 OK response code and a collection of customSecurityAttributeDefinition objects in the response body.
Examples
Example 1: Get all custom security attributes
The following example gets all custom security attribute definitions in a tenant.
GET https://graph.microsoft.com/v1.0/directory/customSecurityAttributeDefinitions
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Directory.CustomSecurityAttributeDefinitions.GetAsync();
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->directory()->customSecurityAttributeDefinitions()->get()->wait();
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(credentials, scopes)
result = await graph_client.directory.custom_security_attribute_definitions.get()
GET https://graph.microsoft.com/v1.0/directory/customSecurityAttributeDefinitions?$filter=name+eq+'Project'%20and%20status+eq+'Available'
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Directory.CustomSecurityAttributeDefinitions.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "name eq 'Project' and status eq 'Available'";
});
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc directory custom-security-attribute-definitions list --filter "name eq 'Project' and status eq 'Available'"
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new CustomSecurityAttributeDefinitionsRequestBuilderGetRequestConfiguration();
$queryParameters = CustomSecurityAttributeDefinitionsRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->filter = "name eq 'Project' and status eq 'Available'";
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->directory()->customSecurityAttributeDefinitions()->get($requestConfiguration)->wait();
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(credentials, scopes)
query_params = CustomSecurityAttributeDefinitionsRequestBuilder.CustomSecurityAttributeDefinitionsRequestBuilderGetQueryParameters(
filter = "name eq 'Project' and status eq 'Available'",
)
request_configuration = CustomSecurityAttributeDefinitionsRequestBuilder.CustomSecurityAttributeDefinitionsRequestBuilderGetRequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.directory.custom_security_attribute_definitions.get(request_configuration = request_configuration)
GET https://graph.microsoft.com/v1.0/directory/customSecurityAttributeDefinitions?$filter=attributeSet+eq+'Engineering'%20and%20status+eq+'Available'%20and%20type+eq+'String'
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Directory.CustomSecurityAttributeDefinitions.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "attributeSet eq 'Engineering' and status eq 'Available' and type eq 'String'";
});
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc directory custom-security-attribute-definitions list --filter "attributeSet eq 'Engineering' and status eq 'Available' and type eq 'String'"
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new CustomSecurityAttributeDefinitionsRequestBuilderGetRequestConfiguration();
$queryParameters = CustomSecurityAttributeDefinitionsRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->filter = "attributeSet eq 'Engineering' and status eq 'Available' and type eq 'String'";
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->directory()->customSecurityAttributeDefinitions()->get($requestConfiguration)->wait();
Import-Module Microsoft.Graph.Identity.DirectoryManagement
Get-MgDirectoryCustomSecurityAttributeDefinition -Filter "attributeSet eq 'Engineering' and status eq 'Available' and type eq 'String'"
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(credentials, scopes)
query_params = CustomSecurityAttributeDefinitionsRequestBuilder.CustomSecurityAttributeDefinitionsRequestBuilderGetQueryParameters(
filter = "attributeSet eq 'Engineering' and status eq 'Available' and type eq 'String'",
)
request_configuration = CustomSecurityAttributeDefinitionsRequestBuilder.CustomSecurityAttributeDefinitionsRequestBuilderGetRequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.directory.custom_security_attribute_definitions.get(request_configuration = request_configuration)