Introduction
This reference is about API version 3. If you are using old sites you cannot use this API to have access to the devices on this sites.
See our 3.0 overview to learn new features.
API Base URL
Use the following base URLs to access this API:
- Enapter Cloud:
https://api.enapter.com/v3 - Enapter Gateway:
http://enapter-gateway.local/api/v3
Authentication
Enapter HTTP API uses API tokens to authenticate requests. The token must be provided for every API request via custom HTTP header X-Enapter-Auth-Token:
$ curl https://api.enapter.com/v3/devices -X GET \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}'
$ curl http://enapter-gateway.local/api/v3/devices -X GET \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}'
Errors
Enapter uses conventional HTTP response codes to indicate success or failure of an API request. Codes in the 2xx range indicate success. Codes in the 4xx range indicate request payload errors. Codes in the 5xx range indicate Enapter servers' errors.
| HTTP Status Code | Explanation |
|---|---|
| 200 — OK | Everything worked as expected. |
| 400 — Bad Request | The request payload has failed parsing or validation. |
| 401 — Unauthorized | Authentication token is missed. |
| 403 — Forbidden | Authentication token is invalid or expired. |
| 404 — Not Found | A non-existent resource is requested. |
| 409 — Conflict | Entity already exists. |
| 422 — Unprocessable Entity | Unable to process the contained instructions. |
| 429 — Too Many Requests | Too many requests hit the API too quickly. |
| 500 — Internal Server Error | Something went wrong on Enapter's end. |
Error Response
Any error response contains at least one error in the body.
{
"errors: [
...
]
}
Error Object
Each error has a common format.
codestringrequired#A short string indicating the reported error code.
messagestringrequired#A human-readable message that provides more details about the error.
detailsobject#Additional error-specific fields.
{
"code": "invalid_header",
"message": "Authentication token is invalid.",
"details": {
"header": "X-Enapter-Auth-Token"
}
}