Skip to main content
Version: 2.52.20

Manage OneDrive account policies

The EasyLife 365 Collaboration API reads OneDrive accounts of the members of your tenant and changes their policies. You can call it as a signed-in administrator or as an application. For the application setup, see Call the API as an application.

Routes​

MethodRouteWhat it doesDelegated scopeApplication rolesRate limitResponse codes
GET/admin/collab/v1/manage/onedrive/{user-id}/Reads a OneDrive accountConfig.ReadWrite.AllCollab.Manage.Read.All, Collab.Manage.ReadWrite.AllRead200, 400, 401, 403, 404, 429
PATCH/admin/collab/v1/manage/onedrive/{user-id}/Changes the policyConfig.ReadWrite.AllCollab.Manage.ReadWrite.AllBulk200, 400, 401, 403, 404, 429

{user-id} is the object ID of the owner of the OneDrive account in Microsoft Entra ID. A guest account answers 404, because guests have no OneDrive account this route manages.

Permissions​

Permission TypePermissions
Delegated (work or school account)https://api.easylife365.cloud/admin/Config.ReadWrite.All
ApplicationCollab.Manage.ReadWrite.All for both routes, Collab.Manage.Read.All for the read
note

Collab.Manage.Read.All can read a OneDrive account. It cannot change one: a PATCH answers 403. Application permissions always require admin consent. A role of another product does not work here. See Call the API as an application.

Read a OneDrive account​

GET https://api.easylife365.cloud/admin/collab/v1/manage/onedrive/{user-id}/
Authorization: Bearer {access-token}

Response​

{
"id": "1a95c23b-cbb3-4f06-9b05-5e96ac65c78c",
"displayName": "Jordan Keller",
"isCompliant": true,
"policy": {
"pId": "ad869549-d693-4d20-8879-402d5ed3d991"
},
"schema": {
"resourceType": "OneDrive",
"policyId": "ad869549-d693-4d20-8879-402d5ed3d991",
"isCompliant": true
}
}

A OneDrive account has no template, so there is no templateId. policy and schema are the data EasyLife 365 stores on the account, returned as stored. Their inner names carry no promise to stay the same, so read only the names you need. The display name is the name of a person, so treat the answer as personal data. The owner IDs are not part of the answer. See What a read returns.

Change a OneDrive account​

PATCH https://api.easylife365.cloud/admin/collab/v1/manage/onedrive/{user-id}/
Content-Type: application/json

HTTP request headers​

HeaderValue
AuthorizationBearer token. (Required)
Content-Typeapplication/json

Request body​

PropertyTypeDescription
policyIdStringID of the OneDrive policy. (Optional)
  • A value you leave out is not changed.
  • To remove the policy, send "00000000-0000-0000-0000-000000000000".

Response​

A successful call answers 200 with the account after the change. The answer keeps every member it had before and adds isCompliant and schema. The change is recorded in the audit log, with the calling application as the actor when an application made it.

Errors​

Errors are application/problem+json with code, title, detail and requestId. The list of codes is on Call the API as an application. These are the ones you can expect here:

StatusCodeWhen
400InvalidPayloadThe ID is empty, or the body is missing.
400Collab.PolicyNotApplicableThe policy is not a OneDrive policy.
400Collab.RequestFailedThe change could not be processed.
403NotAllowedThe role is missing, or it is the read role on a change.
404NotFoundThe account does not exist, or the ID is not a member of your tenant.
404Collab.PolicyNotFoundThe policy does not exist.
{
"type": "https://docs.easylife365.cloud/errors/collab/policy-not-applicable",
"title": "The policy does not apply to this type of item.",
"status": 400,
"detail": "Policy with Id 5d0c61f2-8a3e-4b7c-9f1d-2c4e7a90b316 is not a OneDrive policy",
"code": "Collab.PolicyNotApplicable",
"requestId": "0HNG2K4V7QJ3D:0000000F"
}

Example 1: Assign a policy to a OneDrive account​

PATCH https://api.easylife365.cloud/admin/collab/v1/manage/onedrive/1a95c23b-cbb3-4f06-9b05-5e96ac65c78c/
Content-Type: application/json
{
"policyId": "ad869549-d693-4d20-8879-402d5ed3d991"
}

Example 2: Remove the policy of a OneDrive account​

{
"policyId": "00000000-0000-0000-0000-000000000000"
}

Example 3: Read a OneDrive account as an application (curl)​

curl "https://api.easylife365.cloud/admin/collab/v1/manage/onedrive/1a95c23b-cbb3-4f06-9b05-5e96ac65c78c/" \
-H "Authorization: Bearer $ACCESS_TOKEN"

Example 4: Assign a policy as an application (PowerShell)​

Get the token as shown in Call the API as an application and keep it in $accessToken.

$uri = "https://api.easylife365.cloud/admin/collab/v1/manage/onedrive/1a95c23b-cbb3-4f06-9b05-5e96ac65c78c/"

$body = @{ policyId = "ad869549-d693-4d20-8879-402d5ed3d991" } | ConvertTo-Json

$headers = @{ Authorization = "Bearer $accessToken" }

Invoke-RestMethod -Method Patch -Uri $uri -Headers $headers -ContentType "application/json" -Body $body

On the Insiders ring, use the host api.insiders.easylife365.cloud.