- HTTP request
- Request body
- Response body
- Authorization scopes
- NewMediaItem
- SimpleMediaItem
- NewMediaItemResult
- 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.
This call adds the media item to the library. If an 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. If you are creating a media item in a shared album where you are not the owner, you are not allowed to position the media item. Doing so will result in a BAD REQUEST
error.
HTTP request
POST https://photoslibrary.googleapis.com/v1/mediaItems:batchCreate
The URL uses gRPC Transcoding syntax.
Request body
The request body contains data with the following structure:
JSON representation |
---|
{ "albumId": string, "newMediaItems": [ { object ( |
Fields | |
---|---|
albumId |
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[] |
Required. List of media items to be created. Maximum 50 media items per call. |
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, |
Response body
List of media items created.
If successful, the response body contains data with the following structure:
JSON representation |
---|
{
"newMediaItemResults": [
{
object ( |
Fields | |
---|---|
newMediaItemResults[] |
Output only. List of media items created. |
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/photoslibrary
https://www.googleapis.com/auth/photoslibrary.appendonly
https://www.googleapis.com/auth/photoslibrary.sharing
NewMediaItem
New media item that's created in a user's Google Photos account.
JSON representation |
---|
{ "description": string, // Union field |
Fields | |
---|---|
description |
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 |
A new media item that has been uploaded via the included |
SimpleMediaItem
A simple media item to be created in Google Photos via an upload token.
JSON representation |
---|
{ "uploadToken": string, "fileName": string } |
Fields | |
---|---|
uploadToken |
Token identifying the media bytes that have been uploaded to Google. |
fileName |
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 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 ( |
Fields | |
---|---|
uploadToken |
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 |
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. |
mediaItem |
Media item created with the upload token. It's populated if no errors occurred and the media item was created successfully. |