Shortcuty Studio
Shortcuty Studio

Documentation

Learn Shortcuty Script, from your first shortcut to the full language syntax.

Values and expressions

Shortcuty Script supports these ordinary literal forms:

SourceMeaning
"hello"Text
42, -3, 2.5Integer or real number
true, falseBoolean
nullExplicit null value
["one", "two"]Ordered list
{"name": "Sam", "ready": true}Dictionary
absentOmit an optional action parameter, including an implicit default

Write finite numbers: 1e3 works; 1e999 doesn’t. Put long IDs in quotes so every digit stays intact. Some Apple Shortcuts fields have their own limits. Existing imported data stays unchanged.

Lists and dictionaries may contain variables and nested collections. Dictionary literal keys are fixed text; their values may be expressions. record["key"] reads a fixed key; record[key] accepts a Text key. Use values[1] for the first item or values[index] for a Number index. See Variables and objects for guarded examples. Ordinary names are resolved recursively inside module-action arguments:

For example, data({"title": title, "rows": rows, "enabled": true}) retains those variables and the Boolean.

Use absent to leave out an optional input. null, "", false, [], and {} each supply a value.

A dictionary may use shorthand fields: {name, age} means {"name": name, "age": age}. Shorthand fields may mix with explicit "key": value pairs, and each shorthand name must resolve to a known variable or output.

Dictionaries and JSON requests can contain lists, dictionaries, numbers, true/false, and variables. Apple Shortcuts’ editable fields don’t support JSON null. Leave the key out if that’s what you mean, or send JSON text with web.request(body: ...) if the API requires an explicit null. Imported fields keep their original data.

Text interpolation

Use \(value) to insert a value into quoted text.

message = text("Downloaded \(count) items")

Use literal_text("...") in preservation-oriented code when the characters \( must remain literal instead of becoming an attachment.

Interpolations accept balanced expressions and calls: \(price * qty), \(count(items)), \(name ?? "guest"). Inner string quotes need no escaping. Normal binding and type checks apply.

Dictionary keys inside interpolation retain literal characters such as #, //, and brackets:

shortcut:
  data = {"#greeting": "Hello 👋"}
  result("Message: \(data["#greeting"])")

Special values

The following names refer to values supplied by Shortcuts:

NameApple value
inputShortcut Input / Extension Input
itemRepeat Item inside for item in ...
repeat_indexRepeat Index inside repeat ...
ask()Ask Each Time token in a native parameter

Use quantity(value, unit: "...") for a number with a unit. See Imported workflows for other forms used in imports.

Pipe operator

value |> call(...) feeds the value into a declared positional argument or a uniquely identified content input. For example, photos |> images.make_gif() supplies input: photos, and text_value |> text.trim() supplies input: text_value, not output_name. Some constructors, such as text.make, have an explicit compiler-defined port. When there is no unique supported input, make an ordinary call and name the intended argument. Do not supply the same input twice or mix an action pipe with raw native parameter overrides.

Pipes evaluate left to right: a |> f |> g means g(f(a)) for supported calls. A bare callable is allowed. Pipes bind after arithmetic, comparisons, and ??, before assignment. An ordinary assignment stores the resulting value; an output binding can point directly at the last native producer in a supported chain. See Calling actions.

Operators

Arithmetic supports +, -, *, /, %, **, parentheses, and unary signs. Every operand must be a known, present Number. Text, Booleans, lists, unknown values, and optional numbers need a supported conversion or presence check first; presence alone does not prove Number. / does not truncate. % uses Apple's native Modulus; ** uses native power (x^y). Domain errors, zero divisors, overflow, and negative-remainder behavior belong to Shortcuts; do not assume Python semantics. Compiler/native parameter validation is not execution proof for these operators. 7 // 3 is an error: floor division is unsupported; use # for comments.

shortcut:
  remainder = 7 % 3
  power = 2 ** 3 ** 2
  negative = -2 ** 2
  ready = remainder == 1 and power > 0
  result(ready ? "Ready" : "Not ready")

** associates right: 2 ** 3 ** 2 means 2 ** (3 ** 2). It binds above unary minus: -2 ** 2 means -(2 ** 2); write (-2) ** 2 for a negative base. Negative exponents such as 2 ** -3 are accepted.

and, or, and not operate on Booleans in assignments, calls, returns, collections, interpolation, and conditions. and binds before or; parentheses override grouping. Both sides of and/or evaluate eagerly, once, left to right, matching compound conditions. Earlier variable reads are captured before later calls can change them. Do not use and as a guard for an unsafe call; use an if, guard, or ternary. not count > 0 means not (count > 0); non-Booleans need an explicit comparison.

Precedence, loosest to tightest: ternary ?:, pipe |>, ??, or, and, not, comparisons, +/-, *///%, unary signs, **, postfix access/calls. ??, ?:, and ** associate right; other binary operators associate left. Comparisons (==, !=, <, <=, >, >=) never chain: write low < value and value < high, not low < value < high. Arithmetic binds before comparisons in expressions and headers. A later > or pipe does not turn an earlier < into a generic type argument.

Expressions in headers run before their body; expressions in loops stay inside. Arithmetic emits typed Calculate actions, not text; calculate(left, "+", right) and calculate(expression) remain available. Comparisons produce Booleans through native If actions. Bare if, guard, and ternary conditions require Boolean and test truth, not presence. Literal Boolean conditions may fold.

Choosing a value: null coalescing and fallback

A ternary evaluates only its selected branch. value ?? fallback evaluates its fallback only when needed, using Apple's Has Any Value test, not a dictionary-key-exists test. Zero and false remain present.

shortcut:
  record = {"title": "Report"}
  title = record["title"] ?? "Untitled"
  count = 3
  label = count > 1 ? "items" : "item"
  result("\(title): \(count) \(label)")

Do not use ?? to distinguish success from failure in an error-message field: it handles missing values, not empty-text or status validation. A blank Text item may still be present. Prefer an explicit validated status field; when testing known Text for blank content, use is empty or is not empty. See structured interpreter results.

Continue with Variables and objects or Control flow.