After establishing a connection with the Alexa Voice Service (AVS), your device communicates with AVS through HTTP/2 encoded multipart messages. Refer to the following information to help you structure your HTTP/2 requests for AVS.
HTTP/2 message structure
The following diagram illustrates an example Recognize event message sent to AVS. The multipart message has two parts:
POST for all events sent to the AVS with the events path
GET for establishing the downchannel with the directives path
Scheme
The scheme for accessing the AVS APIs is https.
Paths
All events use the following path.
:path = /v20160207/events
All directives use the following path.
:path = /v20160207/directives
Authorization
When a user authorizes your product to access Alexa on their behalf, Login with Amazon returns an access_token. Then, Alexa uses the access_token to make calls to AVS. Include the access_token in the header of each request.
authorization = Bearer {{access_token}}
Content-Type
The Content-Type parameter describes the data contained in the message body. This value helps AVS to process the request correctly. The boundary term separates different parts of a multipart message, such as JSON and binary audio.
Content-Type should always be multipart/form-data. You can determine your own boundary term. Use the boundary term consistently, and make sure that the boundary doesn't exist in the data.
AVS is designed to receive HTTP/2 encoded multipart messages. Multipart messages contain one or more JSON-formatted directives/events and any required associated binary audio attachments. This section reviews the structure of a multipart message sent to AVS.
JSON headers
Include the following required headers for the JSON part of each multipart request.
Each event has a unique header and payload. In the header, the namespace and name identify the interface and the event, and messageId is a unique identifier your device must send with each request. For more details and samples, see API Overview.
Binary audio headers
Include the following required headers for the binary audio attachment of each multipart request.
This part of the multipart message is binary audio. The only event that requires an audio attachment is a Recognize event. For details, see SpeechRecognizer Interface.
HTTP/2 responses
AVS sends two types of responses to your device. The first type, like requests, are multipart messages composed of one or more JSON-formatted directives and their associated binary audio attachments, if required. The second type are exceptions. Exceptions aren't multipart messages and are returned to your device when an error occurs. Each exception includes an error code and a description.