Sites API
Sites API provides HTTP API to handle sites' objects.
Create Site CloudGateway
POST /v3/sites
Creates a new site with provided parameters and returns created site object.
Request
$ curl -X POST \
http://api.enapter.com/v3/sites \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"name": "Test Site",
"timezone": "UTC"
}'
Body Parameters
namestringrequired#Name for the new site.
timezonestringrequired#Timezone for the new site.
locationobject#Locationobject.Location.namestring#Location name for the new site.
Location.latitudestring#Location latitude for the new site.
Location.longitudestring#Location longitude for the new site.
Response
Information about created site:
{
"site": {
"id": "fecbbba0-79f2-4e9e-a6f0-69a310ab110b",
"name": "Test Site",
"timezone": "UTC",
"version": "V3",
"authorized_role": "INSTALLER"
}
}
siteobject#Siteobject contains site information.Site.idstring#ID of the site.
Site.namestring#Name of the site.
Site.timezonestring#Timezone of the site.
Site.locationobject#The site location information.
location.namestring#Location name of the site.
location.latitudestring#Location latitude of the site.
location.longitudestring#Location longitude of the site.
Site.authorized_rolestring#User authorized role for the site. See authorization system for more details.
Site.versionstring#Version of the site. Should be always
V3at now.
Get Site CloudGateway
GET /v3/sites/{site_id}
Returns information about site with site_id.
Gateway has a single site and it has a shortcut API GET /v3/site.
Request
$ curl http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b
Response
Retrieved site:
{
"site": {
"id": "fecbbba0-79f2-4e9e-a6f0-69a310ab110b",
"name": "Test Site",
"timezone": "UTC",
"version": "V3",
"authorized_role": "INSTALLER"
}
}
siteobject#Siteobject contains site information.Site.idstring#ID of the site.
Site.namestring#Name of the site.
Site.timezonestring#Timezone of the site.
Site.locationobject#The site location information.
location.namestring#Location name of the site.
location.latitudestring#Location latitude of the site.
location.longitudestring#Location longitude of the site.
Site.authorized_rolestring#User authorized role for the site. See authorization system for more details.
Site.versionstring#Version of the site. Should be always
V3at now.
Update Site CloudGateway
PATCH /v3/sites/{site_id}
Updates site information. You should be an OWNER at least to do this.
Gateway has a single site and it has a shortcut API PATCH /v3/site.
Request
$ curl -X PATCH \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"timezone": "Europe/Berlin",
"location": {
"latitude": 52.520008,
"longitude": 13.404954
}'
It is also possible to reset some fields:
$ curl -X PATCH \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"timezone": "Europe/Berlin",
"_reset" ["location.name"]
}'
Body Parameters
namestring#The new name for the site.
timezonestring#The new timezone for the site.
locationobject#Locationobject.location.namestring#The new location name for the site.
location.latitudestring#The new location latitude for the site.
location.longitudestring#The new location longitude for the site.
_resetarray of strings#The list of fields to reset. Available values:
location.name, location.latitude, location.longitude.
Response
Updated site:
{
"site": {
"id": "fecbbba0-79f2-4e9e-a6f0-69a310ab110b",
"name": "Test Site",
"timezone": "Europe/Berlin",
"version": "V3",
"authorized_role": "INSTALLER"
}
}
siteobject#Siteobject contains site information.Site.idstring#ID of the site.
Site.namestring#Name of the site.
Site.timezonestring#Timezone of the site.
Site.locationobject#The site location information.
location.namestring#Location name of the site.
location.latitudestring#Location latitude of the site.
location.longitudestring#Location longitude of the site.
Site.authorized_rolestring#User authorized role for the site. See authorization system for more details.
Site.versionstring#Version of the site. Should be always
V3at now.
List Sites CloudGateway
GET /v3/sites
Returns all sites available to the user.
It does not make any sense to get sites list on Gateway, because it has only single site. It simpler to get this single site via GET /v3/site.
Request
$ curl http://api.enapter.com/v3/sites
Query Parameters
limitnumber#The maximum number of sites to return.
offsetnumber#The number of sites to skip. Sites ordered by ID.
name.containsstring#Filter sites by name.
Response
List of sites:
{
"sites": [{
"id": "fecbbba0-79f2-4e9e-a6f0-69a310ab110b",
"name": "Test Site",
"timezone": "UTC",
"version": "V3",
"authorized_role": "INSTALLER"
},{
"id": "69a3110b-6ff2-fba0-a079-4eecbb9e0ab1",
"name": "Our Factory",
"timezone": "Europe/Berlin",
"version": "V3",
"authorized_role": "USER",
"location": {
"name: "Berlin",
"latitude": 52.520008,
"longitude": 13.404954
}
}]
}
Each site object has the following fields:
siteobject#Siteobject contains site information.Site.idstring#ID of the site.
Site.namestring#Name of the site.
Site.timezonestring#Timezone of the site.
Site.locationobject#The site location information.
location.namestring#Location name of the site.
location.latitudestring#Location latitude of the site.
location.longitudestring#Location longitude of the site.
Site.authorized_rolestring#User authorized role for the site. See authorization system for more details.
Site.versionstring#Version of the site. Should be always
V3at now.
Delete Site CloudGateway
DELETE /v3/sites
Deletes site. You should be an OWNER at least to do this.
Request
$ curl -X DELETE
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b