Namespace: microsoft.graph
Classify a delegated permission by adding a delegatedPermissionClassification to the servicePrincipal representing the API.
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
✅ |
✅ |
✅ |
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) |
Policy.ReadWrite.PermissionGrant |
Not available. |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
Policy.ReadWrite.PermissionGrant |
Not available. |
HTTP request
You can address the service principal using either its id or appId. id and appId are referred to as the Object ID and Application (Client) ID, respectively, in app registrations in the Microsoft Entra admin center.
POST /servicePrincipals/{id}/delegatedPermissionClassifications
POST /servicePrincipals(appId='{appId}')/delegatedPermissionClassifications
Request body
In the request body, supply a JSON representation of an delegatedPermissionClassification object.
Response
If successful, this method returns a 201 Created
response code and an delegatedPermissionClassification object in the response body.
Examples
Request
In the following example, the delegated permission "User.Read" is being classified "low".
POST https://graph.microsoft.com/v1.0/servicePrincipals/{id}/delegatedPermissionClassifications
Content-Type: application/json
{
"permissionId": "e1fe6dd8-ba31-4d61-89e7-88639da4683d",
"permissionName": "User.Read",
"classification": "low"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new DelegatedPermissionClassification
{
PermissionId = "e1fe6dd8-ba31-4d61-89e7-88639da4683d",
PermissionName = "User.Read",
Classification = PermissionClassificationType.Low,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.ServicePrincipals["{servicePrincipal-id}"].DelegatedPermissionClassifications.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
mgc service-principals delegated-permission-classifications create --service-principal-id {servicePrincipal-id} --body '{\
"permissionId": "e1fe6dd8-ba31-4d61-89e7-88639da4683d",\
"permissionName": "User.Read",\
"classification": "low"\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewDelegatedPermissionClassification()
permissionId := "e1fe6dd8-ba31-4d61-89e7-88639da4683d"
requestBody.SetPermissionId(&permissionId)
permissionName := "User.Read"
requestBody.SetPermissionName(&permissionName)
classification := graphmodels.LOW_PERMISSIONCLASSIFICATIONTYPE
requestBody.SetClassification(&classification)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
delegatedPermissionClassifications, err := graphClient.ServicePrincipals().ByServicePrincipalId("servicePrincipal-id").DelegatedPermissionClassifications().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
DelegatedPermissionClassification delegatedPermissionClassification = new DelegatedPermissionClassification();
delegatedPermissionClassification.setPermissionId("e1fe6dd8-ba31-4d61-89e7-88639da4683d");
delegatedPermissionClassification.setPermissionName("User.Read");
delegatedPermissionClassification.setClassification(PermissionClassificationType.Low);
DelegatedPermissionClassification result = graphClient.servicePrincipals().byServicePrincipalId("{servicePrincipal-id}").delegatedPermissionClassifications().post(delegatedPermissionClassification);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
const delegatedPermissionClassification = {
permissionId: 'e1fe6dd8-ba31-4d61-89e7-88639da4683d',
permissionName: 'User.Read',
classification: 'low'
};
await client.api('/servicePrincipals/{id}/delegatedPermissionClassifications')
.post(delegatedPermissionClassification);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\DelegatedPermissionClassification;
use Microsoft\Graph\Generated\Models\PermissionClassificationType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new DelegatedPermissionClassification();
$requestBody->setPermissionId('e1fe6dd8-ba31-4d61-89e7-88639da4683d');
$requestBody->setPermissionName('User.Read');
$requestBody->setClassification(new PermissionClassificationType('low'));
$result = $graphServiceClient->servicePrincipals()->byServicePrincipalId('servicePrincipal-id')->delegatedPermissionClassifications()->post($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Applications
$params = @{
permissionId = "e1fe6dd8-ba31-4d61-89e7-88639da4683d"
permissionName = "User.Read"
classification = "low"
}
New-MgServicePrincipalDelegatedPermissionClassification -ServicePrincipalId $servicePrincipalId -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.delegated_permission_classification import DelegatedPermissionClassification
from msgraph.generated.models.permission_classification_type import PermissionClassificationType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = DelegatedPermissionClassification(
permission_id = "e1fe6dd8-ba31-4d61-89e7-88639da4683d",
permission_name = "User.Read",
classification = PermissionClassificationType.Low,
)
result = await graph_client.service_principals.by_service_principal_id('servicePrincipal-id').delegated_permission_classifications.post(request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-type: application/json
{
"id": "2G3-4TG6YU2J54hjnaRoPQE",
"permissionId": "e1fe6dd8-ba31-4d61-89e7-88639da4683d",
"permissionName": "User.Read",
"classification": "low"
}