Automation JSON format v1
Write a version 1 automation definition and its wire fields.
Use a bare definition or an export envelope: schema: "pocket-station/automation-ast", ast_version, name, and ast (definition). See import and export for file transfer.
Definition and nodes
Required: type: "definition", ast_version: 1, nonempty name, trigger, and ordered blocks. Optional params declares inputs with nonempty name and type strings. Unknown fields are rejected on definitions, triggers, input declarations, and nodes.
Every node needs type; nested arrays contain nodes.
| Type | Required fields | Optional |
|---|---|---|
action | kind | params, bind_output |
if_else | condition_cel, then, else (include empty arrays) | None |
repeat | count_expr (positive integer string), body | None |
foreach | list_expr (CEL list), item_var, body | None |
wait | duration_expr: "duration('30s')" or "30" (seconds) | None |
stop | Nonempty reason | None |
For Each accepts lists of bool, int, uint, double, string, or bytes, such as
claimable_mission_ids; lists of messages, maps, or lists aren't supported.
For bind_output result types, bind_output/item_var names, and account fields, see Conditions. Branch/loop bindings stay inside that body. See Blocks for runtime behavior.
Triggers
| Type | Fields |
|---|---|
manual, booster_stamina_available | None |
interval | every: whole hours, minimum "1h" |
daily | at: zero-padded 24-hour time; timezone: "UTC" or Area/City |
Fixed-offset timezones aren't accepted. See Triggers for scheduling behavior.
Action parameters
Values can be direct literals, {"literal": value}, {"param_ref": "input_name"}, or {"expression": "CEL"}. Wrappers contain exactly one key. Input references require a declared, type-compatible input. The app installer can't supply inputs for param_ref.
Top-level {"expression": "CEL"} wrappers are allowed only for add_friend.target, approve_friend_request.sender_player_id, and remove_friend.player_id. Other parameters accept literals or compatible input references unless marked literal below. For example, wonder_pick.send_thank_reward accepts a boolean input reference.
Within a payload object, a key ending in _expr evaluates its string value as CEL and drops the suffix from the resulting key.
Action kind must be one of:
| Kind | Parameters |
|---|---|
add_friend | Required string target (player ID/friend code) |
approve_friend_request | Required string sender_player_id |
remove_friend | Required string player_id |
claim_reward_inbox, complete_missions, like_all_friend_showcases, refresh | None |
complete_tutorials | Optional request_json: JSON object or JSON text, not base64; omitted uses defaults |
open_booster | Required strings selection_mode, quantity_mode; conditional strings pack_id, product_id, integer count |
run_battles | Required string section; optional booleans use_event_hourglass, continue_on_error, integer max_tasks, string empty_policy |
wonder_pick | Required string selection_mode; optional booleans send_thank_reward, continue_on_error |
continue_on_error: true records ordinary Wonder Pick failures and failed battle results while continuing. Battle setup/submission failures and budget/plan restrictions still stop execution.
Booster modes
Literal selection_mode: specific_pack, latest_available, most_missing, random_available. Only specific_pack needs nonempty literal pack_id and product_id; otherwise omit both.
Literal quantity_mode: all_current_stamina, all_current_hourglasses, specific_count, specific_hourglasses. Only specific_ modes need positive integer literal count; otherwise omit it.
Battle and Wonder Pick modes
Battle section is a literal: stepup, event, random, all. Only event accepts use_event_hourglass. Only all accepts max_tasks and requires literal max_tasks: 1, empty_policy: "skip"; it still skips a battle when less than six minutes of the run remain. Otherwise, literal empty_policy accepts error (default) or skip.
{
"type": "action",
"kind": "run_battles",
"params": { "section": "all", "max_tasks": 1, "empty_policy": "skip" }
}Wonder Pick selection_mode is a literal: most_missing, rarest_missing, cheapest_useful, random, random_any.
Validation and runtime limits
| Limit | Maximum |
|---|---|
| Submitted definition | 262,144 bytes |
| Nesting depth | 16 |
| Total nodes / entries per block array | 500 each |
Counted CEL expressions / combined bytes (excludes _expr aliases inside payloads) | 1,000 / 65,536 |
| Pre-run loop iterations / expanded actions / repeat count | 100 each |
| Single wait | 1 hour (save-time validation); must fit in remaining run time |
| Total run time | 10 minutes |
Size applies to the definition submitted by Save, excluding the envelope. Each foreach counts as 100 iterations before execution. repeat.count_expr accepts no expressions. Waits need at least one second; exceeding the remaining run time fails the step.
Complete definition
{
"type": "definition",
"ast_version": 1,
"name": "Claim inbox",
"trigger": { "type": "manual" },
"blocks": [{ "type": "action", "kind": "claim_reward_inbox" }]
}