Skip to content

Latest commit

 

History

History
157 lines (129 loc) · 5.61 KB

user-assignlicense.md

File metadata and controls

157 lines (129 loc) · 5.61 KB
title description author ms.localizationpriority ms.subservice doc_type
user: assignLicense
Add or remove subscriptions for the user. You can also enable and disable specific plans associated with a subscription.
frank-masuelli
high
entra-users
apiPageType

user: assignLicense

Namespace: microsoft.graph

Add or remove subscriptions for the user. You can also enable and disable specific plans associated with a subscription.

[!INCLUDE national-cloud-support]

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.

[!INCLUDE permissions-table]

For delegated scenarios, the calling user needs at least one of the following Microsoft Entra roles.

  • Directory Writers
  • License Administrator
  • User Administrator

HTTP request

POST /users/{id | userPrincipalName}/assignLicense

Request headers

Header Value
Authorization Bearer {token}. Required. Learn more about authentication and authorization.
Content-Type application/json

Request body

In the request body, provide a JSON object with the following parameters.

Parameter Type Description
addLicenses assignedLicense collection A collection of assignedLicense objects that specify the licenses to add. You can disable plans associated with a license by setting the disabledPlans property on an assignedLicense object.
removeLicenses Guid collection A collection of GUIDs that identify the licenses to remove.

Response

If successful, this method returns 200 OK response code and user object in the response body.

Example

Here is an example of how to call this API.

Request

The following example shows a request.

POST https://graph.microsoft.com/v1.0/me/assignLicense
Content-type: application/json

{
  "addLicenses": [
    {
      "disabledPlans": [ "11b0131d-43c8-4bbb-b2c8-e80f9a50834a" ],
      "skuId": "45715bb8-13f9-4bf6-927f-ef96c102d394"
    }
  ],
  "removeLicenses": [ "bea13e0c-3828-4daa-a392-28af7ff61a0f" ]
}

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]


Response

The following example shows the response. Note: The response object shown here might be shortened for readability.

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

{
  "accountEnabled": true,
  "assignedLicenses": [
    {
      "disabledPlans": [ "11b0131d-43c8-4bbb-b2c8-e80f9a50834a" ],
      "skuId": "0118A350-71FC-4EC3-8F0C-6A1CB8867561"
    }
  ],
  "assignedPlans": [
    {
      "assignedDateTime": "2016-10-02T12:13:14Z",
      "capabilityStatus": "capabilityStatus-value",
      "service": "service-value",
      "servicePlanId": "bea13e0c-3828-4daa-a392-28af7ff61a0f"
    }
  ],
  "businessPhones": [
    "businessPhones-value"
  ],
  "city": "city-value",
  "companyName": "companyName-value"
}