# Method: mediaItems.batchCreate

- [HTTP request](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#body.HTTP_TEMPLATE)
- [Request body](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#body.request_body)
  - [JSON representation](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#body.response_body)
  - [JSON representation](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#body.BatchCreateMediaItemsResponse.SCHEMA_REPRESENTATION)
- [Authorization scopes](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#body.aspect)
- [NewMediaItem](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#NewMediaItem)
  - [JSON representation](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#NewMediaItem.SCHEMA_REPRESENTATION)
- [SimpleMediaItem](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#SimpleMediaItem)
  - [JSON representation](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#SimpleMediaItem.SCHEMA_REPRESENTATION)
- [NewMediaItemResult](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#NewMediaItemResult)
  - [JSON representation](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#NewMediaItemResult.SCHEMA_REPRESENTATION)
- [Try it!](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#try-it)

Creates one or more media items in a user's Google Photos library.

This is the second step for creating a media item. For details regarding Step 1, uploading the raw bytes to a Google Server, see [Uploading media](https://developers.google.com/photos/library/guides/upload-media).

This call adds the media item to the library. If an app created album `id` is specified, the call adds the media item to the album too. Each album can contain up to 20,000 media items. By default, the media item will be added to the end of the library or album.

If an album `id` and position are both defined, the media item is added to the album at the specified position.

If the call contains multiple media items, they're added at the specified position.

### HTTP request

`POST https://photoslibrary.googleapis.com/v1/mediaItems:batchCreate`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "albumId": string, "newMediaItems": [ { object (`https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#NewMediaItem`) } ], "albumPosition": { object (`https://developers.google.com/photos/library/reference/rest/v1/AlbumPosition`) } } ``` |

| Fields ||
|---|---|
| `albumId` | `string` Identifier of the album where the media items are added. The media items are also added to the user's library. This is an optional field. |
| `newMediaItems[]` | ``object (`https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#NewMediaItem`)`` Required. List of media items to be created. Maximum 50 media items per call. |
| `albumPosition` | ``object (`https://developers.google.com/photos/library/reference/rest/v1/AlbumPosition`)`` Position in the album where the media items are added. If not specified, the media items are added to the end of the album (as per the default value, that is, `LAST_IN_ALBUM`). The request fails if this field is set and the `albumId` is not specified. The request will also fail if you set the field and are not the owner of the shared album. |

### Response body

List of media items created.

If successful, the response body contains data with the following structure:

| JSON representation |
|---|
| ``` { "newMediaItemResults": [ { object (`https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#NewMediaItemResult`) } ] } ``` |

| Fields ||
|---|---|
| `newMediaItemResults[]` | ``object (`https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#NewMediaItemResult`)`` Output only. List of media items created. |

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/photoslibrary.appendonly`

## NewMediaItem

New media item that's created in a user's Google Photos account.

| JSON representation |
|---|
| ``` { "description": string, // Union field `new_media_item_type` can be only one of the following: "simpleMediaItem": { object (`https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#SimpleMediaItem`) } // End of list of possible types for union field `new_media_item_type`. } ``` |

| Fields ||
|---|---|
| `description` | `string` Description of the media item. This is shown to the user in the item's info section in the Google Photos app. Must be shorter than 1000 characters. Only include text written by users. Descriptions should add context and help users understand media. Do not include any auto-generated strings such as filenames, tags, and other metadata. |
| Union field `new_media_item_type`. The new media item can be of various different types - this is dependent on the upload path. The currently supported uploads only use the simple media item path. `new_media_item_type` can be only one of the following: ||
| `simpleMediaItem` | ``object (`https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#SimpleMediaItem`)`` A new media item that has been uploaded via the included `uploadToken`. |

## SimpleMediaItem

A simple media item to be created in Google Photos via an upload token.

| JSON representation |
|---|
| ``` { "uploadToken": string, "fileName": string } ``` |

| Fields ||
|---|---|
| `uploadToken` | `string` Token identifying the media bytes that have been uploaded to Google. |
| `fileName` | `string` File name with extension of the media item. This is shown to the user in Google Photos. The file name specified during the [byte upload process](https://developers.google.com/photos/library/guides/upload-media) is ignored if this field is set. The file name, including the file extension, shouldn't be more than 255 characters. This is an optional field. |

## NewMediaItemResult

Result of creating a new media item.

| JSON representation |
|---|
| ``` { "uploadToken": string, "status": { object (`https://developers.google.com/photos/library/reference/rest/v1/Status`) }, "mediaItem": { object (`https://developers.google.com/photos/library/reference/rest/v1/mediaItems#MediaItem`) } } ``` |

| Fields ||
|---|---|
| `uploadToken` | `string` The upload token used to create this new (simple) media item. Only populated if the media item is simple and required a single upload token. |
| `status` | ``object (`https://developers.google.com/photos/library/reference/rest/v1/Status`)`` If an error occurred during the creation of this media item, this field is populated with information related to the error. For details regarding this field, see [Status](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#Status). |
| `mediaItem` | ``object (`https://developers.google.com/photos/library/reference/rest/v1/mediaItems#MediaItem`)`` Media item created with the upload token. It's populated if no errors occurred and the media item was created successfully. |