Link Search Menu Expand Document

Shortcuts Actions

iOS macOS

Drafts offers an extensive array of actions to integration with Apple’s Shortcuts app. All Shortcuts actions are available on iOS and iPadOS, as well as Macs running macOS 12 (Monterey) or greater.

NOTE: Some shortcuts actions require a Pro subscription. PRO

Table of Contents

  1. Examples and Tips
    1. Articles
    2. Other Examples Shortcuts
  2. Parameter and Result Objects
    1. Draft
    2. Workspace
    3. Action
    4. Action Group
  3. Shortcut Action Which Open in Drafts
    1. Open Draft
    2. Create Draft with Dictation
    3. Show Capture
    4. Run Action with Text
    5. Run Action on Draft
    6. Load Workspace
    7. Quick Search
  4. Background Shortcut Action
    1. Set Theme
    2. View Draft
    3. Create Draft
    4. Update Draft
    5. File Draft
    6. Get Draft
    7. Get Current Draft
    8. Get Draft by UUID
  5. Querying Drafts
    1. Search Drafts
    2. Get Drafts from Workspace
  6. Other
    1. Markdown to HTML
    2. Process Template

Examples and Tips

Sometimes the best way to get started with automation is by example. We have published a number of articles covering ways Shortcuts an be used with Drafts which you may find interesting.

Articles

Other Examples Shortcuts

  • New Journal Entry in Drafts: Demonstrates how to create a new draft with a template using Shortcuts to pull values about system status and insert them in the text. After creating the template, the shortcuts creates a new draft and opens it in Drafts.
  • Publish Workspace: Prompt to select a Drafts workspace, then get drafts from the inbox of that workspace, and publish them as .md files to a selected folder (requires iOS 15 or macOS 12).

Parameter and Result Objects

Many Shortcuts actions require parameters to specify what objects in Drafts you want to make changes to, or retrieve information about. These parameters take the form of the following objects in Shortcuts:

Draft

Most Drafts’ Shortcut actions return a Draft object, or in the case of query actions, arrays of Draft objects. Each of these objects contains the the following values about the draft:

  • Draft: The primary identifier for the draft. This can be used in subsequent Shortcut actions to identify the draft.
  • UUID string: The UUID of the draft.
  • Content string: The full text of the draft.
  • Link string: A permalink to the draft, using the drafts://open URL action.
  • Title string: The first line of the draft.
  • Tags array of strings: Tags assigned to the draft.
  • Flagged boolean: Flagged status of the draft.
  • Folder: Folder the draft is currently located in. Possible values: Inbox, Archive or Trash.
  • Syntax Definition: Syntax highlighting mode assigned to the draft.
  • Creation Date date: Timestamp of draft creation.
  • Creation Location location: Location the draft was created.
  • Modification Date date: Timestamp of draft’s last modification.
  • Modification Location location: Location the draft was last modified.

Workspace

  • Workspace: The primary identifier for the workspace. This can be used in subsequent Shortcut actions to identify the workspace.
  • Name: The name assigned to the workspace.

Action

  • Action: The primary identifier for the action. This can be used in subsequent Shortcut actions to identify the action.
  • Name: The name assigned to the action.

Action Group

  • Action Group: The primary identifier for the action group. This can be used in subsequent Shortcut actions to identify the action group.
  • Name: The name assigned to the action group.

Shortcut Action Which Open in Drafts

The below actions will open Drafts when used.

Open Draft

Open Draft to a specific draft. Options allow configuration of the Drafts window on opening the draft.

  • Parameters
    • Draft: A valid draft
    • Draft List Hide, Show, No Change
    • Action List Hide, Show, No Change
    • Load Workspace
    • Load Action Group
    • Load Action Bar Group

Create Draft with Dictation

Launch Drafts to dictate a new draft.

  • Parameters
    • Locale string: Locale identifier for the preferred language/country for dictation in the standard format such as en-US (English/US), es-MX (Spanish/Mexico), it-IT (Italian/Itally), etc.

Show Capture

Open a draft capture window, as used in the share extension. This window can be prefilled with text and tags, and can be used to create a draft, or append-prepend to existing drafts.

  • Parameters
    • Content string: The initial text for the capture window.
    • Tags array of strings: Initial tags.

Run Action with Text

Open Drafts and run an action on the specified text.

  • Parameters
    • Action: A valid action.
    • Input string: Text to run the action on.

Run Action on Draft

Open Drafts and run an action on the specified existing draft.

  • Parameters
    • Action: A valid action.
    • Draft: A valid draft

Load Workspace

Open Drafts and load a specific workspace.

  • Parameters
    • Workspace: An existing workspace.

Open Drafts directly to Quick Search.

  • Parameters
    • Query String: Initial value for search.

Background Shortcut Action

The below actions do not require Drafts to open and become the active app.

Set Theme

Update themes and theme mode active in Drafts.

  • Parameters
    • Theme Mode system|light|dark
    • Light theme
    • Dark dark

View Draft

Open a preview of the content of a draft in Siri. Displays without opening Drafts.

  • Parameters
    • Draft: A valid draft

Create Draft

Create a new draft with the parameters provided. Does not require opening Drafts.

  • Parameters
    • Content string: Content of the draft.
    • Tags array of strings: Tags to assign.
    • Folder: The folder to place the draft.
    • Flagged Status: Whether to make the draft flagged.
    • Syntax Definition: Syntax highlighting mode to assign.
  • Returns
    • Draft: Dictionary containing information about the draft created.

Update Draft

Update content or other values of an existing draft.

  • Parameters
    • Draft: A valid draft
    • Content string: Text to prepend to the beginning.
    • Content Update Type:
      • Replace: Replace existing content of the draft with new content.
      • Prepend: Prepend new content to the beginning of the draft.
      • Append: Append new content to the end of the draft.
    • Tags array of strings: Tags to assign.
    • Folder: The folder to place the draft.
    • Flagged Status: Whether to make the draft flagged.
    • Syntax Definition: Syntax highlighting mode to assign.
  • Returns
    • Draft: Dictionary containing information about the draft affected.

File Draft

Update folder or other values of an existing draft without affecting content.

  • Parameters
    • Draft: A valid draft
    • Tags array of strings: Tags to assign.
    • Folder: The folder to place the draft.
    • Flagged Status: Whether to make the draft flagged.
  • Returns
    • Draft: Dictionary containing information about the draft affected.

Get Draft

Get details about an existing draft.

  • Parameters
    • Draft: A valid draft
  • Returns
    • Draft: Dictionary containing information about the draft affected.

Get Current Draft

Get details about the draft currently loaded in the editor.

  • Returns
    • Draft: Dictionary containing information about the draft.

Get Draft by UUID

Get details about an existing draft based on it’s UUID.

  • Parameters
    • UUID: A valid draft UUID.
  • Returns
    • Draft: Dictionary containing information about the draft affected.

Querying Drafts

Search Drafts

Query for drafts matching the specified values.

  • Parameters
    • Search string: Full text search string.
    • Folder: Limit results to only drafts in the specified folder. Values: Inbox, Archive, Trash, All.
    • Tag filter string: Tag filter string specifing tags to include or omit. Should be comma-separate list of tag values, using ! before tags to omit.
    • Flag status: Limit result to only drafts with specified flag status. Options: Flagged, Unflagged, Any.
    • Sort Order: Order to sort results.
    • Sort Descending: If yes, sort in reverse order.
    • Limit: Maximum number of matching results to return.
  • Returns
    • Array of Drafts: Array of Draft Details dictionaries containing information about the matching drafts.

Get Drafts from Workspace

Query for drafts in a specified workspace.

  • Parameters
    • Workspace Identifier: Identifier of an existing workspace in Drafts.
    • Folder: Limit results to only drafts in the specified folder. Values: Inbox, Archive, Trash, All.
  • Returns
    • Array of Drafts: Array of Draft Details dictionaries containing information about the matching drafts.

Other

Markdown to HTML

Convert Markdown text to HTML using Drafts built-in Markdown options.

  • Parameters
    • Content: The Markdown text to convert.
    • Markdown Parser: Choose whether to use MultiMarkdown or GitHub Markdown.
  • Returns
    • Text: The HTML output returned by the Markdown Parser.

Process Template

Pass template text through Drafts’ template engine to process template tags.

  • Parameters
    • Template: The template text.
    • Draft: A draft to use as the context for template processing.
  • Returns
    • Text: The text returned by the template engine.


© 2012-2024 by Agile Tortoise, Inc.
Drafts is a registered Trademark of Agile Tortoise, Inc.
Privacy | Terms

Mastodon