Analytics API


The Analytics API lets you obtain the same analytics data visible in the AWS QuickSight dashboards in a CSV format. Examples of how you can use this data include the following:

  • Gain insights about Alexa performance in your properties, such as learning which rooms are the most active.
  • Merge the data with your own property-specific information to discern new insights. For example, learn that a resident's satisfaction has increased after placing calls to family with Alexa.
  • Provide data to your stakeholders, either through custom reports or by surfacing through your own web interface.

For details about viewing analytics in the developer console, see View Analytics in the Alexa Smart Properties Console.

About the available data

The Analytics API can obtain historic data for the past 90 days, either through a date range, or daily. You can select custom categories of data to retrieve. For example, you can exclude data relevant to proactive campaigns if you don't have multimodal devices.

You can request data for a specific unit, or for all children of a parent unit. This includes the organization unit, so you can get data for all units in your organization.

After you send a request, the API schedules the request to run immediately, and then delivers the result to an S3 bucket that you provide.

Prerequisites

To use the Analytics API, you must have the following:

  1. An Alexa Smart Properties (ASP) property on the Alexa for Properties (A4P) tech stack. This includes the Senior Living, Healthcare, and Core subscriptions.

    Hospitality subscriptions are now offered in the A4P tech stack. Reach out to your Solution Architect to confirm you're on the A4P tech stack if you use the Hospitality subscription.

  2. An Amazon Web Services (AWS) account with an S3 Bucket. Configure the S3 bucket to have the following policy attached under Bucket Policy on the Permissions tab and replace the Resource with your ARN.

     {
       "Version": "2012-10-17",
       "Statement": [
         {
           "Sid": "Statement1",
           "Effect": "Allow",
           "Principal": {
             "AWS": "arn:aws:iam::889066238466:role/AlexaAnalyticsReportConsumerS3IamRole"
           },
           "Action": "s3:PutObject",
           "Resource": "**<REPLACE WITH S3 BUCKET ARN>**/*"
         }
       ]
     }
    
  3. An ASP property containing units. The property and units must be at least four days old.
  4. A Login with Amazon (LWA) access token with ownership to the units that are being requested.

API endpoint

The endpoint of the Analytics API is https://api.amazonalexa.com.

Authentication

Each API request must have an authorization header whose value is the access token retrieved from Login with Amazon (LWA).

Operations

The Analytics API includes the following operations.

Operation HTTP method and URI

Generate Report

POST /v1/enterprise/analytics/reports

Generate report

Generate a CSV file with the requested data and save it to a configured S3 bucket.

Amazon recommends that you minimize the amount of time that the generated CSV files remain your S3 bucket and delete these files as soon as possible.

Request

To generate a report, you make a POST request to /v1/enterprise/analytics/reports.

This operation is available in the following countries.

Healthcare Hospitality (A4P) Senior Living Core

US, CA

US, CA

US, CA

US, CA

Request path and header example

Copied to clipboard.

POST /v1/enterprise/analytics/reports
Host: api.amazonalexa.com
Accept: application/json
Authorization: Bearer {access token}

Request path and header parameters

Parameter Located in Description Type Required

access token

Header

LWA token.

String

Yes

Request body example

{
  "unitId": "amzn1.alexa.unit.did.xxxx",
  "categories": [
    "DEVICE"
  ],
  "dateRange": {
    "startDate": "2023-06-01",
    "endDate": "2023-06-02",
    "granularity": "DAILY"
  },
  "format": "CSV",
  "showSubUnits": true,
  "deliveryChannel": {
    "id": "arn:aws:s3:::<bucket id>",
    "type": "S3"
  }
}

Request body properties

Field Description Type Required

unitId

Directed ID of a unit in the hierarchy in the format amzn1.alexa.unit.did.xxxx. This is the root unit of the report. This means that the report includes data for the specified unit and its descendants. Max length of 255 characters.

String

Yes

categories

An array of enumerations that specify the type of data to deliver in the report.
Accepted values: PROPERTY_SKILL, PROACTIVE_CAMPAIGN, DOMAIN_ENGAGEMENT, COMMUNICATION, DEVICE.

Array of enumeration values

Yes

dateRange

Encapsulates information about the dates the report should cover.

Object

Yes

dateRange.startDate

The earliest date to retrieve data for, inclusive, in the format YYYY-MM-DD. Date can be no more than 93 days before the current date. The date you provide follows UTC+00:00 date stamps.

String

Yes

dateRange.endDate

The latest date to retrieve data for, inclusive, in the format YYYY-MM-DD. Date must be at least four days before the current date. The date you provide follows UTC+00:00 date stamps.

String

Yes

dateRange.granularity

Indicates whether to roll up the data for the specified time range.
Accepted values:

  • RANGE – Roll up the data into a single count.
  • DAILY – Display data for each day. Days are derived from startDate and endDate.

For example, assume the report contains three days of data for two units (unitA, unitB) measuring some metric with a value of 1 each day:

  • For DAILY, the report has six rows (unitAday1=1, unitAday2=1, unitAday3=1, unitBday1=1, unitBday2=1, unitBday3=1)
  • For RANGE, the report has two rows (unitA=3, unitB=3)

Enumeration: RANGE or DAILY

Yes

format

The output file type for the report.
Accepted values: CSV.

Enumeration: CSV

Yes

showSubUnits

When true, the report includes a row for each descendent in the hierarchy. When false, the report displays all data in one count for the provided unit.

For example, assume the report contains two days of data for three units in a tree structure with unitA as the parent of unitB and unitC. In this example, the metric being measured has a value of 1 for each unit each day.

  • When showSubUnits is true, the report has six rows (unitAday1=1, unitBday1=1, unitCday1=1, unitAday2=1, unitBday2=1, unitCday2=1).
  • When showSubUnits is false, the report has two rows (unitAday1=3, unitAday2=3). The metrics for unitB and unitC are included in the count for unitA.

Boolean

Yes

deliveryChannel

Encapsulates information about how to deliver the output report.

Object

Yes

deliveryChannel.type

Specifies to deliver the report.
Accepted values: S3.

Enumeration: S3

Yes

deliveryChannel.id

Identifier for the output report delivery location. Max length of 255 characters. When type is S3, set id to the ARN for the S3 bucket in the format arn:aws:s3:::<bucket id>.

String

No

Response

A successful response returns HTTP 202 Accepted with information about the expected report outputs. On error, the response returns the appropriate HTTP status code and includes a response body with an error code and human readable message

Response body example

{
  "message": "The report generation has been queued. Results with the attached names will be delivered when complete.",
  "reports": [
    {
      "category": "<configuration.categories ENUM value, ex: DEVICE>",
      "name": "<output-report-filename-n.csv>"
    }
  ]
}

Response headers

Property Description Type

Content-Type

Contains application/json

String

X-Amzn-RequestId

A UUID generated for the individual request.

String

Response body properties

Property Description Type

message

A generic success or failure message

String

reports[]

An array of objects with information about the expected output reports. If an error occurs, the reports array is empty.

Array

reports[i].category

Name of the corresponding category for this report.

String

reports[i].name

Name of an output report. Reports are generated asynchronously based on the request.

String

errors[]

Array of problems encountered during processing. Included when an error occurs.

Array

errors[i].errorDescription

A short message explaining the error.

String

errors[i].errorCode

An ID to reference documentation for more information about the error.

String

errors[i].status

HTTP Response code for the type of error encountered.

int

HTTP status codes

Status Description

202 Accepted

The request was successful. Reports are generated asynchronously and are available at the specified deliveryChannel when complete. The specific reports to generate are specified in the reports array in the response body. For details, see Response body properties.

400 Bad Request

Indicates that one or more properties in the request body aren't valid. The following example shows the response body with the error and message.

{
  "errors": [
    {
      "errorCode": "BAD_REQUEST",
      "errorDescription": "Granularity format Invalid",
      "status": 400
    }
  ],
  "message": "There was an error processing the request",
  "reports": []
}

401 Unauthorized

Request didn't include the authorization token, or the included token expired or isn't valid. Or, you don't have access to the resource.

403 Forbidden

Indicates that the authorization token is valid, but the requested operation isn't allowed.

404 Not Found

Requested resource not found.

429 Too Many Requests

API exceeded the permitted rate limit or specified number of requests per unit of time. Requests can be retried using exponential back-off.

500 Server Error

Error occurred on the server. The request can be retried using exponential back-off.

503 Service Unavailable

Data not yet available due to an upstream processing delay. Amazon recommends that you retry every few hours while we work to resolve the delay.

503 Service Unavailable

Server is down for maintenance, overloaded, or otherwise unavailable to handle the incoming request.

The following code shows the JSON format of an error.

{
  "message": "There was an error processing the request.",
  "reports": [], // no reports are delivered if there are any errors during processing
  "errors": [
    {
      "errorDescription": "<description of the failure>",
      "errorCode": "<more specific error code to reference in documentation>",
      "status": <HTTP status code related to the error>
    }
  ]
}

Sample generated reports

The following table shows an example of the output for DEVICE data over a specific time range.

dataset_date unitId_level_1 unitName_level_1 unitId_level_2 unitName_level_2 unitId_level_3 unitName_level_3 device_count active_device_count dialog_count
8/15/2023 amzn1.alexa.unit.did.XXX Test Healthcare amzn1.alexa.unit.did.YYY Default amzn1.alexa.unit.did.ZZZ Test Room 1 0 0
8/16/2023 amzn1.alexa.unit.did.XXX Test Healthcare amzn1.alexa.unit.did.YYY Default amzn1.alexa.unit.did.ZZZ Test Room 1 0 0
8/17/2023 amzn1.alexa.unit.did.XXX Test Healthcare amzn1.alexa.unit.did.YYY Default amzn1.alexa.unit.did.ZZZ Test Room 1 0 0
8/19/2023 amzn1.alexa.unit.did.XXX Test Healthcare amzn1.alexa.unit.did.YYY Default amzn1.alexa.unit.did.ZZZ Test Room 1 0 0
8/20/2023 amzn1.alexa.unit.did.XXX Test Healthcare amzn1.alexa.unit.did.YYY Default amzn1.alexa.unit.did.ZZZ Test Room 1 0 0
8/21/2023 amzn1.alexa.unit.did.XXX Test Healthcare amzn1.alexa.unit.did.YYY Default amzn1.alexa.unit.did.ZZZ Test Room 1 0 0
8/22/2023 amzn1.alexa.unit.did.XXX Test Healthcare amzn1.alexa.unit.did.YYY Default amzn1.alexa.unit.did.ZZZ Test Room 1 0 0

The following table shows an example of the output for DOMAIN_ENGAGEMENT data for a specific time range.

dataset_date unitId_level_0 unitName_level_0 unitId_level_1 unitName_level_1 Business Domain active_device_count dialog_count
8/16/2023 amzn1.alexa.unit.did.XXX Test Org amzn1.alexa.unit.did.YYY Test Healthcare Audio 12 46
8/17/2023 amzn1.alexa.unit.did.XXX Test Org amzn1.alexa.unit.did.YYY Test Healthcare Other 2 3

The following table shows an example of the output for PROACTIVE_CAMPAIGN data for a specific time range.

dataset_date unitId_level_0 unitName_level_0 unitId_level_1 unitName_level_1 campaign_id targeted_devices_count taps_count impression_count
9/3/2023 amzn1.alexa.unit.did.XXX Test Org amzn1.alexa.unit.did.YYY Test Healthcare XXX 1 4 100

The following table shows an example of the output for PROPERTY_SKILL data for a specific time range.

dataset_date unitId_level_0 unitName_level_0 unitId_level_1 unitName_level_1 skill_name intent_name active_device_count dialog_count
9/3/2023 amzn1.alexa.unit.did.XXX Test Org amzn1.alexa.unit.did.YYY Test Healthcare My Property Skill GetMenu 1 1

The following table shows an example of the output for COMMUNICATION data for a specific time range.

dataset_date unitId_level_0 unitName_level_0 unitId_level_1 unitName_level_1 direction sub_experience call_provider calling_action_count calling_duration_minutes dropIn_action_count dropIn_duration_minutes
9/3/2023 amzn1.alexa.unit.did.XXX Test Org amzn1.alexa.unit.did.YYY Test Healthcare Inbound DropIn_Video A2A 0 0 1 164.33
9/3/2023 amzn1.alexa.unit.did.XXX Test Org amzn1.alexa.unit.did.YYY Test Healthcare Outbound Calling_Voice PSTN 99 157.95 0 0

Was this page helpful?

Last updated: Nov 28, 2023