Skip to content
Coritan Docs

Create server rules

Create automation rules on the Rules tab, which we store but do not run yet.

View as Markdown

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.

  • 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"}.
  1. In the dashboard, go to Container Apps and open the server, then the Rules tab.
  2. Select New rule….
  3. In Name, enter a name, for example Restart on crash.
  4. Under Trigger, choose what the rule reacts to: Manual, Scheduled, Event, Crash or Resource threshold.
  5. In Trigger config, enter the trigger's settings as JSON, or leave {}.
  6. In Conditions, enter what must be true for the rule to act, or leave {} for none.
  7. In Actions, enter what the rule does.
  8. Leave Enabled ticked to switch the rule on, or clear it to save it switched off.
  9. Select Create rule.

We 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.

  • 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.

The 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.

the 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 rule or Could 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.

Create 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):

Shell
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

MethodPathWhat it does
GET/api/v1/client/servers/{uuid}/rulesList rules for a server
POST/api/v1/client/servers/{uuid}/rulesCreate 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