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.
Add or remove licenses on the group. Licenses assigned to the group will be assigned to all users in the group. To learn more about group-based licensing, see What is group-based licensing in Microsoft Entra ID.
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)
LicenseAssignment.ReadWrite.All
Directory.ReadWrite.All, Group.ReadWrite.All
Delegated (personal Microsoft account)
Not supported.
Not supported.
Application
LicenseAssignment.ReadWrite.All
Directory.ReadWrite.All, Group.ReadWrite.All
For delegated scenarios, the calling user needs at least one of the following Microsoft Entra roles.
A collection of assignedLicense objects that specify the licenses to add. You can disable servicePlans associated with a license by setting the disabledPlans property on an assignedLicense object.
removeLicenses
Guid collection
A collection of skuIds that identify the licenses to remove. Required.
Response
If successful, this method returns a 202 Accepted response code and a target group object in the response body.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Groups.Item.AssignLicense;
using Microsoft.Graph.Beta.Models;
var requestBody = new AssignLicensePostRequestBody
{
AddLicenses = new List<AssignedLicense>
{
new AssignedLicense
{
DisabledPlans = new List<Guid?>
{
Guid.Parse("113feb6c-3fe4-4440-bddc-54d774bf0318"),
Guid.Parse("14ab5db5-e6c4-4b20-b4bc-13e36fd2227f"),
},
SkuId = Guid.Parse("b05e124f-c7cc-45a0-a6aa-8cf78c946968"),
},
new AssignedLicense
{
DisabledPlans = new List<Guid?>
{
Guid.Parse("a413a9ff-720c-4822-98ef-2f37c2a21f4c"),
},
SkuId = Guid.Parse("c7df2760-2c81-4ef7-b578-5b5392b571df"),
},
},
RemoveLicenses = new List<string>
{
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups["{group-id}"].AssignLicense.PostAsync(requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphgroups "github.com/microsoftgraph/msgraph-beta-sdk-go/groups"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphgroups.NewAssignLicensePostRequestBody()
assignedLicense := graphmodels.NewAssignedLicense()
disabledPlans := []uuid.UUID {
uuid.MustParse("113feb6c-3fe4-4440-bddc-54d774bf0318"),
uuid.MustParse("14ab5db5-e6c4-4b20-b4bc-13e36fd2227f"),
}
assignedLicense.SetDisabledPlans(disabledPlans)
skuId := uuid.MustParse("b05e124f-c7cc-45a0-a6aa-8cf78c946968")
assignedLicense.SetSkuId(&skuId)
assignedLicense1 := graphmodels.NewAssignedLicense()
disabledPlans := []uuid.UUID {
uuid.MustParse("a413a9ff-720c-4822-98ef-2f37c2a21f4c"),
}
assignedLicense1.SetDisabledPlans(disabledPlans)
skuId := uuid.MustParse("c7df2760-2c81-4ef7-b578-5b5392b571df")
assignedLicense1.SetSkuId(&skuId)
addLicenses := []graphmodels.AssignedLicenseable {
assignedLicense,
assignedLicense1,
}
requestBody.SetAddLicenses(addLicenses)
removeLicenses := []string {
}
requestBody.SetRemoveLicenses(removeLicenses)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
assignLicense, err := graphClient.Groups().ByGroupId("group-id").AssignLicense().Post(context.Background(), requestBody, nil)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.groups.item.assignlicense.AssignLicensePostRequestBody assignLicensePostRequestBody = new com.microsoft.graph.beta.groups.item.assignlicense.AssignLicensePostRequestBody();
LinkedList<AssignedLicense> addLicenses = new LinkedList<AssignedLicense>();
AssignedLicense assignedLicense = new AssignedLicense();
LinkedList<UUID> disabledPlans = new LinkedList<UUID>();
disabledPlans.add(UUID.fromString("113feb6c-3fe4-4440-bddc-54d774bf0318"));
disabledPlans.add(UUID.fromString("14ab5db5-e6c4-4b20-b4bc-13e36fd2227f"));
assignedLicense.setDisabledPlans(disabledPlans);
assignedLicense.setSkuId(UUID.fromString("b05e124f-c7cc-45a0-a6aa-8cf78c946968"));
addLicenses.add(assignedLicense);
AssignedLicense assignedLicense1 = new AssignedLicense();
LinkedList<UUID> disabledPlans1 = new LinkedList<UUID>();
disabledPlans1.add(UUID.fromString("a413a9ff-720c-4822-98ef-2f37c2a21f4c"));
assignedLicense1.setDisabledPlans(disabledPlans1);
assignedLicense1.setSkuId(UUID.fromString("c7df2760-2c81-4ef7-b578-5b5392b571df"));
addLicenses.add(assignedLicense1);
assignLicensePostRequestBody.setAddLicenses(addLicenses);
LinkedList<String> removeLicenses = new LinkedList<String>();
assignLicensePostRequestBody.setRemoveLicenses(removeLicenses);
var result = graphClient.groups().byGroupId("{group-id}").assignLicense().post(assignLicensePostRequestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Groups\Item\AssignLicense\AssignLicensePostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\AssignedLicense;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AssignLicensePostRequestBody();
$addLicensesAssignedLicense1 = new AssignedLicense();
$addLicensesAssignedLicense1->setDisabledPlans(['113feb6c-3fe4-4440-bddc-54d774bf0318', '14ab5db5-e6c4-4b20-b4bc-13e36fd2227f', ]);
$addLicensesAssignedLicense1->setSkuId('b05e124f-c7cc-45a0-a6aa-8cf78c946968');
$addLicensesArray []= $addLicensesAssignedLicense1;
$addLicensesAssignedLicense2 = new AssignedLicense();
$addLicensesAssignedLicense2->setDisabledPlans(['a413a9ff-720c-4822-98ef-2f37c2a21f4c', ]);
$addLicensesAssignedLicense2->setSkuId('c7df2760-2c81-4ef7-b578-5b5392b571df');
$addLicensesArray []= $addLicensesAssignedLicense2;
$requestBody->setAddLicenses($addLicensesArray);
$requestBody->setRemoveLicenses([]);
$result = $graphServiceClient->groups()->byGroupId('group-id')->assignLicense()->post($requestBody)->wait();
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Groups.Item.AssignLicense;
using Microsoft.Graph.Beta.Models;
var requestBody = new AssignLicensePostRequestBody
{
AddLicenses = new List<AssignedLicense>
{
},
RemoveLicenses = new List<Guid?>
{
Guid.Parse("c7df2760-2c81-4ef7-b578-5b5392b571df"),
Guid.Parse("b05e124f-c7cc-45a0-a6aa-8cf78c946968"),
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups["{group-id}"].AssignLicense.PostAsync(requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
mgc-beta groups assign-license post --group-id {group-id} --body '{\
"addLicenses": [],\
"removeLicenses": [\
"c7df2760-2c81-4ef7-b578-5b5392b571df",\
"b05e124f-c7cc-45a0-a6aa-8cf78c946968"\
]\
}\
'
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphgroups "github.com/microsoftgraph/msgraph-beta-sdk-go/groups"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphgroups.NewAssignLicensePostRequestBody()
addLicenses := []graphmodels.AssignedLicenseable {
}
requestBody.SetAddLicenses(addLicenses)
removeLicenses := []uuid.UUID {
uuid.MustParse("c7df2760-2c81-4ef7-b578-5b5392b571df"),
uuid.MustParse("b05e124f-c7cc-45a0-a6aa-8cf78c946968"),
}
requestBody.SetRemoveLicenses(removeLicenses)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
assignLicense, err := graphClient.Groups().ByGroupId("group-id").AssignLicense().Post(context.Background(), requestBody, nil)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.groups.item.assignlicense.AssignLicensePostRequestBody assignLicensePostRequestBody = new com.microsoft.graph.beta.groups.item.assignlicense.AssignLicensePostRequestBody();
LinkedList<AssignedLicense> addLicenses = new LinkedList<AssignedLicense>();
assignLicensePostRequestBody.setAddLicenses(addLicenses);
LinkedList<UUID> removeLicenses = new LinkedList<UUID>();
removeLicenses.add(UUID.fromString("c7df2760-2c81-4ef7-b578-5b5392b571df"));
removeLicenses.add(UUID.fromString("b05e124f-c7cc-45a0-a6aa-8cf78c946968"));
assignLicensePostRequestBody.setRemoveLicenses(removeLicenses);
var result = graphClient.groups().byGroupId("{group-id}").assignLicense().post(assignLicensePostRequestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Groups\Item\AssignLicense\AssignLicensePostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\AssignedLicense;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AssignLicensePostRequestBody();
$requestBody->setAddLicenses([ ]);
$requestBody->setRemoveLicenses(['c7df2760-2c81-4ef7-b578-5b5392b571df', 'b05e124f-c7cc-45a0-a6aa-8cf78c946968', ]);
$result = $graphServiceClient->groups()->byGroupId('group-id')->assignLicense()->post($requestBody)->wait();
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.groups.item.assign_license.assign_license_post_request_body import AssignLicensePostRequestBody
from msgraph_beta.generated.models.assigned_license import AssignedLicense
graph_client = GraphServiceClient(credentials, scopes)
request_body = AssignLicensePostRequestBody(
add_licenses = [
],
remove_licenses = [
UUID("c7df2760-2c81-4ef7-b578-5b5392b571df"),
UUID("b05e124f-c7cc-45a0-a6aa-8cf78c946968"),
],
)
result = await graph_client.groups.by_group_id('group-id').assign_license.post(request_body)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.