Skip to main content

Rule Engine API

Rule Engine API provides HTTP API to control engine and its rules.

Gateway only

The Rule Engine API is only available on Gateway 3.x.x.

Create Rule Engine

POST sites/{site_id}/rule_engine

Creates an instance of rule engine on the specified site.

Request

$ curl -X POST \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"suspend": false
}'

Body Parameters

suspendbooleanrequired#

This flag indicates whether the created rule engine should be running or suspended.

Response

Information about created rule engine:

{
"engine": {
"id": "abcdefg0-79f2-4e9e-a6f0-69a310ab110b",
"state": "ACTIVE",
"timezone": "UTC"
}
}
engine.idstring#

Rule Engine ID.

engine.statestring#

Can be ACTIVE or SUSPENDED.

engine.timezonestring#

The time zone is the same as the site's time zone.

Get Rule Engine

GET sites/{site_id}/rule_engine

Returns information about the rule engine on the specified site.

Request

$ curl http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \

Response

Rule engine information:

{
"engine": {
"id": "abcdefg0-79f2-4e9e-a6f0-69a310ab110b",
"state": "ACTIVE",
"timezone": "UTC"
}
}
engine.idstring#

Rule Engine ID.

engine.statestring#

Can be ACTIVE or SUSPENDED.

engine.timezonestring#

The time zone is the same as the site's time zone.

Suspend Rule Engine

POST sites/{site_id}/rule_engine/suspend

Suspends the rule engine on the specified site.

Request

$ curl -X POST \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/suspend \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}'

Response

Rule engine information:

{
"engine": {
"id": "abcdefg0-79f2-4e9e-a6f0-69a310ab110b",
"state": "SUSPENDED",
"timezone": "UTC"
}
}
engine.idstring#

Rule Engine ID.

engine.statestring#

Can be ACTIVE or SUSPENDED.

engine.timezonestring#

The time zone is the same as the site's time zone.

Resume Rule Engine

POST sites/{site_id}/rule_engine/resume

Resumes a previously suspended rule engine on the specified site.

Request

$ curl -X POST \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/resume \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}'

Response

Rule engine information:

{
"engine": {
"id": "abcdefg0-79f2-4e9e-a6f0-69a310ab110b",
"state": "ACTIVE",
"timezone": "UTC"
}
}
engine.idstring#

Rule Engine ID.

engine.statestring#

Can be ACTIVE or SUSPENDED.

engine.timezonestring#

The time zone is the same as the site's time zone.

Create Rule

POST sites/{site_id}/rule_engine/rules

Creates a new rule in the rule engine on the specified site.

Request

$ curl -X POST \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/rules \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"slug": "start-generator-1",
"script": {
"code": "...",
"runtime_version": "V3"
},
"disable": false
}'

Body Parameters

namestringrequired#

The name of the new rule.

scriptobjectrequired#

The object describing rule script.

script.codestring#

Rule script code.

script.runtime_versionstring#

V1 or V3.

Response

Information about the created rule:

{
"rule": {
"id": "qwertyu1-23z4-5x6c-a6f0-69a310ab110b",
"slug": "start-generator-1",
"disabled": false,
"script": {
"code": "...",
"runtime_version": "V3"
},
"state": "STARTED"
}
}
rule.idstring#

Rule ID.

rule.slugstring#

Rule slug.

rule.scriptobject#

Rule script.

rule.disabledboolean#

Indicates whether rule is enabled or disabled.

rule.statestring#

Can be STARTED or STOPPED.

List Rules

GET sites/{site_id}/rule_engine/rules

Returns all rules configured in the rule engine on the specified site.

Request

$ curl http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/rules \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}'

Response

List of rules:

{
"rules": [{
"id": "qwertyu1-23z4-5x6c-a6f0-69a310ab110b",
"slug": "start-generator-1",
"script": {
"code": "...",
"runtime_version": "V3"
},
"disabled": false,
"state": "STARTED"
}]
}

Get Rule

GET sites/{site_id}/rule_engine/rules/{rule_id}

Retrieves information about a specific rule.

Request

$ curl http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/rules/qwertyu1-23z4-5x6c-a6f0-69a310ab110b \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}'

Response

Rule information:

{
"rule": {
"id": "qwertyu1-23z4-5x6c-a6f0-69a310ab110b",
"slug": "start-generator-1",
"disabled": false,
"script": {
"code": "...",
"runtime_version": "V3"
},
"state": "STARTED"
}
}
rule.idstring#

Rule ID.

rule.slugstring#

Rule slug.

rule.scriptobject#

Rule script.

rule.disabledboolean#

Indicates whether rule is enabled or disabled.

rule.statestring#

Can be STARTED or STOPPED.

Update Rule

PATCH sites/{site_id}/rule_engine/rules/{rule_id}

Updates rule. Currently only rule slug can be updated.

Request

$ curl -X PATCH \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/rules/qwertyu1-23z4-5x6c-a6f0-69a310ab110b \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"slug": "start-generator-low-battery"
}'

Body Parameters

slugstring#

The new slug of the rule.

Response

Updated rule:

{
"rule": {
"id": "qwertyu1-23z4-5x6c-a6f0-69a310ab110b",
"slug": "start-generator-low-battery",
"disabled": false,
"script": {
"code": "...",
"runtime_version": "V3"
},
"state": "STARTED"
}
}
rule.idstring#

Rule ID.

rule.slugstring#

Rule slug.

rule.scriptobject#

Rule script.

rule.disabledboolean#

Indicates whether rule is enabled or disabled.

rule.statestring#

Can be STARTED or STOPPED.

Update Rule Script

POST sites/{site_id}/rule_engine/rules/{rule_id}/update_script

Updates only the script of an existing rule.

Request

$ curl -X POST \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/rules/qwertyu1-23z4-5x6c-a6f0-69a310ab110b/update_script \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"new_rule_script": {
"code": "...",
"runtime_version": "V3"
}
}'

Body Parameters

new_rule_scriptobjectrequired#

The new Lua script for the rule.

script.codestring#

Rule script code.

script.runtime_versionstring#

V1 or V3.

Response

Updated rule:

{
"rule": {
"id": "qwertyu1-23z4-5x6c-a6f0-69a310ab110b",
"slug": "start-generator-low-battery",
"disabled": false,
"script": {
"code": "...",
"runtime_version": "V3"
},
"state": "STARTED"
}
}
rule.idstring#

Rule ID.

rule.slugstring#

Rule slug.

rule.scriptobject#

Rule script.

rule.disabledboolean#

Indicates whether rule is enabled or disabled.

rule.statestring#

Can be STARTED or STOPPED.

Disable Rule

POST sites/{site_id}/rule_engine/rules/{rule_id}/disable

Disables a specific rule.

Request

$ curl -X POST \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/rules/qwertyu1-23z4-5x6c-a6f0-69a310ab110b/disable \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}'

Response

Disabled rule:

{
"rule": {
"id": "qwertyu1-23z4-5x6c-a6f0-69a310ab110b",
"slug": "start-generator-low-battery",
"disabled": true,
"script": {
"code": "...",
"runtime_version": "V3"
},
"state": "STARTED"
}
}
rule.idstring#

Rule ID.

rule.slugstring#

Rule slug.

rule.scriptobject#

Rule script.

rule.disabledboolean#

Indicates whether rule is enabled or disabled.

rule.statestring#

Can be STARTED or STOPPED.

Batch Disable Rules

POST sites/{site_id}/rule_engine/rules/batch_disable

Disables multiple rules at once.

Request

$ curl -X POST \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/rules/batch_disable \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"rule_ids": ["qwertyu1-23z4-5x6c-a6f0-69a310ab110b", "dvorakl1-23z4-5x6c-a6f0-69a310ab110b"]
}'

Body Parameters

rule_idsarray of stringsrequired#

List of rule IDs to disable.

Response

Disabled rules:

{
"rules": [
{
"id": "qwertyu1-23z4-5x6c-a6f0-69a310ab110b",
"slug": "start-generator-low-battery",
"disabled": true,
"script": {
"code": "...",
"runtime_version": "V3"
},
"state": "STARTED"
},
{
"id": "dvorakl1-23z4-5x6c-a6f0-69a310ab110b",
"slug": "electrolysers-control",
"disabled": true,
"script": {
"code": "...",
"runtime_version": "V3"
},
"state": "STOPPED"
}
]
}

Enable Rule

POST sites/{site_id}/rule_engine/rules/{rule_id}/enable

Enables a specific rule.

Request

$ curl -X POST \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/rules/dvorakl1-23z4-5x6c-a6f0-69a310ab110b/enable \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}'

Response

Enabled rule:

{
{
"id": "dvorakl1-23z4-5x6c-a6f0-69a310ab110b",
"slug": "electrolysers-control",
"disabled": false,
"script": {
"code": "...",
"runtime_version": "V3"
},
"state": "STOPPED"
}
}
rule.idstring#

Rule ID.

rule.slugstring#

Rule slug.

rule.scriptobject#

Rule script.

rule.disabledboolean#

Indicates whether rule is enabled or disabled.

rule.statestring#

Can be STARTED or STOPPED.

Batch Enable Rules

POST sites/{site_id}/rule_engine/rules/batch_enable

Enables multiple rules at once.

Request

$ curl -X POST \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/rules/batch_enable \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"rule_ids": ["qwertyu1-23z4-5x6c-a6f0-69a310ab110b", "dvorakl1-23z4-5x6c-a6f0-69a310ab110b"]
}'

Body Parameters

rule_idsarray of stringsrequired#

List of rule IDs to enable.

Response

Enabled rules:

{
"rules": [
{
"id": "qwertyu1-23z4-5x6c-a6f0-69a310ab110b",
"slug": "start-generator-low-battery",
"disabled": false,
"script": {
"code": "...",
"runtime_version": "V3"
},
"state": "STARTED"
},
{
"id": "dvorakl1-23z4-5x6c-a6f0-69a310ab110b",
"slug": "electrolysers-control",
"disabled": false,
"script": {
"code": "...",
"runtime_version": "V3"
},
"state": "STOPPED"
}
]
}

Delete Rule

DELETE sites/{site_id}/rule_engine/rules/{rule_id}

Deletes a specific rule.

Request

$ curl -X DELETE \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/rules/qwertyu1-23z4-5x6c-a6f0-69a310ab110b \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}'

Batch Delete Rules

POST sites/{site_id}/rule_engine/rules/batch_delete

Deletes multiple rules at once.

Request

$ curl -X POST \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/rules/batch_delete \ -H'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"rule_ids": ["qwertyu1-23z4-5x6c-a6f0-69a310ab110b", "dvorakl1-23z4-5x6c-a6f0-69a310ab110b"]
}'

Body Parameters

rule_idsarray of stringsrequired#

List of rule IDs to delete.

All Rights Reserved © 2025 Enapter AG.