Create albums

In Google Photos, you can organize photos and other media items using albums. A media item can be associated with one or more albums. To start associating media items with an album, you need to create the album first.

Required authentication scope

To create an album, you app must request at least one of the following authorization scopes:

  • .appendonly
  • .sharing
  • .photoslibrary

Creating a new album

To create an album, call albums.create and include the title. Note that title is restricted to 500 characters.

The call returns an album. Your app can store the album ID from this information and use it for uploading media items to the specific album.

REST

Here is a header for a POST request:

POST https://photoslibrary.googleapis.com/v1/albums
Content-type: application/json
Authorization: Bearer OAUTH2_TOKEN

The request body looks like this:

{
  "album": {
    "title": "New Album Title"
  }
}

If successful, the response returns an album:

{
  "productUrl": "ALBUM_PRODUCT_URL",
  "id": "ALBUM_ID",
  "title": "ALBUM_TITLE",
  "isWriteable": "WHETHER_YOU_CAN_WRITE_TO_THIS_ALBUM"
}

Java

try {
  Album newAlbum = Album.newBuilder().setTitle("My Album").build();
  Album createdAlbum = photosLibraryClient.createAlbum(newAlbum);
  // The createdAlbum object contains properties of an album
  String productUrl = createdAlbum.getProductUrl();
  // coverPhotoBaseUrl shouldn't be used as is. Append parameters to base URLs before use
  String albumCoverImage = createdAlbum.getCoverPhotoBaseUrl() + "=w2048-h1024";
  boolean isWriteable = createdAlbum.getIsWriteable();
} catch (ApiException e) {
  // Handle error
}

PHP

try {
    $newAlbum = PhotosLibraryResourceFactory::album("My Album");
    $createdAlbum = $photosLibraryClient->createAlbum($newAlbum);
    // The createdAlbum object contains properties of an album
    $albumId = $createdAlbum->getId();
    $productUrl = $createdAlbum->getProductUrl();
    // coverPhotoBaseUrl shouldn't be used as is. Append parameters to base URLs before use
    $albumCoverImage = $createdAlbum->getCoverPhotoBaseUrl() . '=w2048-h1024';
    $isWriteable = $createdAlbum->getIsWriteable();
} catch (\Google\ApiCore\ApiException $e) {
    // Handle error
}