Property Hierarchy Management API
The unit forms the building block of property hierarchy. You can create a unit under your organization to represent your property, and then create several units under it to represent rooms. You can also add more levels in your hierarchy. For example, you can create units under the property unit to represent floors in your property, and then create units under each floor unit to represent rooms on that floor. With unit management APIs, you can create up to 15 levels of units in your hierarchy to represent your property. You can't manage properties with more than two levels in the console. Use API calls to manage these complex properties.
API endpoint
In the request header, set Host
to one of the following, depending on the region of your organization:
Country | Endpoint |
---|---|
CA, US |
|
DE, ES, FR, IT, UK |
|
JP |
|
Authentication
Each API request must have an authorization header whose value is the access token retrieved from Login with Amazon (LWA).
Operations
The Property Hierarchy Management API includes the following operations.
Operation | HTTP Method and URI |
---|---|
| |
| |
| |
| |
|
Create a unit
Call POST /v2/units
to create a unit to represent a physical unit, such as a property, floor, wing, or room in your property.
A Unit is an administrative construct for organizing people and resources (skill, devices) that interact with Alexa systems. Units are hierarchical in nature and can have zero or more sub units. The parent of a unit can't be any of its sub units.
This operation is available in the following countries.
Healthcare | Hospitality | Senior Living | Core |
---|---|---|---|
US |
US, DE, IT, ES, JP |
CA, DE, FR, IT, UK, US, ES, JP |
US |
Request format
In the request header, set Host
to the appropriate endpoint for the region of your organization. See API endpoint, earlier.
POST /v2/units HTTP/1.1
Host: api.amazonalexa.com
Accept: application/json
Authorization: Bearer {LWA Token}
Request path parameters
None.
Request body format
{
"name": {
"type": "PLAIN",
"value": {
"text": "name of unit"
}
},
"parentId": "amzn1.alexa.unit.did.{unitId}"
}
Request body parameters
Field | Description | Type | Required |
---|---|---|---|
name.type |
The type of format the name.value field is expected to have. Accepted value: PLAIN |
String | Yes |
name.value.text |
The name of the unit. A unit name can contain letters or numbers and the following special characters, with no spaces or periods: _ - = # ; : ? @ &. The unit name can't exceed 250 characters. | String | Yes |
parentId |
Unit under which to create the new unit. | String | Yes |
Response header
Host: api.amazonalexa.com
X-Amzn-RequestId: {request-id}
Content-Type: application/json
Location: "/v2/units"
Field | Description | Type | Required |
---|---|---|---|
X-Amzn-RequestId |
Unique identifier for the request. If a problem occurs, Amazon can use this value to troubleshoot the problem. | String | Yes |
propertyId |
Property ID as part of the Location header URI. |
String | Yes |
Response body
{
"id": "amzn1.alexa.unit.did.{id}"
}
Response body parameters
Field | Description | Type | Required |
---|---|---|---|
id |
The unit ID for the new unit. | String | Yes |
Error response
HTTP/1.1 {ErrorCode}
{
"type": "{ErrorType}"
"message": "{ErrorMessage}"
}
Error response parameters
Field | Description | Type | Required |
---|---|---|---|
type |
The error type. | String | No |
message |
The error message for the error. | String | No |
HTTP response codes
Status | Description |
---|---|
|
The unit was created. |
|
The request is malformed or is missing one or more required parameters.
|
|
The access token is missing or invalid. |
|
The user doesn't have permission to access the service. |
|
Request was throttled. Retry after one second, backing off exponentially until a 256-second wait, retrying every 256 seconds thereafter until a non-429 response is received. |
|
The request couldn't be handled because of an internal service error. |
Get a unit
Call GET /v2/units/{unitId}
to retrieve a unit.
This operation is available in the following countries.
Healthcare | Hospitality | Senior Living | Core |
---|---|---|---|
US |
US, DE, IT, ES, JP |
CA, DE, FR, IT, UK, US, ES, JP |
US |
Request format
In the request header, set Host
to the appropriate endpoint for the region of your organization. See API endpoint, earlier.
GET /v2/units/{unitId}
&nextToken={nextToken} HTTP/1.1
Host: api.amazonalexa.com
Accept: application/json
Authorization: Bearer {LWA Token}
Request parameters
Field | Description | Type | Required |
---|---|---|---|
unitId |
Identifier for the unit you want to retrieve in the following format "amzn1.alexa.unit.did.{id}" . |
String | Yes |
Request body
None.
Response header
Host: api.amazonalexa.com
X-Amzn-RequestId: {request-id}
Content-Type: application/json
Field | Description | Type | Required |
---|---|---|---|
X-Amzn-RequestId |
Unique identifier for the request. If a problem occurs, Amazon can use this value to troubleshoot the problem. | String | Yes |
Response body
{
"id": "amzn1.alexa.unit.did.{unitId}",
"name": {
"type": "PLAIN",
"value": {
"text": "UnitName"
}
},
"level": 0,
"parentId": null
}
Response body parameters
Field | Description | Type | Required |
---|---|---|---|
name.type |
The type of format the name.value field is expected to have. Accepted value: PLAIN |
String | Yes |
name.value.text |
The name of the unit. | String | Yes |
level |
Number of levels the unit is from the root unit. Root unit level is 0. | Integer | Yes |
parentId |
ID of the parent unit for the retrieved unit. | String | Yes |
Error response
HTTP/1.1 {ErrorCode}
{
"type": "{ErrorType}"
"message": "{ErrorMessage}"
}
Error response parameters
Field | Description | Type | Required |
---|---|---|---|
type |
The error type. | String | No |
message |
The error message for the error. | String | No |
HTTP response codes
Status | Description |
---|---|
|
The request succeeded. |
|
The request is malformed or is missing one or more required parameters.
|
|
The access token is missing or invalid. |
|
The user doesn't have permission to access the service. |
|
|
|
Request was throttled. Retry after one second, backing off exponentially until a 256-second wait, retrying every 256 seconds thereafter until a non-429 response is received. |
|
The request couldn't be handled because of an internal service error. |
List units
Call GET /v2/units/
to retrieve units. If there are no child units, the operation returns an empty list. The operation returns units that are accessible to the caller. All subunits up to depth specified, if any, are returned.
paginationContext.nextToken
in the response for null
to make sure that there are no more results. In certain cases, an empty list might be returned, if all units have been filtered due to authorization check.This operation is available in the following countries.
Healthcare | Hospitality | Senior Living | Core |
---|---|---|---|
US |
US, DE, IT, ES, JP |
CA, DE, FR, IT, UK, US, ES, JP |
US |
Request format
In the request header, set Host
to the appropriate endpoint for the region of your organization. See API endpoint, earlier.
GET /v2/units/
&nextToken={nextToken} HTTP/1.1
Host: api.amazonalexa.com
Accept: application/json
Authorization: Bearer {LWA Token}
Request query parameters
Field | Description | Type | Required |
---|---|---|---|
|
Identifier of the unit for which child units should be returned. In format of |
String |
Yes |
|
Number of entries to fetch in a request. Default: up to 10 entries are returned, current max is 50. |
Integer |
No |
|
Token to fetch the next set of items. Set this property to the token provided in the |
String |
No |
|
Controls the number of immediate depth of subunits to retrieve. When not set, defaults to
|
String |
No |
|
An attribute or set of attributes to include in the response. Current values supported:
|
String |
No |
Request body
None.
Response header
Host: api.amazonalexa.com
X-Amzn-RequestId: {request-id}
Content-Type: application/json
Field | Description | Type | Required |
---|---|---|---|
X-Amzn-RequestId |
Unique identifier for the request. If a problem occurs, Amazon can use this value to troubleshoot the problem. | String | Yes |
Response body example
{
"results": [
{
"id": "amzn1.alexa.unit.{unitId}",
"name": {
"type": "PLAIN",
"value": {
"text": "unitName"
}
}
"parentId": "amzn1.alexa.unit.{unitID}",
"level":0
}
],
"paginationContext": {
"nextToken": "ABCD1234"
}
}
Response body parameters
Field | Description | Type | Required |
---|---|---|---|
results |
The units that matched the request. | Array of unit objects | Yes |
results[*].id |
The id for the unit. | String | Yes |
results[*].name.type |
The type of format the name.value field is expected to have. Possible values: PLAIN |
String | Yes |
results[*].name.value.text |
The name of the unit. | String | Yes |
results[*].parentId |
ID of the parent unit for this unit. | String | Yes |
results[*].level |
Number of levels the unit is from the root unit. Root unit level is 0. | Integer | Yes |
paginationContext.nextToken |
Token used for getting the next page of results. For details, see Handling Pagination in Query Results. | String | No |
When the request doesn't include expand=all
, the level
, name
, and parentId
properties are included in the response for each unit, but return null
.
Additional request and response examples
The following example shows a request that uses the expand
and queryDepth
parameters to include all units for a parent unit and details for each unit.
GET /v2/units?parentId={unitId}&queryDepth=all&expand=all HTTP/1.1
The following example shows a request that uses the queryDepth
parameter to include one level of units, and doesn't include all details. Because the request doesn't include expand=all
, the level
, name
, and parentId
properties all return null
.
GET /v2/units?parentId={unitId}&queryDepth=1 HTTP/1.1
The following example shows a request that uses the queryDepth
parameter to include all units for a parent unit, but no details. Because the request doesn't include expand=all
, the level
, name
, and parentId
properties all return null
.
GET /v2/units?parentId={unitId}&queryDepth=all HTTP/1.1
Error response
HTTP/1.1 {ErrorCode}
{
"type": "{ErrorType}"
"message": "{ErrorMessage}"
}
Error response parameters
Field | Description | Type | Required |
---|---|---|---|
type |
The error type. | String | No |
message |
The error message for the error. | String | No |
HTTP response codes
Status | Description |
---|---|
|
The request succeeded. |
|
The request is malformed or is missing one or more required parameters.
|
|
The access token is missing or invalid. |
|
The user doesn't have permission to access the service. |
|
|
|
Request was throttled. Retry after one second, backing off exponentially until a 256-second wait, retrying every 256 seconds thereafter until a non-429 response is received. |
|
The request couldn't be handled because of an internal service error. |
Update a unit
Call PUT /v2/units/{unitId}
to update the name of the unit.
This operation is available in the following countries.
Healthcare | Hospitality | Senior Living | Core |
---|---|---|---|
US |
US, DE, IT, ES, JP |
CA, DE, FR, IT, UK, US, ES, JP |
US |
Request format
In the request header, set Host
to the appropriate endpoint for the region of your organization. See API endpoint, earlier.
PUT /v2/units/{unitId} HTTP/1.1
Host: api.amazonalexa.com
Accept: application/json
Authorization: Bearer {LWA Token}
Request path parameters
Field | Description | Type | Required |
---|---|---|---|
unitId |
Identifier for the unit you want to update in the following format "amzn1.alexa.unit.did.{id}" . |
String | Yes |
Request body format
{
"name": {
"type": "PLAIN",
"value": {
"text": "NAME"
}
}
}
Request body parameters
Field | Description | Type | Required |
---|---|---|---|
name.type |
The type of format the name.value field is expected to have. Accepted value: PLAIN |
String | Yes |
name.value.text |
The name of the unit. The name of the unit. A unit name can contain letters or numbers and the following special characters, with no spaces or periods: _ - = # ; : ? @ &. The unit name can't exceed 250 characters. | String | Yes |
Response header
Host: api.amazonalexa.com
X-Amzn-RequestId: {request-id}
Content-Type: application/json
Location: "/v2/units/{unitId}"
Field | Description | Type | Required |
---|---|---|---|
X-Amzn-RequestId |
Unique identifier for the request. If a problem occurs, Amazon can use this value to troubleshoot the problem. | String | Yes |
propertyId |
Property ID as part of the Location header URI. |
String | Yes |
Response body
None.
Response body parameters
None.
Error response
HTTP/1.1 {ErrorCode}
{
"type": "{ErrorType}"
"message": "{ErrorMessage}"
}
Error response parameters
Field | Description | Type | Required |
---|---|---|---|
type |
The error type. | String | No |
message |
The error message for the error. | String | No |
HTTP response codes
Status | Description |
---|---|
|
The unit was updated. |
|
The request is malformed or is missing one or more required parameters.
|
|
The access token is missing or invalid. |
|
The user doesn't have permission to access the service. |
|
Request was throttled. Retry after one second, backing off exponentially until a 256-second wait, retrying every 256 seconds thereafter until a non-429 response is received. |
|
The request couldn't be handled because of an internal service error. |
Delete a unit
Call DELETE /v2/units/{unitId}
to delete a unit. If the unit has child Units, 400 Bad request is returned.
This operation is available in the following countries.
Healthcare | Hospitality | Senior Living | Core |
---|---|---|---|
US |
US, DE, IT, ES, JP |
CA, DE, FR, IT, UK, US, ES, JP |
US |
Request format
In the request header, set Host
to the appropriate endpoint for the region of your organization. See API endpoint, earlier.
DELETE /v2/units/{unitId} HTTP/1.1
Host: api.amazonalexa.com
Accept: application/json
Authorization: Bearer {LWA Token}
Request path parameters
Field | Description | Type | Required |
---|---|---|---|
unitId |
Identifier for the unit you want to update in the following format "amzn1.alexa.unit.did.{id}" . |
String | Yes |
Request body format
None.
Request body parameters
None.
Response header
Host: api.amazonalexa.com
X-Amzn-RequestId: {request-id}
Content-Type: application/json
Location: "/v2/units/{unitId}"
Field | Description | Type | Required |
---|---|---|---|
X-Amzn-RequestId |
Unique identifier for the request. If a problem occurs, Amazon can use this value to troubleshoot the problem. | String | Yes |
Response body
None.
Response body parameters
None.
Error response
HTTP/1.1 {ErrorCode}
{
"type": "{ErrorType}"
"message": "{ErrorMessage}"
}
Error response parameters
Field | Description | Type | Required |
---|---|---|---|
type |
The error type. | String | No |
message |
The error message for the error. | String | No |
HTTP response codes
Status | Description |
---|---|
|
The unit was deleted. |
|
The request is malformed or is missing one or more required parameters.
|
|
The access token is missing or invalid. |
|
The user doesn't have permission to access the service. |
|
|
|
Request was throttled. Retry after one second, backing off exponentially until a 256-second wait, retrying every 256 seconds thereafter until a non-429 response is received. |
|
The request couldn't be handled because of an internal service error. |
Related topics
Last updated: May 17, 2024