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.
Asynchronously creates a copy of an driveItem (including any children), under a new parent item or with a new name.
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)
Files.ReadWrite
Files.ReadWrite.All, Sites.ReadWrite.All
Delegated (personal Microsoft account)
Files.ReadWrite
Files.ReadWrite.All
Application
Files.ReadWrite.All
Sites.ReadWrite.All
HTTP request
POST /drives/{driveId}/items/{itemId}/copy
POST /groups/{groupId}/drive/items/{itemId}/copy
POST /me/drive/items/{item-id}/copy
POST /sites/{siteId}/drive/items/{itemId}/copy
POST /users/{userId}/drive/items/{itemId}/copy
Optional query parameters
This method supports the @microsoft.graph.conflictBehavior query parameter to customize the behavior when a conflict occurs.
Value
Description
fail
Default behavior is to report the failure.
replace
Overwrite existing item at the target site.
rename
Rename the item.
Note: The conflictBehavior isn't supported for OneDrive Consumer.
Request body
In the request body, provide a JSON object with the following parameters.
Optional. Reference to the parent item the copy is created in.
name
string
Optional. The new name for the copy. If this information isn't provided, the same name is used as the original.
Note: The parentReference should include the driveId and id parameters for the target folder.
Response
Returns details about how to monitor the progress of the copy, upon accepting the request.
Example
This example copies a file identified by {item-id} into a folder identified with a driveId and id value.
The new copy of the file is named contoso plan (copy).txt.
POST https://graph.microsoft.com/beta/me/drive/items/{item-id}/copy
Content-Type: application/json
{
"parentReference": {
"driveId": "6F7D00BF-FC4D-4E62-9769-6AEA81F3A21B",
"id": "DCD0D3AD-8989-4F23-A5A2-2C086050513F"
},
"name": "contoso plan (copy).txt"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Drives.Item.Items.Item.Copy;
using Microsoft.Graph.Beta.Models;
var requestBody = new CopyPostRequestBody
{
ParentReference = new ItemReference
{
DriveId = "6F7D00BF-FC4D-4E62-9769-6AEA81F3A21B",
Id = "DCD0D3AD-8989-4F23-A5A2-2C086050513F",
},
Name = "contoso plan (copy).txt",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Drives["{drive-id}"].Items["{driveItem-id}"].Copy.PostAsync(requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc-beta drives items copy post --drive-id {drive-id} --drive-item-id {driveItem-id} --body '{\
"parentReference": {\
"driveId": "6F7D00BF-FC4D-4E62-9769-6AEA81F3A21B",\
"id": "DCD0D3AD-8989-4F23-A5A2-2C086050513F"\
},\
"name": "contoso plan (copy).txt"\
}\
'
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.drives.item.items.item.copy.CopyPostRequestBody copyPostRequestBody = new com.microsoft.graph.beta.drives.item.items.item.copy.CopyPostRequestBody();
ItemReference parentReference = new ItemReference();
parentReference.setDriveId("6F7D00BF-FC4D-4E62-9769-6AEA81F3A21B");
parentReference.setId("DCD0D3AD-8989-4F23-A5A2-2C086050513F");
copyPostRequestBody.setParentReference(parentReference);
copyPostRequestBody.setName("contoso plan (copy).txt");
var result = graphClient.drives().byDriveId("{drive-id}").items().byDriveItemId("{driveItem-id}").copy().post(copyPostRequestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\CopyPostRequestBody;
use Microsoft\Graph\Generated\Models\ItemReference;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new CopyPostRequestBody();
$parentReference = new ItemReference();
$parentReference->setDriveId('6F7D00BF-FC4D-4E62-9769-6AEA81F3A21B');
$parentReference->setId('DCD0D3AD-8989-4F23-A5A2-2C086050513F');
$requestBody->setParentReference($parentReference);
$requestBody->setName('contoso plan (copy).txt');
$result = $graphServiceClient->drives()->byDriveId('drive-id')->items()->byDriveItemId('driveItem-id')->copy()->post($requestBody)->wait();
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Import-Module Microsoft.Graph.Beta.Files
$params = @{
parentReference = @{
driveId = "6F7D00BF-FC4D-4E62-9769-6AEA81F3A21B"
id = "DCD0D3AD-8989-4F23-A5A2-2C086050513F"
}
name = "contoso plan (copy).txt"
}
Copy-MgBetaDriveItem -DriveId $driveId -DriveItemId $driveItemId -BodyParameter $params
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
from msgraph import GraphServiceClient
from msgraph.generated.models.copy_post_request_body import CopyPostRequestBody
from msgraph.generated.models.item_reference import ItemReference
graph_client = GraphServiceClient(credentials, scopes)
request_body = CopyPostRequestBody(
parent_reference = ItemReference(
drive_id = "6F7D00BF-FC4D-4E62-9769-6AEA81F3A21B",
id = "DCD0D3AD-8989-4F23-A5A2-2C086050513F",
),
name = "contoso plan (copy).txt",
)
result = await graph_client.drives.by_drive_id('drive-id').items.by_drive_item_id('driveItem-id').copy.post(request_body)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
The value of the Location header provides a URL for a service that returns the current state of the copy operation.
You can use this information to determine when the copy finished.
Remarks
In many cases, the copy action is performed asynchronously.
The response from the API indicates that the copy operation was accepted or rejected; for example, due to the destination filename already being in use.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback.