Skip to main content
POST
Create Automation rule

Restrictions

Usage

  • Send 0 for a personal rule. An app key that omits team_id also gets a personal rule. A team rule requires the caller to be a member of that team; account owners and admins get no exemption.
  • A rule’s scope is fixed at creation: Update Automation rule rejects any team_id that differs from the stored value. Create a new rule to run the same task under another scope.
  • cron_expr is required even when only other triggers are used; send a valid expression with schedule_trigger_enabled=false.
  • cron_expr is evaluated in timezone if provided, else the caller’s member timezone, else the account timezone, else Asia/Shanghai.
  • http_post_trigger_enabled=true creates an enabled HTTP POST trigger. http_post_token is returned only in this response; save it. Fire the trigger with POST to http_post_trigger_url and the header Authorization: Bearer <http_post_token>; the optional JSON body {"text": "..."} is limited to 256 KB.
  • If any oncall_incident_* field is sent, both oncall_incident_channel_ids and oncall_incident_severities must be non-empty. Matching incidents start runs with trigger_kind=oncall_incident.
  • If war_room_trigger_enabled=true or war_room_channel_ids is sent, both war_room_channel_ids and war_room_severities must be non-empty. When a war room (IM group chat) is created for a matching incident, the agent runs inside that group chat and the run has trigger_kind=war_room_created.
  • Runs started through the API execute in the web console (execution_place=web_console); run_in=current-chat is accepted only from a live IM conversation with the AI SRE agent and is rejected here.
  • The response is the created rule; can_edit is always true for the creator.
  • Every call is recorded in the account audit log.

Authorizations

app_key
string
query
required

APP Key created in the Flashduty console under My → APP Key. Send it as the app_key query parameter or in the Fd-App-Key request header. Its effective access is the intersection of the key's permission scope and the creator's current role permissions. Keep it secret.

Body

application/json

Create an Automation rule.

name
string
required

Display name of the rule, 1–255 characters; leading and trailing spaces are trimmed.

Required string length: 1 - 255
cron_expr
string
required

Schedule in local time of timezone. Accepts 4 fields (hour day month weekday, minute defaults to 0) or 5 fields (minute hour day month weekday). The minute must be one fixed integer; seconds (6 fields) are not supported; setting both day-of-month and day-of-week is rejected. Required even for rules that use only other triggers: send a valid expression with schedule_trigger_enabled=false.

Example:

"15 9 * * *"

prompt
string
required

Task instruction sent to the AI SRE agent on every run. Must not be empty after trimming spaces.

Minimum string length: 1
team_id
integer<int64> | null

Scope of the rule. 0: a personal rule owned by the caller. >0: a team rule; the caller must be a member of that team. Omitted: a personal rule for an app key; a rule created by the AI SRE agent inherits its session's scope. The scope cannot be changed after creation.

Required range: x >= 0
run_in
enum<string> | null

Where the rule's runs execute. web (default): in a web console session. current-chat: in the IM chat the rule is created from; accepted only from a live IM conversation with the AI SRE agent, so API calls that send it get 400.

Available options:
web,
current-chat,
null
enabled
boolean

Whether the rule's automatic triggers (schedule, HTTP POST, On-call incident, war room) are armed after creation. Defaults to false. Manual runs work either way.

timezone
string

IANA time zone name used to evaluate cron_expr, e.g. Asia/Shanghai. Ambiguous names such as Local, CST, UTC+8, and GMT+8 are rejected. When omitted: the caller's member time zone, then the account time zone, then Asia/Shanghai.

schedule_trigger_enabled
boolean | null

Whether the schedule trigger is enabled. Defaults to true when omitted; send false for rules that should fire only from other triggers.

environment_kind
enum<string>

Runtime environment kind. Omit or send an empty value for automatic selection. One of: cloud (platform-hosted cloud sandbox), byoc (a self-hosted BYOC runner in the account, used with environment_id); automatic selection prefers an online BYOC runner and falls back to the cloud sandbox.

Available options:
,
cloud,
byoc
environment_id
string

BYOC runner ID. Required when environment_kind=byoc and rejected for other kinds. A personal rule can only use account-scope runners; a team rule can use account-scope runners or runners of its own team.

http_post_trigger_enabled
boolean

Whether to create an enabled HTTP POST trigger. When true, the response carries http_post_trigger_url and the one-time http_post_token.

oncall_incident_trigger_enabled
boolean

Whether the On-call incident trigger is enabled. When the trigger is created (this is true, or channel IDs or severities are sent), both oncall_incident_channel_ids and oncall_incident_severities must be non-empty.

oncall_incident_channel_ids
integer<int64>[]

Channel IDs to watch; incidents in these channels can start a run. Each ID must be positive.

Required range: x >= 1
oncall_incident_severities
enum<string>[]

Incident severities to watch: Critical (most severe), Warning, or Info (least severe) — the On-call incident severity levels.

Available options:
Critical,
Warning,
Info
oncall_incident_merge_similar
boolean | null

Whether to merge similar incidents into one analysis. When true (default), an incident that closely resembles one already being analyzed by this rule (a run in progress or finished within the last 10 minutes) joins that run's session instead of starting a new one; its own run is recorded as skipped with joined_session_id set. When false, every matching incident starts its own run.

war_room_trigger_enabled
boolean

Whether the war room trigger is enabled. It fires when a war room (IM group chat) is created for an incident in one of war_room_channel_ids with a severity in war_room_severities; the agent then runs inside that group chat. When the trigger is created (this is true, or war_room_channel_ids is sent), both lists must be non-empty.

war_room_channel_ids
integer<int64>[]

Channel IDs whose war rooms start a run. Each ID must be positive.

Required range: x >= 1
war_room_severities
enum<string>[]

Incident severities that start a run when their war room is created: Critical (most severe), Warning, or Info (least severe) — the On-call incident severity levels.

Available options:
Critical,
Warning,
Info

Response

Success

Standard response envelope used by every Flashduty public API. On success data contains the endpoint-specific payload and error is absent. On failure error is present and data is absent. request_id is always present and is also mirrored in the Flashcat-Request-Id response header.

request_id
string
required

Unique ID for this request. Mirrored in the Flashcat-Request-Id header. Include it when reporting issues.

Example:

"01HK8XQE3Z7JM2NTFQ5YJ8P9R4"

error
object

Error payload inside the response envelope. Present only on non-2xx responses.

data
object

Automation rule.