Namespace: microsoft.graph
Submit a data policy operation request from a company administrator or an application to export an organizational user's data. This data includes the user's data stored in OneDrive and their activity reports. For more information about exporting data while complying with regulations, see Data Subject Requests and the GDPR and CCPA.
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.Export.All |
Not available. |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
User.Export.All |
Not available. |
Note: The export can only be performed by a company administrator when delegated permissions are used.
HTTP request
POST /users/{id}/exportPersonalData
Request body
In the request body, provide a JSON object with the following parameters.
Parameter |
Type |
Description |
storageLocation |
String |
A shared access signature (SAS) URL to an Azure Storage account, to where data should be exported. |
Response
If successful, this method returns a 202 Accepted
response code. It doesn't return anything in the response body. The response contains the following response headers.
Name |
Description |
Location |
URL to check on the status of the request. |
Retry-After |
Time period in seconds. Request maker should wait this long after submitting a request to check for the status. |
Example
Request
POST https://graph.microsoft.com/v1.0/users/{id}/exportPersonalData
Content-type: application/json
{
"storageLocation": "storageLocation-value"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Users.Item.ExportPersonalData;
var requestBody = new ExportPersonalDataPostRequestBody
{
StorageLocation = "storageLocation-value",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Users["{user-id}"].ExportPersonalData.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphusers "github.com/microsoftgraph/msgraph-sdk-go/users"
//other-imports
)
requestBody := graphusers.NewExportPersonalDataPostRequestBody()
storageLocation := "storageLocation-value"
requestBody.SetStorageLocation(&storageLocation)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Users().ByUserId("user-id").ExportPersonalData().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.users.item.exportpersonaldata.ExportPersonalDataPostRequestBody exportPersonalDataPostRequestBody = new com.microsoft.graph.users.item.exportpersonaldata.ExportPersonalDataPostRequestBody();
exportPersonalDataPostRequestBody.setStorageLocation("storageLocation-value");
graphClient.users().byUserId("{user-id}").exportPersonalData().post(exportPersonalDataPostRequestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
const exportPersonalData = {
storageLocation: 'storageLocation-value'
};
await client.api('/users/{id}/exportPersonalData')
.post(exportPersonalData);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Users\Item\ExportPersonalData\ExportPersonalDataPostRequestBody;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ExportPersonalDataPostRequestBody();
$requestBody->setStorageLocation('storageLocation-value');
$graphServiceClient->users()->byUserId('user-id')->exportPersonalData()->post($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Users.Actions
$params = @{
storageLocation = "storageLocation-value"
}
Export-MgUserPersonalData -UserId $userId -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.users.item.export_personal_data.export_personal_data_post_request_body import ExportPersonalDataPostRequestBody
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = ExportPersonalDataPostRequestBody(
storage_location = "storageLocation-value",
)
await graph_client.users.by_user_id('user-id').export_personal_data.post(request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
{
Location: https://graph.microsoft.com/v1.0/dataPolicyOperations/d007e3da-cd9b-4b02-8d66-422403c53e3f
Retry-After: 60
}
HTTP/1.1 202 Accepted