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.
Retrieve a list of usageRight objects for a given user.
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) |
User.Read |
Directory.Read.All, Directory.ReadWrite.All, User.Read.All, User.ReadWrite, User.ReadWrite.All |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
User.Read.All |
Directory.Read.All, Directory.ReadWrite.All, User.ReadWrite.All |
HTTP request
GET /users/{userId}/usageRights
Optional query parameters
This API supports the $filter OData query parameter. The following patterns of $filter are supported:
- $filter = state eq 'value'
- $filter = serviceIdentifier eq 'value'
- $filter = state eq 'value' and serviceIdentifier eq 'value'
- $filter = state in ('value1', 'value2')
- $filter = serviceIdentifier in ('value1', 'value2')
- $filter = state in ('value1', 'value2') and serviceIdentifier in ('value1', 'value2')
Name |
Description |
Authorization |
Bearer {token}. Required. Learn more about authentication and authorization. |
odata.maxpagesize |
Set the max result page size pereference. Optional. |
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 usageRight objects in the response body.
Additionally, if there are more pages in the response an @odata.nextLink is returned.
Examples
Example 1: Get all usage rights for a user
Request
GET https://graph.microsoft.com/beta/users/{userId}/usageRights
// 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.Users["{user-id}"].UsageRights.GetAsync();
mgc-beta users usage-rights list --user-id {user-id}
// 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"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
usageRights, err := graphClient.Users().ByUserId("user-id").UsageRights().Get(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
UsageRightCollectionResponse result = graphClient.users().byUserId("{user-id}").usageRights().get();
const options = {
authProvider,
};
const client = Client.init(options);
let usageRights = await client.api('/users/{userId}/usageRights')
.version('beta')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->users()->byUserId('user-id')->usageRights()->get()->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.users.by_user_id('user-id').usage_rights.get()
Response
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#users('64952b80-51fd-4378-9ba5-589a840afb80')/usageRights",
"@odata.nextLink": "https://graph.microsoft.com/beta/users/64952b80-51fd-4378-9ba5-589a840afb80/usageRights?$skiptoken=W4diD29cGKX1bX",
"value": [
{
"id": "c2e034cb-3cbc-41be-a496-bfcd031e4cfc",
"catalogId": "CFQ7TTC0KCRG:0001",
"serviceIdentifier": "mscrm.f6d23ec7-255c-4bd8-8c99-dc041d5cb8b3.517f7ddd-df45-4f1c-83ec-a081a047f546",
"state": "active"
}
]
}
Example 2: Get usage rights for a user with specific service identifiers and states
Request
GET https://graph.microsoft.com/beta/users/{userId}/usageRights?$filter=state in ('active', 'suspended') and serviceIdentifier in ('ABCD')
// 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.Users["{user-id}"].UsageRights.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "state in ('active', 'suspended') and serviceIdentifier in ('ABCD')";
});
mgc-beta users usage-rights list --user-id {user-id} --filter "state in ('active', 'suspended') and serviceIdentifier in ('ABCD')"
// 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"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
//other-imports
)
requestFilter := "state in ('active', 'suspended') and serviceIdentifier in ('ABCD')"
requestParameters := &graphusers.ItemUsageRightsRequestBuilderGetQueryParameters{
Filter: &requestFilter,
}
configuration := &graphusers.ItemUsageRightsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
usageRights, err := graphClient.Users().ByUserId("user-id").UsageRights().Get(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
UsageRightCollectionResponse result = graphClient.users().byUserId("{user-id}").usageRights().get(requestConfiguration -> {
requestConfiguration.queryParameters.filter = "state in ('active', 'suspended') and serviceIdentifier in ('ABCD')";
});
const options = {
authProvider,
};
const client = Client.init(options);
let usageRights = await client.api('/users/{userId}/usageRights')
.version('beta')
.filter('state in (\'active\', \'suspended\') and serviceIdentifier in (\'ABCD\')')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\UsageRights\UsageRightsRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new UsageRightsRequestBuilderGetRequestConfiguration();
$queryParameters = UsageRightsRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->filter = "state in ('active', 'suspended') and serviceIdentifier in ('ABCD')";
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->users()->byUserId('user-id')->usageRights()->get($requestConfiguration)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.users.item.usage_rights.usage_rights_request_builder import UsageRightsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = UsageRightsRequestBuilder.UsageRightsRequestBuilderGetQueryParameters(
filter = "state in ('active', 'suspended') and serviceIdentifier in ('ABCD')",
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.users.by_user_id('user-id').usage_rights.get(request_configuration = request_configuration)
Response
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#users('64952b80-51fd-4378-9ba5-589a840afb80')/usageRights",
"value": [
{
"id": "505261eb-b4ee-421c-8206-05529ae2c150",
"catalogId": "CFQ7TTC0KCRG:0001",
"serviceIdentifier": "ABCD",
"state": "active"
}
]
}