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
| Method | Route | What it does | Delegated scope | Application roles | Rate limit | Response codes |
|---|---|---|---|---|---|---|
| GET | /admin/collab/v1/manage/onedrive/{user-id}/ | Reads a OneDrive account | Config.ReadWrite.All | Collab.Manage.Read.All, Collab.Manage.ReadWrite.All | Read | 200, 400, 401, 403, 404, 429 |
| PATCH | /admin/collab/v1/manage/onedrive/{user-id}/ | Changes the policy | Config.ReadWrite.All | Collab.Manage.ReadWrite.All | Bulk | 200, 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 Type | Permissions |
|---|---|
| Delegated (work or school account) | https://api.easylife365.cloud/admin/Config.ReadWrite.All |
| Application | Collab.Manage.ReadWrite.All for both routes, Collab.Manage.Read.All for the read |
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
| Header | Value |
|---|---|
| Authorization | Bearer token. (Required) |
| Content-Type | application/json |
Request body
| Property | Type | Description |
|---|---|---|
policyId | String | ID 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:
| Status | Code | When |
|---|---|---|
| 400 | InvalidPayload | The ID is empty, or the body is missing. |
| 400 | Collab.PolicyNotApplicable | The policy is not a OneDrive policy. |
| 400 | Collab.RequestFailed | The change could not be processed. |
| 403 | NotAllowed | The role is missing, or it is the read role on a change. |
| 404 | NotFound | The account does not exist, or the ID is not a member of your tenant. |
| 404 | Collab.PolicyNotFound | The 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.