Shortcuty Studio
Shortcuty Studio

Documentation

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

Calling actions

Write an action as module.action(parameter: value). Short forms such as text("Hello") take positional arguments. Use the named arguments in the action reference for module calls.

output = module.action(parameter: value, option: "Choice")
module.side_effect(parameter: output)

Assign the result if a later action needs it. Otherwise, call the action on its own. Use the exact call, argument names, and supported choices. The action reference shows which choices have a short spelling such as .down. Imports use that spelling when it maps to the same saved value.

Core calls

Common actions with short forms:

CallResult or effect
text(value, output_name: "Name")Text action
input(prompt) or ask(prompt)Ask for Input
clipboard()Get Clipboard
list([...], output_name: "Name")List
data({...}, output_name: "Name") or dictionary(...)Dictionary
choose(values)Choose from List
item(values, at: index)Get Item from List
value(dictionary, key: key)Get Dictionary Value; literal or variable text key
count(value)Count
number(value, output_name: "Name")Number
calculate(left, operator, right)Calculate
calculate(expression)Calculate Expression
combine(items, separator: "\n")Combine Text
split(text, by: separator)Split Text
replace(text, find, with: replacement)Replace Text
change_case(text, style: "lower")Change Case
match(text, pattern: expression)Match Text
trim(text)Trim Whitespace
base64(value, mode: "encode", line_breaks: "none")Base64 encode/decode
now()Current Date
format_date(date, style: "short")Format Date
url(text)URL
expand_url(url)Expand URL
random(minimum, maximum)Random Number
alert(message, title: title, cancel: true)Show Alert
result(value) or show(value)Show Result
share(value)Share
preview(value)Quick Look
open_url(url)Open URL
search_web(query)Search Web
speak(text)Speak Text
wait(seconds)Wait
notify(title, body: body, sound: true)Show Notification
comment(text)Comment action
open_app(bundle_identifier, selected_app: {...})Open App
exit()Exit Shortcut

output_name changes the display name stored in the native action. It does not change the source binding on the left side of =.

Quick Look

Use preview(value) or preview.show(item: value) to open Quick Look. If an imported shortcut shows an unknown preview action, replace it with one of these calls and build again.

Native module actions

The Action reference lists each call’s arguments, types, choices, and defaults. Check its authoring status before using an action in a new script. Use blocks such as if and repeat for control flow.

shortcut:
  parking = location.current()
  maps.directions(mode: "Driving", destination: parking)
  result("Directions opened")

Use shortcuts.run_self() to rerun the current shortcut without naming it. An imported script may show name: or identifier: to retain details from the original.

Save a value between runs

Assign to storage["key"] to save a value. The assignment infers its type. Read it with storage.get("key") and use if let when the value might be missing.

shortcut:
  start_page = number(2)
  storage["PDFPageRangeStart"] = start_page
  if let saved = storage.get("PDFPageRangeStart"):
    result(saved + 1)

If the script only reads a key and its type is not known there, specify it, for example storage.get<Number>("PDFPageRangeStart").

HTTP requests

Send only one body: json, form, or body. If you specify body_type, it must match.

shortcut:
  endpoint_text = text("https://example.com/api")
  endpoint = as_type(endpoint_text, "URL")
  access_key = input.ask(prompt: "API key", type: "Text")
  response = web.request(url: endpoint, method: "POST", headers: {"Authorization": access_key}, json: {"input": [{"type": "text", "text": "Hello"}], "options": {"limit": 128}, "store": false})
  show(response)

Literal JSON dictionaries use native editable fields. A complete dictionary variable uses the native File body input and an application/json Content-Type header, matching saved Apple workflows. For that form, header names must be a literal dictionary; their values may be variables. An explicit Content-Type is retained. Raw JSON text, including null, can be produced with text(...) and passed through body: with a Content-Type header. Form and header field values use text tokens.

Continue with Types and optional values for compatibility checks.

Stopping execution

Use flow.stop() or exit() to end the shortcut. Showing a result or an alert does not end it on its own.

Bind the end of a native pipeline

shortcut "Polished Label":
  output original = text("  Draft label  ")
  output polished = original |> text.trim() |> text.change_case(style: "Uppercase")
  result(polished)

The output of each action feeds into the next. polished names the Change Case result without adding a Set Variable step. Use an ordinary assignment if you need to change that value later. If the pipe has no clear input, name the input in an ordinary call instead.

shortcut "Review Task":
  output task = data({title: "Review", status: "draft", lane: "later"})
  output done = task |> data.set_value(key: "status", value: "done") |> data.set_value(key: "lane", value: "now")
  result("\(done["title"]): \(done["status"]) / \(done["lane"])")

Use data({title: "Review"}) or data.dictionary(items: {title: "Review"}) to make a dictionary. Both produce the same native Dictionary fields.

Use list(["North", "South"]) or lists.make(items: ["North", "South"]) to make a list. Both produce the same native List items.

An output binding takes an identifier. Use a plain assignment when the result is reassigned later, or variable("Display name") to read and write an exact named store. Native pipes do not flatten collections, insert a default, or change the order in which arguments are evaluated.

Dictionary lookups and list items

Use record["title"] for a fixed dictionary key. For a key stored in a Text variable, use record[key_name]. To build a key inline, interpolate inside the brackets: record["Round \(round_number)"].

shortcut:
  cartridge_types = {"00": "ROM only", "01": "MBC1"}
  cartridge_code = "01"
  if let description = cartridge_types[cartridge_code]:
    result(description)
  else:
    result("Unknown cartridge type")

Keep codes such as "01" as text so they retain the leading zero. For a key built inline:

shortcut:
  round_number = number(2)
  scores = {"Round 2": 9}
  if let score = scores["Round \(round_number)"]:
    result(score)

Use if let or a guard when a key may be missing. A key you build at runtime may refer to fields with different types.

Use items[1] for the first item and items[2:4] for an inclusive range. For calculated positions, use items[index] or items[first:last] with Number expressions. Positions start at 1, both ends of a range are included, and the brackets do not check bounds for you. Check that each position is a whole number within the list and that the first position is not after the last. With lists.item, use "Item At Index" with index: or "Items in Range" with both endpoints. First, Last and Random Item do not use an index or a range.

shortcut:
  choices = ["First", "Second"]
  selected = item(choices, at: 1)
  result(selected)

Native dotted dictionary paths

record["account.name"] and value(record, key: "account.name") retain Apple's dotted dictionary-path semantics. They do not promise access to a literal top-level key named account.name. Known nested dictionary fields can carry their types; ambiguous dotted-key collisions, list paths and unknown shapes stay conservative. Prefer nested dictionaries with plain keys for new data. Missing values still need presence handling; no runtime schema validation is added.

shortcut:
  record = {account: {count: 3}}
  next_count = record["account.count"] + 1
  first = [10, 20][1]
  show(next_count)
  show(first)

Choosing a file at runtime

Use files.choose(select_multiple: false) to show the native file picker when the shortcut runs. files.pick(file: ...) is a configured File action, not a picker, and requires an explicit file. An empty files.pick() does not prompt the user to choose one.

shortcut:
  selected = files.choose(select_multiple: false)
  preview(selected)

Test picker cancellation and access on your device. Choosing a file does not by itself decode it.

Regex capture groups

text.match finds regex matches; text.match_group(matches: matches, index: 1) retrieves the first parenthesized capture, not the whole match. A match must exist and its regex must define that group. $ is an end anchor with no captures. Capture numbers are independent of list-item indices.

shortcut:
  matches = text.match(input: "print(3 + 4)", pattern: "^print[(](.*)[)]$")
  if matches has value:
    value = text.match_group(matches: matches, index: 1)
    result(value)

Here [(] and [)] match literal parentheses; (.*) is capture 1. These character classes also avoid confusing a literal parenthesis with Shortcuty text interpolation. This extracts text only; it does not evaluate 3 + 4 or implement Python.

Zero-length regex matches

A regex can match successfully and return empty text. For example, ^( )*$ accepts zero leading spaces. Handle empty input separately or match at least one non-whitespace character. See Source indentation.

Interactive HTML

Saving HTML is not playing it. Quick Look or Show Result does not prove JavaScript playback. For a browser-launch request, encode HTML as Base64 without line breaks, construct an explicit data:text/html;charset=utf-8;base64,... URL, then open_url that URL. Device/browser acceptance is unverified by compilation. Read the delivery recipe and limits; do not silently change native-only, offline, or export-only requirements.

Actions that need a device or app

Check the Action reference for arguments, types, and device availability.

  • web.search and maps.search open the corresponding apps. They do not return search results to the shortcut. For a Maps query, put the text in a variable first.
  • safari.run_javascript needs a Safari page from safari.current_page or the share sheet, not a URL or downloaded HTML. The script must call completion(result).
  • shortcuty.open_shortcut opens a Shortcuty listing. It does not install or run the shortcut.
  • The actions.* calls need the Actions app. Color images take hex text, shuffle takes a list of files, and high-resolution timestamps measure elapsed time within a session.
  • Calendar, contact, and app pickers need the corresponding native items, not names or hand-written dictionaries. shell.run is macOS-only. Keep passwords and encryption keys out of shared scripts.

Proportionate text

Keep comments, prompts, labels and routine results brief. Skip filler, obvious comments and repeated status. Use detail when the task needs instructions, stories or accessibility, or the user requests it. Preserve meaning, warnings and existing behavior; no blanket length limit.

Counts and report delivery

Choose the unit explicitly for text analysis: lists.count(input: text_value, count_type: "Characters") counts characters; count_type: "Words" selects words; count_type: "Items" counts list items. The convenience count(value) does not choose a unit from the variable's name. Pass the actual section list to combine([heading, body], separator: "\n\n"); combine([]) deliberately has no sections. Inspect the emitted input when a report is unexpectedly empty.

Keep preview/share actions inside their menu cases. Code after a menu runs after its selected branch, so an unconditional result(report) also runs after a quiet or notification-only choice. For a silent path, save any requested result first, then exit(). Top-level return(value) shows output before stopping; it is not a silent return. Build delivery warnings are static hints, not runtime tests, and intentional empty reports or imported behavior must not be blindly rewritten.

Numeric helper bounds

wait(seconds) takes zero or a positive number of seconds, not true or false. In repeat 3 times:, the count must be a whole number of zero or more. random(minimum, maximum) requires minimum <= maximum when both bounds are known numeric literals; equal bounds are allowed. The legacy random() defaults are 0 and 1, and omitting only the maximum retains its default of 1.

These rules check values written directly in the script. Validate values that come from user input or another action before passing them to wait() or random(). --1 is the number 1; "--1" is text.

Native a-Shell mini files and Instagram sharing

These friendly calls emit native app actions, not a remote shell or server-side sharing. They require the corresponding app on the recipient's device. Inspect get_action for the installed signature before authoring; compilation does not run them or verify app permissions.

shortcut:
  a_shell_mini.put_file(file: input, overwrite: false, show_when_run: false)
  copied = a_shell_mini.get_file(file_name: "report.txt", error_if_not_found: true, copy_file: true, show_when_run: false)
  preview.show(item: copied)

Supply an actual native file as Shortcut Input for this file-transfer pattern. put_file accepts file, optional overwrite and show_when_run; its output type is unverified, so do not rely on it as a success flag. get_file returns a File and accepts file_name, optional error_if_not_found, copy_file and show_when_run. Its name must refer to a file available in a-Shell mini; the example does not create report.txt. a_shell_mini.execute additionally accepts optional Boolean keep_going. Use its current command signature rather than assuming macOS shell.run parameters. The file options are backed by official app intent metadata; runtime behavior still needs device verification.

shortcut:
  instagram.share(input: input, caption: "A moment from today")

Provide media as Shortcut Input. input is required; caption is optional. Test which media Instagram accepts on your device. These calls do not guarantee silent posting or delivery.

HTTP form file fields

A web.request(form: {...}) field containing a known File value, or a final explicit as_type(value, "File") cast, is emitted as a native multipart file field. Mixed text and file fields are supported:

shortcut MultipartExample:
  upload = as_type(input, "File")
  web.request(url: "https://example.invalid/upload", method: "POST", form: {"file": upload, "description": "Example upload"})

This is a compile-only example, not a working upload service. Use a verified destination and authorization before running a shortcut that sends a file.

An inline form: {"file": as_type(input, "File")} also works. Pass the File value directly: interpolating it into text creates a text field instead. Untyped values and nested dictionaries/lists are not automatically promoted to file fields; existing optional-value checks still apply. This rule does not change JSON bodies or headers, and a File cast is not proof that runtime input is available or convertible.

Prefilled alarm times

For a fixed alarm, set time: to a quoted 24-hour time in HH:MM format. Use "06:10" for 6:10 AM or "18:10" for 6:10 PM. You can also use date_components: {hour: 6, minute: 10} instead of time:.

shortcut:
  alarms.create(time: "06:00", name: "Morning")
  alarms.create(time: "06:10", name: "First backup")
  alarms.create(time: "06:30", name: "Second backup")

If a time comes from user input, check its range before using it. A successful build does not guarantee Clock will apply the time. Preview the imported actions and verify the alarms in Clock after a test run. When editing an existing shortcut, keep its working alarm settings unchanged unless you intend to change them.

GIF frames, Finder image conversion, and recognition

  • images.add_gif_frame(gif: animation, frame: photo, delay: 0.25) adds a frame to a GIF. For manual frame sizing, set auto_size: false and pass width: and height:.
  • images.convert_for_finder(images: photos, format: "HEIF", size: "Original", preserve_metadata: true) is the Finder variant on Mac. Use the regular Convert Image action for an iPhone shortcut.
  • music.recognize_song(show_when_run: false, error_if_not_recognized: false) uses Shazam. Handle an unrecognized song separately from an action error.
  • device.get_onscreen_content() takes no arguments. Handle an empty result if the current app does not share content.

Measurements, disk images, and device settings

Create a measurement with a number and unit, then convert it. This example uses the Convert Measurement action’s default destination, feet.

shortcut:
  length = measurements.create(amount: quantity(2, unit: "m"), unit_type: "Length")
  feet = measurements.convert(measurement: length)
  • On Mac, files.make_disk_image(files: input, volume_name: "Archive", size_to_fit: true) creates a disk image from the supplied files.
  • device.set_always_on_display(enabled: false), device.set_announce_notifications(enabled: true), and device.set_silence_unknown_callers(enabled: true) set individual preferences on supported devices. show_when_run: is optional.

Contact photos, calendar duration, and filtering

  • contacts.set_detail(..., photo: image) accepts a selected image or photo variable. Choose the matching contact property in Shortcuts.
  • calendar.set_detail(..., duration: quantity(45, unit: "min")) accepts a duration with a unit. Review the target event before testing changes.
  • calendar.filter_attendees(input: attendees, sort_by: "Name", limit_enabled: true, limit: 5) uses native attendee values, not a list of names.
  • device.get_vpn() reads the VPN value when available. device.filter_vpns(sort_by: "Name") reads and sorts VPN entries. Neither changes the connection.
  • files.label_files(files: selected, color_number: color) is a Finder action. Use a numeric color from a native Label Files action rather than assuming a mapping.

Match options to the selected mode

When you omit a mode but the supplied option makes it clear which one you meant, Check may suggest adding it. It does not change your source until you apply the suggestion. If two options conflict, choose which one to keep.

  • For images.resize(image: photo, width: 1080), the default mode is Size. Use image_resize_key: "Percentage" with image_resize_percentage:, or image_resize_key: "Longest Edge" with image_resize_length:. Don’t mix fields from different modes.
  • Use auto_size: false before supplying manual dimensions to Make GIF or Add Frame to GIF.
  • For lists.insert_item, use position: "Index", index: 2 to insert at the second position. Indices start at 1. Pass a number or a Number variable, not quoted text. Omit index: with "Beginning" or "End".
  • For a Mac disk image, choose a fixed size: or size_to_fit: true, not both.
  • Set date_style: "Custom" before supplying a date pattern, or date_style: "ISO 8601" before using iso8601_include_time:.
  • For a PDF, set pages: "Single Page" with single_page:, or pages: "Page Range" with a first and last page. Number pages from 1.
  • For crop coordinates, set position: "Custom". For a custom media speed, set media_speed: "Custom".
  • For imported Mac audio files, set reencode: true before choosing an encoder other than Default.

Action examples

These examples build and export to native actions. Test device behavior and permissions on your target device.

Rich text, web display, IP addresses and calculations

Convert Markdown to rich text or HTML

Pass a Markdown text value to markdown.rich_text(markdown:). Pass its result to html.from_rich_text(rich_text:) to produce HTML. The optional Boolean full_document controls whether to request a full HTML document. The example requests a fragment.

shortcut "Convert a heading":
  source = text("**Sample**")
  rich = markdown.rich_text(markdown: source)
  html.from_rich_text(rich_text: rich, full_document: false)

Display a web page

web.show(url:) displays the supplied URL when the shortcut runs. The optional Boolean enter_safari_reader requests Reader mode. This compile-only example uses a reserved, non-resolving domain. A URL assembled from variables has a destination that depends on their runtime values.

shortcut "Display a page":
  web.show(url: "https://example.invalid/", enter_safari_reader: false)

Get an IP address

network.ip_address takes two separate choices. Use "Local" or "External" for ip_address_source_option and "IPv4" or "IPv6" for ip_address_type_option. This example requests a local IPv4 address. The value depends on the device and network at runtime.

shortcut "Read a local address":
  network.ip_address(ip_address_source_option: "Local", ip_address_type_option: "IPv4")

Calculate a numeric expression

Pass the expression as text to math.calculate_expression(input:). If you construct that text from variables, the final expression is determined at runtime.

shortcut "Calculate a sum":
  math.calculate_expression(input: "2 + 3")

Support note for Set Uniform Type Identifier

Imported workflows may contain Set Uniform Type Identifier from the Actions app. The app developer’s reference describes a list of files as both input and output. The imported example confirms the file input and type identifier fields, but not whether the installed version returns one file or a list. Preserve the imported action as written; this guide does not provide an authoring example.

Find matches and replace text

Use text.match to find matching text. Use text.replace to produce revised text. For replacement, regex: true treats find as a regular expression. With regex: false, find is literal text. The catalog records false as the default for regex and true for case_sensitive.

shortcut "Normalize a label":
  label = text("Item 42")
  text.match(input: label, pattern: "[0-9]+", case_sensitive: true)
  substitute = text("entry")
  text.replace(input: label, find: "item", replacement: substitute, regex: false, case_sensitive: false, output_name: "Revised label")

Both calls above read the original label. The replacement comes from a text variable; output_name labels the replacement action’s output. To replace runs of digits, use a pattern and turn on regular-expression matching explicitly.

shortcut "Mask a number":
  text.replace(input: "Item 42", find: "[0-9]+", replacement: "N", regex: true, case_sensitive: true)

Call another installed shortcut

Give shortcuts.run the shortcut name as its first positional argument. To supply text as input, bind it to a variable first.

shortcut "Prepare a note":
  note = text("Sample note")
  shortcuts.run("Format Note", input: note)

The exported call asks Shortcuts to resolve the named shortcut on the device. Compiling the caller does not include the called shortcut or verify what it does.

An imported Run Shortcut action can contain a saved picker identifier and a self-reference flag alongside its display name. Keep the imported selection when its identity matters. Replacing it with a name-only call drops that extra selection information. For an intentional call to the current shortcut, use the existing shortcuts.run_self form.

Common action patterns

Pick one or more list items

Use lists.choose when you need more than the simple choose(values) form. Set multiple: true to allow several selections. Pair it with select_all: true to set the native Select All Initially option.

shortcut:
  choices = list(["Review", "Draft", "Send"])
  selected = lists.choose(items: choices, prompt: "Which steps?", multiple: true, select_all: true)
  selection_count = count(selected)
  show(selection_count)

For a fixed position without a prompt, pair specifier: "Item At Index" with index:. The first item is at index 1. Use item_range_start: and item_range_end: with "Items in Range" instead.

shortcut:
  choices = list(["Review", "Draft", "Send"])
  next_step = lists.item(items: choices, specifier: "Item At Index", index: 2)
  show(next_step)

Extract audio from shortcut input

Pass media to media.encode and set audio_only: true. The catalog records "M4A" and "AIFF" as audio format choices. The output can contain multiple media items, so this example passes the result directly to Quick Look rather than assuming a single item. Provide a media item as shortcut input.

shortcut:
  media = as_type(input, "Media")
  audio = media.encode(media: media, audio_only: true, media_audio_format: "AIFF")
  preview(audio)

Create and inspect an archive

archives.create takes the source item in input:. archives.unzip instead takes the resulting archive in archive:. This example takes a file as shortcut input, then counts the extracted items without adding a Save File action.

shortcut:
  file = as_type(input, "File")
  archive = archives.create(input: file, zip_name: "Project")
  items = archives.unzip(archive: archive)
  show(count(items))

Append to the note you just created

Keep the output of notes.create and pass it to notes.append as note:. The text to append goes in input:, not note:. This writes a note; it does not look up a note by title.

shortcut:
  initial = text("Draft checklist")
  note = notes.create(input: initial, name: "Weekend checklist", open_when_run: false)
  extra = text("Pack water")
  notes.append(input: extra, note: note)

Roll a die

Use random(1, 6), or name the bounds with numbers.random(minimum: 1, maximum: 6). The minimum cannot be greater than the maximum. If the bounds come from input, check their order before rolling.

shortcut:
  roll = random(1, 6)
  result(roll)

Round a number or format it as text

Use numbers.round for a numeric result and numbers.format for a display label. Set the place and the rounding direction separately. For a power of ten, use to: "10 ^", ten_to_the_power_of: 2 to round to a multiple of 100. Omit the exponent when choosing a named place like "Hundredths". Pass the original amount to the formatter when its text representation is independent of your rounding rule. Use a whole number for decimal_places:, such as 0 for no decimal places or 2 for two.

shortcut:
  amount = numbers.make(number: 12.364)
  rounded = numbers.round(input: amount, to: "Hundredths", round_mode: .down)
  label = numbers.format(number: amount, decimal_places: 2)

Choose a folder rather than a file

Set picking_mode: "Folders" to ask for a folder. Set select_multiple: false to limit the selection to one; the action still returns picker items rather than a path string.

shortcut:
  folders = files.choose(picking_mode: "Folders", select_multiple: false)

Compare and display a file size

Read the file size with files.detail(file: input, property: .size). Use the numeric byte count in if and format it separately for display. This example compares against 1 MB (1,000,000 bytes). Use unit: "Automatic" to let Shortcuts choose a display unit, or use a fixed unit such as "MB".

shortcut:
  bytes = as_type(files.detail(file: input, property: .size), "Number")
  if bytes >= 1000000:
    output size_text = files.format_size(bytes: bytes, unit: "Automatic", include_units: true)
    result(size_text)
  else:
    result("Under 1 MB")

Get all keys or all values from a dictionary

Use data.keys(input: record) for all keys. For all values, use the "All Values" mode without a key. To look up a single entry, pass key: instead of selecting either collection mode.

shortcut:
  record = {"title": "Field Notes", "edition": 2}
  keys = data.keys(input: record)
  values = data.value(input: record, get_dictionary_value_type: "All Values")

Format an ISO date without a time

Set iso8601_include_time: false with the ISO 8601 date style. Pass a date value, not the already formatted text.

shortcut:
  current = now()
  day = dates.format(date: current, date_style: "ISO 8601", iso8601_include_time: false)
  show(day)

Get response headers without retrieving a response body

Pass a URL value to web.get_headers. Use web.request when you need the response body. The headers call contacts the destination when the shortcut runs.

shortcut:
  target = url("https://example.com")
  headers = web.get_headers(input: target)

Speak an announcement before continuing

Use speech.speak for playback. Set wait: true to have the shortcut wait for the announcement to finish before moving on. Leave language and voice unspecified unless you know the choices available on the target device.

shortcut:
  speech.speak(text: "The report is ready.", wait: true)

Resize an image by percentage or longest edge

These are two different modes, not two ways to specify a width. Choose "Percentage" with image_resize_percentage or "Longest Edge" with image_resize_length. Use "Size" for width and height settings. A separate images.convert action can re-encode the resized image.

shortcut:
  selected = photos.select(multiple: false, media_type: "Images")
  image = lists.item(items: selected, specifier: "First Item")
  scaled = images.resize(image: image, image_resize_key: "Percentage", image_resize_percentage: 50)
  preview.show(item: scaled)

Pick a crop position, image mask or text alignment

Use dot choices, for example images.crop(position: .top_left), images.mask(mask_type: .ellipse), and images.overlay_text(text_alignment: .center), alongside the other arguments for that action. dates.format(time_style: .short) uses the same syntax for time style.

Convert a photo to JPEG

Pick one photo and convert it with images.convert. Set preserve_metadata: false when you don’t want the action to carry over the original metadata. This previews the converted image without saving or sharing it.

shortcut:
  photos = photos.select(multiple: false, media_type: "Images")
  photo = item(photos, at: 1)
  jpeg = images.convert(image: photo, format: "JPEG", quality: 0.75, preserve_metadata: false)
  preview(jpeg)

Extract plain text from a PDF

Set get_text_from_pdf_text_type to "Text" for plain text or "Rich Text" for formatted text. Set combine_pages explicitly when you want the extraction combined instead of page-by-page. This is not a demonstration of OCR on a scanned PDF.

shortcut:
  document = pdf.make(input: "Workshop handout")
  extracted = pdf.extract_text(input: document, combine_pages: true, get_text_from_pdf_text_type: .text)
  preview.show(item: extracted)

Split and rejoin text with custom separators

Use split(text, by: "|") to split at a custom delimiter and combine(items, separator: " / ") to join with one. In the longer text.split and text.combine forms, pair custom_separator: with separator: "Custom".

shortcut:
  labels = text.split(input: "blue|green|yellow", separator: "Custom", custom_separator: "|")
  joined = text.combine(items: labels, separator: "Custom", custom_separator: " / ")
  result(joined)

Summarize several numbers

Use math.statistics for a collection of numbers. For a two-number calculation, use math.operation with the input, operand, and operator.

shortcut:
  durations = [5, 10, 15]
  average = math.statistics(input: durations, statistics_operation: "Average")
  preview.show(item: average)

Inspect device and battery information

device.detail selects one detail by name; device.battery_level uses a separate subject selector. This example requests the system version and numeric battery level explicitly instead of relying on the defaults.

shortcut:
  version = device.detail(name: "System Version")
  battery = device.battery_level(subject: "Battery Level")

Choose photo capture options

device selects the front or back camera. photo_count sets how many images to request. Leave the preview on if the user should see it while taking the photo.

shortcut:
  photo = camera.take_photo(device: "Front", photo_count: 1, camera_capture_show_preview: true)

Build a Maps link

Use maps.link if the result should be a URL you can pass to another step. Use maps.directions instead if the shortcut should open directions. A street address can be passed as text.

shortcut:
  link = maps.link(input: "1 Apple Park Way, Cupertino, CA")

Read the current song title

Choose "Current Song" when the next action needs a song. "Current Playback Time" selects a time interval instead. This example assumes a song is playing.

shortcut:
  song = music.current(subject: "Current Song")
  title = music.properties(input: song, property: "Title")

Create a reminder without an alert

"No Alert" leaves out the alert. Use the separate priority and notes parameters to describe how the reminder should appear. This adds an item to Reminders when run; it does not just build a reminder-shaped value.

shortcut:
  reminder = reminders.create(title: "Water the plants", calendar_item_notes: "Check the soil first.", alert_enabled: "No Alert", priority: "Low")

Extract a URL part or encode text

url.component extracts part of a URL. url.encode encodes or decodes text; pass the value you want encoded rather than encoding a whole URL. Base64 is a separate encoding. Use "None" for its line-break mode if you need a single line.

shortcut:
  link = url("https://example.com/notes")
  host = url.component(url: link, component: "Host")
  term = url.encode(input: "garden notes", mode: "Encode")
  encoded = encoding.base64(input: "garden notes", encode_mode: "Encode", base64_line_break_mode: "None")

Read current weather and request a forecast

weather.current returns current conditions for the default current location. Pass that result to weather.property to select a value. weather.forecast is separate: it returns a list and accepts "Hourly" or "Daily". These actions may require location access and a network connection when run.

shortcut:
  conditions = weather.current()
  temperature = weather.property(weather: conditions, name: "Temperature")
  forecast = weather.forecast(type: "Hourly")

Freeform, Journal, Calculator and Wallpaper

shortcut:
  freeform.create_board(title: "Weekly planning")
  journal.record_audio()
  calculator.open()
  output current_wallpaper = wallpaper.get(kind: .current)
  result(current_wallpaper)

Build up a Freeform board

shortcut:
  output board = freeform.create_board(title: "Weekly planning")
  freeform.add_sticky_note(board: board, text: "Pick three priorities")
  freeform.add_text(board: board, text: "Weekly plan")
  freeform.add_link(board: board, url: "https://example.com")

Pass the actual Board output, not the board title. The link action adds a link to the board; it doesn't ask Studio to fetch that address.

These actions need their respective Apple apps on the device. Journal opens its audio-entry flow. Use .current or .all when reading wallpapers.

For the built-in Shortcuts folder, use location: .shortcuts. Choose .append or .prepend for the file write mode:

shortcut:
  files.append(value: "A new line", location: .shortcuts, path: "Report.txt", new_line: true, append_file_write_mode: .append)

.shortcuts is not the iCloud Drive root. To use a different folder, let the user pick a folder and pass the returned Folder value to a file action that accepts it. Do not guess the serialized location.

Ask for a single line or a number

Use type: "Text" and multiline: false for a short name or label. Leave multiline enabled for a longer answer.

shortcut:
  label = input.ask(prompt: "Name this entry", type: "Text", multiline: false)
  result(label)

For a quantity, use type: "Number" instead of asking for text and converting it. Set a literal numeric default with default: 3 (no quotes). If you turn off decimal or negative numbers, choose a default that follows the same rules. Check the accepted range before using the answer.

shortcut:
  quantity_value = input.ask(prompt: "How many items?", type: "Number", default: 3, ask_action_allows_decimal_numbers: false, ask_action_allows_negative_numbers: false)
  if quantity_value >= 1:
    result(quantity_value)
  else:
    result("Enter at least one item.")