Site object represents a place where devices are installed, and sites API allows you to manage them; you can create, update, delete a site, or list sites.

Site object

name type description
id string site id
name string site name
createdAt timestamp UTC timestamp in millisecond
timezone string timezone in tz database
country string installation location, two-letter country code (ISO 3166-1 alpha-2)
zipcode string zipcode of site
latitude number latitude of site
longitude number longitude of site
description string site description

Create site

Create a site

Endpoints

POST /sites

Parameters

name type description
name string (required) site name
timezone string (required) timezone in tz database
country string (required) site location. Possible values are KR, JP, CA or US
teamId string (required) team identifier for site management
zipcode string zipcode of site
latitude number latitude of site (from -90 to 90)
longitude number longitude of site (from -180 to 180)
description string site description

Request Example

curl -X POST
  "https://api2.enertalk.com/sites"
  -H "Authorization: Bearer <access_token>"
  -H "accept-version: 2.0.0"
  -H "Content-Type: application/json"
  -d '{
    "name": "test name",
    "latitude": 37.566535,
    "longitude": 126.977969,
    "timezone": "Asia/Seoul",
    "createdAt": 1479190407000,
    "country": "KR",
    "zipcode": 98052,
    "description": "home"
  }'

Response

Created site object, or error on failure.

Response Example

{
  "id": "651b4105",
  "name": "test name",
  "latitude": 37.566535,
  "longitude": 126.977969,
  "timezone": "Asia/Seoul",
  "createdAt": 1479190407000,
  "country": "KR",
  "zipcode": "98052",
  "description": "home"
}

List sites

Get information of all sites belonging to a user

Endpoints

GET /sites

Parameters

name type description
role string user role for sites. admin or member. With parameter, return sites which the user has given user role for. Without this parameter, return all sites

Request Example

curl -X GET
  -H "Authorization: Bearer <access_token>"
  -H "accept-version: 2.0.0"
  "https://api2.enertalk.com/sites"

Response

List of site objects, or error on failure.

Response Example

[
   {
     "id": "651b4105",
     "name": "test name",
     "latitude": 37.566535,
     "longitude": 126.977969,
     "timezone": "Asia/Seoul",
     "createdAt": 1479190407000,
     "country": "KR",
     "zipcode": "98052",
     "description": "home"
   }
]

Get a site

Get a site information for a user.

Endpoints

GET /sites/:siteId

Parameters

name type description
siteId string (required) site identifier

Request Example

curl -X GET
  "https://api2.enertalk.com/sites/651b4105"
  -H "Authorization: Bearer <access_token>"
  -H "accept-version: 2.0.0"

Response

Retrieved site object, or error on failure.

Response Example

{
  "id": "651b4105",
  "name": "test name",
  "latitude": 37.566535,
  "longitude": 126.977969,
  "timezone": "Asia/Seoul",
  "createdAt": 1479190407000,
  "country": "KR",
  "zipcode": "98052",
  "description": "home"
}

Update site

Update a site Information for a user.

Endpoints

PATCH /sites/:siteId

Parameters

name type description
siteId number (required) site id
name string site name
zipcode string zipcode of site
latitude number latitude of site
longitude number longitude of site
description string site description

Request Example

curl -X PATCH
  "https://api2.enertalk.com/sites/651b4105"
  -H "Authorization: Bearer <access_token>"
  -H "accept-version: 2.0.0"
  -H "Content-Type: application/json"
  -d '{
    "name": "updated name",
    "zipcode": "502-260",
    "latitude": 41.231,
    "longitude": -92.123,
    "description": "updated description"
  }'

Response

Updated site object, or error on failure.

Response Example

{
  "id": "651b4105",
  "name": "updated name",
  "latitude": 41.231,
  "longitude": -92.123,
  "timezone": "Asia/Seoul",
  "createdAt": 1479190407000,
  "country": "KR",
  "zipcode": "502-260",
  "description": "updated description"
}

Delete site

Delete a site and its devices.

Endpoints

DELETE /sites/:siteId

Parameters

name type description
siteId number (required) site id

Request Example

curl -X DELETE
  "https://api2.enertalk.com/sites/651b4105"
  -H "Authorization: Bearer <access_token>"
  -H "accept-version: 2.0.0"

Response

Deleted site id.

Response Example

{
  "id": "651b4105"
}