Create server rules
Create automation rules on the Rules tab, which we store but do not run yet.
In the dashboard
The Rules tab holds a server's automation rules. A rule names a trigger, optional conditions and the actions to take, each written as JSON.
Warning
We do not run rules yet. A rule you create is saved, but nothing triggers it, so it never restarts the server or sends a command. To run a command, a power action or a snapshot at set times, use a schedule.
Before you begin
Section titled Before you begin- On a server someone shared with you, the owner must have given you the Manage rules permission.
- The rule's fields take JSON. Put names and text in double quotes, for example
{"type": "power", "action": "restart"}.
Create a rule
Section titled Create a rule- In the dashboard, go to Container Apps and open the server, then the Rules tab.
- Select New rule….
- In Name, enter a name, for example
Restart on crash. - Under Trigger, choose what the rule reacts to: Manual, Scheduled, Event, Crash or Resource threshold.
- In Trigger config, enter the trigger's settings as JSON, or leave
{}. - In Conditions, enter what must be true for the rule to act, or leave
{}for none. - In Actions, enter what the rule does.
- Leave Enabled ticked to switch the rule on, or clear it to save it switched off.
- Select Create rule.
Rule format
Section titled Rule formatWe store each field as you enter it and check only that it is JSON. Actions takes one action, or a list of them:
| Action | Example |
|---|---|
| Run a console command | {"type": "command", "command": "say Restarting in 5 minutes"} |
| Send a power signal | {"type": "power", "action": "restart"} with start, stop, restart or kill |
Conditions can limit a rule to a window of hours in UTC, for example {"type": "time_window", "start_hour": 2, "end_hour": 5} for 02:00 to 05:59.
Turn a rule off or delete it
Section titled Turn a rule off or delete it- To turn a rule off or on, use the switch in its Enabled column.
- To delete a rule, select the bin icon at the end of its row, then Delete rule.
Result
Section titled ResultThe dashboard confirms a new rule with Rule created.. The list shows each rule's name, its Trigger, when you created it and whether it is enabled. Under the name, a rule that has never acted reads Never fired, which is what every rule shows while we do not run them.
Troubleshooting
Section titled Troubleshootingthe Actions field is not valid JSON.- The field it names holds something other than JSON. Check the brackets and put every name and text value in double quotes.
Could not update the ruleorCould not delete the rule- Turning a rule off and deleting a rule fail with a server error at the moment. A rule has no effect while we do not run rules, so leaving it in place does no harm. Contact support if you need it removed.
Insufficient permissions- On a server someone shared with you, ask the owner for the Manage rules permission.
Related
Section titled Related- Schedule server tasks runs commands, power actions and snapshots at set times.
- Share a server with other users explains the Manage rules permission.
With the API
Section titled With the APICreate a rule with POST /api/v1/client/servers/{uuid}/rules. The body takes name, trigger_type (the dashboard offers manual, scheduled, event, crash and resource), trigger_config (an object, default {}), conditions (an object, a list or null), actions (an object or a list) and enabled (default true):
curl -X POST https://api.coritan.com/api/v1/client/servers/$SERVER/rules \
-H "Authorization: Bearer $CORITAN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "Restart on crash", "trigger_type": "crash", "actions": [{"type": "power", "action": "restart"}]}'
The response (201) is the rule, with uuid, name, trigger_type, trigger_config, conditions, actions, enabled, created_at, updated_at and last_triggered_at, which stays null while we do not run rules.
| Route | What it does |
|---|---|
GET /api/v1/client/servers/{uuid}/rules |
Lists the server's rules, oldest first. |
PUT /api/v1/client/servers/{uuid}/rules/{rule_uuid} |
Changes the fields you send. It answers 500 at the moment. |
DELETE /api/v1/client/servers/{uuid}/rules/{rule_uuid} |
Deletes the rule. It answers 500 at the moment. |
Creating, changing and deleting need settings.automation. Any user on the server can list its rules.
API operations on this page
| Method | Path | What it does |
|---|---|---|
GET | /api/v1/client/servers/{uuid}/rules | List rules for a server |
POST | /api/v1/client/servers/{uuid}/rules | Create a new rule |
PUT | /api/v1/client/servers/{uuid}/rules/{rule_uuid} | Update a rule |
DELETE | /api/v1/client/servers/{uuid}/rules/{rule_uuid} | Delete a rule |