Create bundle

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.

Add a new bundle to the user's drive.

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) Not supported. Not supported.
Delegated (personal Microsoft account) Files.ReadWrite Files.ReadWrite.All
Application Not supported. Not supported.

HTTP request

POST /drive/bundles

Request headers

Name Description
Authorization Bearer {token}. Required. Learn more about authentication and authorization.

Request body

In the request body, supply a JSON representation of the bundle to be created.

Response

If the request is successful, the driveItem representing the newly created bundle is returned.

Read the Error Responses topic for more info about how errors are returned.

Examples

Example 1: Create a bundle

The following example shows how to create a basic new bundle. This request creates a new bundle named Just some files and adds two existing items to the bundle. This bundle can be used to share a collection of files with other users without sharing the folder those items are stored in.

Request

The following example shows a request.

POST https://graph.microsoft.com/beta/drive/bundles
Content-Type: application/json

{
  "name": "Just some files",
  "@microsoft.graph.conflictBehavior" : "rename",
  "bundle": { },
  "children": [
    { "id": "1234asdf" },
    { "id": "1234qwerty" }
  ]
}

Response

The following example shows the response.

HTTP/1.1 201 Created
Content-Type: application/json

{
  "id": "1234321!abc",
  "name": "Just some files",
  "bundle": {
    "childCount": 2
  }
}

The response object shown here might be shortened for readability.

Example 2: Create an album

The request to create a new photo album is similar, although inside the bundle facet, the album property is set to a non-null value.

Request

The following example shows a request.

POST https://graph.microsoft.com/beta/drive/bundles
Content-Type: application/json

{
  "name": "My Day at the Beach",
  "@microsoft.graph.conflictBehavior" : "rename",
  "bundle": { "album": {} },
  "children": [
    { "id": "1234asdf" }
  ]
}

Response

The following example shows the response.

Note: The response object shown here might be shortened for readability.

HTTP/1.1 201 Created
Content-Type: application/json

{
  "id": "1234321!abc",
  "name": "Just some files",
  "bundle": {
    "childCount": 2,
    "album": { }
 }
}

If @microsoft.graph.conflictBehavior is set to rename and a bundle with the same name already exists, the new bundle name is updated to be unique. OneDrive appends a number to the end of the bundle name.

For example, My Day at the Beach would be renamed My Day at the Beach 1. If My Day at the Beach 1 is taken, then the number would be incremented again until a unique bundle name is discovered.