Alexa.Media.Search GetPlayableContent

When a user requests content from your skill, Alexa sends a GetPlayableContent request to your skill. For example, if a user says "Alexa, play Alive from the album Ten on skill name", the skill receives a GetPlayableContent request that contains information about the user and the requested content. The skill can respond with a content identifier that represents the song Alive from the album Ten. If the skill cannot satisfy the request—for example, the user's subscription tier does not support the content, or geographic streaming rights do not allow streaming to the user's location—the skill can respond with the appropriate error code.

The response does not initiate playback of audio on the device, it only indicates whether the skill has audio content that satisfies the request. If the Alexa service determines that the audio content should be played, a subsequent request is made.

Example utterances

The following examples represent only a subset of the voice commands that can trigger a GetPlayableContent request. The full set is constantly evolving as the Alexa voice models improve and adapt to how users interact with Alexa-powered devices.

Utterance Pattern Example
"Alexa, play music on skill name" "Alexa, play music on skill name"
"Alexa, play artist on skill name" "Alexa, play Soundgarden on skill name"
"Alexa, play song by artist on skill name" "Alexa, play Alive by Pearl Jam on skill name"
"Alexa, play the album album by artist on skill name" "Alexa, play the album Nevermind by Nirvana on skill name"
"Alexa, play the playlist playlist name on skill name" "Alexa, play the playlist Party Hits on skill name"
"Alexa, play genre music on skill name" "Alexa, play rock music on skill name"
"Alexa, play the station station on skill name" "Alexa, play the Summertime station on skill name"
"Alexa, wake me up to music request on skill name" at time "Alexa, wake me up to rock music on skill name at 7:30 AM"

Understand ContentId

To build a high quality music skill, you must understand ContentId. ContentId identifies a music listening experience that a skill can return and play on a device. A ContentId can reference a track, an editorial playlist of popular songs, a custom (artist or genre seeded) station, or an album.

ContentId must be globally unique within your skill, long-lived, and always represent the same experience for all skill users. For example, imagine that Alice asks "Alexa, play the album Rainier Fog by Alice in Chains", and the skill returns a ContentId of "123" to represent the album. This same ContentId should represent this album for all users. When Bob asks "Alexa, play the album Rainier Fog by Alice in Chains", your skill should send the same ContentId of "123" in response to the GetPlayableContent request, even if the request happens one year after Alice's request.

Here is another example: Imagine that your music service has a "Top Weekly Songs" playlist, where the list of songs in the playlist changes from week to week to reflect the most popular songs on the charts. Alice asks "Alexa, play the top weekly songs playlist". Your skill responds with a ContentId of "321" which represents the "Top Weekly Songs" playlist. When Alexa sends this ContentId in an Initiate request, your skill returns the first track of the playlist, for example Shallow by Lady Gaga. One month later, Alice asks "Alexa, play the top weekly songs playlist". Your skill again responds with a ContentId of "321" because this ContentId always represents the "Top Weekly Songs" playlist. However, this time when Alexa sends this ContentId in an Initiate request, your skill returns, for example, the song Better Now by Post Malone, because the playlist contents change weekly.

When a user sets a music alarm (for example, "Alexa, wake me up to Can't Stop The Feeling by Justin Timberlake from skill name at 8 AM"), Alexa saves the ContentId returned in the GetPlayableContent response. Each time the alarm is triggered, which might be months later for a repeating alarm, Alexa sends an Initiate request to your skill with the saved ContentId, and the response should reflect the content the user requested when setting the alarm.

Similarly, when a user browses their history of music requests and selects an item to replay, Alexa calls Initiate with the saved ContentId. In the preceding example for "Top Weekly Songs", if the user sees "Top Weekly Songs" in their history and clicks to play it again, Alexa sends an Initiate request with a ContentId of "321". The resulting queue of songs might be different because the playlist changes weekly, but the user is still listening to the "Top Weekly Songs" playlist, so the result is correct.

Configure a skill to receive requests

You must configure your music skill to support this API before Alexa will send requests to it. You can do this on the Interfaces page while building your skill in the Alexa Skills Kit developer console, or by adding the API to the interfaces object in your skill manifest JSON if you're using the ASK CLI to build your skill. For an example music skill manifest, see the example music skill manifest.

Request structure

Following is the structure of a GetPlayableContent request.

Header

For an overview of the header format, see message header.

Field Value Type
messageId A version 4 UUID string
namespace Alexa.Media.Search string
name GetPlayableContent string
payloadVersion 1.0 string

Payload

The following table describes the fields in the payload of a GetPlayableContent request.

Field Description Type
requestContext An object containing context information about the request. See the RequestContext object for more information. object
filters Filters to apply during content resolution. See the Filters object for more information. object
selectionCriteria The ResolvedSelectionCriteria that should be resolved to a Content to play for the user. See the ResolvedSelectionCriteria object for more information. object

Entity and catalog types

The entity types in the request's selectionCriteria property correspond to music catalogs associated with the skill as follows:

API Entity Type Catalog Type
TRACK AMAZON.MusicRecording
ALBUM AMAZON.MusicAlbum
ARTIST AMAZON.MusicGroup
PLAYLIST AMAZON.MusicPlaylist
GENRE AMAZON.Genre
STATION AMAZON.BroadcastChannel

Example GetPlayableContent request

{
  "header": {
    "messageId": "2cae4d53-6bc1-4f8f-aa98-7dd2727ca84b",
    "namespace": "Alexa.Media.Search",
    "name": "GetPlayableContent",
    "payloadVersion": "1.0"
  },
  "payload": {
    "requestContext": {
      "user": {
        "id": "amzn1.ask.account.AGF3NETIE4MNXNG2Z64Z27RXB6JCK2R62BCPYUZI",
        "accessToken": "e72e16c7e42f292c6912e7710c838347ae178b4a"
      },
      "location": {
        "originatingLocale": "en-US",
        "countryCode": "US"
      }
    },
    "filters": {
      "explicitLanguageAllowed": true
    },
    "selectionCriteria": {
      "attributes": [
        {
          "type": "TRACK",
          "entityId": "138545995"
        },
        {
          "type": "MEDIA_TYPE",
          "value": "TRACK"
        }
      ]
    }
  }
}

GetPlayableContent response

Your skill code (AWS Lambda function) should generate and return a response in 0.5 seconds or less under moderate traffic (at least two transactions per second). Longer response times might result in your skill failing certification.

If your skill can successfully find playable content to satisfy the request, it should respond with GetPlayableContent.Response. If not, the skill should respond with a media-specific CONTENT_NOT_FOUND error response.

Response structure

Following is the structure of a GetPlayableContent response.

Header

For an overview of the header format, see message header.

Field Value Required? Type
messageId A version 4 UUID yes string
namespace Alexa.Media.Search yes string
name GetPlayableContent.Response yes string
payloadVersion 1.0 yes string

Payload

The following table describes the fields in the payload of a GetPlayableContent response.

Field Description Required? Type
content Content that points to audio that satisfies the request. yes object

Example GetPlayableContent response

The following example demonstrates a response that satisfies an example request from a user that said "Alexa, play the song Poker Face by Lady Gaga".

{
  "header": {
    "messageId": "2cae4d53-6bc1-4f8f-aa98-7dd2727ca84b",
    "namespace": "Alexa.Media.Search",
    "name": "GetPlayableContent.Response",
    "payloadVersion": "1.0"
  },
  "payload": {
    "content": {
      "id": "1021012f-12bb-4938-9723-067a4338b6d0",
      "metadata": {
        "type": "TRACK",
        "name": {
          "speech": {
            "type": "PLAIN_TEXT",
            "text": "poker face"
          },
          "display": "Poker Face"
        },
        "authors": [
          {
            "name": {
              "speech": {
                "type": "PLAIN_TEXT",
                "text": "lady gaga"
              },
              "display": "Lady Gaga"
            }
          }
        ],
        "art": {
          "sources": [
            {
              "url": "https://example.com/images/cover/48x48-000000-80-0-0.jpg",
              "size": "X_SMALL",
              "widthPixels": 48,
              "heightPixels": 48
            },
            {
              "url": "https://example.com/images/cover/60x60-000000-80-0-0.jpg",
              "size": "SMALL",
              "widthPixels": 60,
              "heightPixels": 60
            },
            {
              "url": "https://example.com/images/cover/110x110-000000-80-0-0.jpg",
              "size": "MEDIUM",
              "widthPixels": 110,
              "heightPixels": 110
            },
            {
              "url": "https://example.com/images/cover/256x256-000000-80-0-0.jpg",
              "size": "LARGE",
              "widthPixels": 256,
              "heightPixels": 256
            },
            {
              "url": "https://example.com/images/cover/600x600-000000-80-0-0.jpg",
              "size": "X_LARGE",
              "widthPixels": 600,
              "heightPixels": 600
            }
          ]
        }
      }
    }
  }
}

In the following example, the skill cannot find playable content to satisfy the user's request so it returns an error response.

{
  "header": {
    "messageId": "2cae4d53-6bc1-4f8f-aa98-7dd2727ca84b",
    "namespace": "Alexa.Media",
    "name": "ErrorResponse",
    "payloadVersion": "1.0"
  },
  "payload": {
    "type": "CONTENT_NOT_FOUND",
    "message": "Requested content could not be found."
  }
}