Create Rule
gorgias_create_ruleCreate an automation rule with JavaScript logic and event triggers to automate helpdesk workflows.
Instructions
POST /api/rules — Create a new automation rule with JavaScript logic and event triggers.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The logic of the rule as JavaScript code | |
| name | Yes | The name of the rule | |
| code_ast | No | The logic of the rule as an ESTree AST representation (auto-generated from code if not specified) | |
| priority | No | Order of execution; rules with higher priority values are executed first | |
| description | No | A human-readable description of the rule | |
| event_types | No | Comma-separated list of events that trigger this rule. Allowed values: ticket-created, ticket-updated, ticket-message-created, ticket-assigned, ticket-self-unsnoozed, satisfaction-survey-responded | |
| deactivated_datetime | No | ISO 8601 datetime when the rule was deactivated. Set to null to create the rule as active |