Skip to main content

AppleScript Automation

Use AppleScript to find and update tasks, create projects and checklists, and organize tasks into sections in 2Do for Mac. Scripts can also complete, duplicate, move, or delete tasks; pause tags; and open tasks or lists in the app.

AppleScript and the Claude MCP extension use the same snake_case command names, argument keys, and validation rules. For workflows in the Shortcuts app, see the available Shortcuts actions.

note

This is a strict API. AppleScript exposes only the documented command terms, and each command takes one optional arguments parameter. Unknown command names, unknown argument keys, and unknown enum values fail instead of being normalized. There are no aliases or alternate parameter names.

Privacy and passwords

AppleScript follows the Mac app's current unlocked session. Unlock 2Do before running a script. A locked app returns access_denied; password-protected lists that are still locked are hidden and their tasks cannot be read or changed. 2Do checks the lock state again immediately before every write.

tip

Use command and argument names exactly as documented.

Getting Started​

Open Script Editor from Applications > Utilities, then choose File > Open Dictionary... > 2Do to see the 2Do Automation Suite.

Every automation command is called inside a tell application "2Do" block:

tell application "2Do"
set listsResult to list_lists given arguments:{include_archived:false}
set firstList to item 1 of lists of listsResult

set createdResult to create_task given arguments:{list_id:(list_id of firstList), title:"Review project plan", due_date:"2026-07-02", due_time:"17:00", priority:"high"}
set createdTask to task of createdResult

open_task given arguments:{task_id:(task_id of createdTask)}
end tell

You can also run scripts from Terminal:

osascript -e 'tell application "2Do" to list_lists'

Identifiers​

Read identifiers from discovery, query, or create responses and pass them back to later commands. Do not construct IDs from titles.

Moving a task can give it a new ID. After move_task, use the task_id in the returned task record. For a batch, read task_id from each record in the returned tasks array. These records follow the same order as the request's task_ids. If an ID changes, calls using the old ID return not_found. After move_section, query the section again to get its tasks' current IDs.

IdentifierUsed for
task_idTasks, projects, checklists, and sub-tasks.
attachment_idAn attachment returned by list_attachments. Always supply its owning task_id too.
list_idNormal 2Do lists.
section_idA saved section in a normal list. The ID stays the same when the section moves to another list.
list_group_idList Groups. query_tasks can use this to query the group's dynamic Smart Filter.
smart_list_idSaved Smart Lists.
tag_idTags.
tag_group_idTag Groups.
location_idLocations.
collection_idNamespaced collection identity emitted on lists, List Groups, and Smart Lists: focus:<name>, list:<uid>, list-group:<uid>, or smart-list:<uid>.
destination_idNamespaced task-creation destination: list:<uid> or parent-task:<uid>.
alarm_idStable identity on returned alarm records.
tip

Always pass type-specific identifiers such as task_id and list_id; there is no generic id field.

Commands​

The tables below list the canonical AppleScript and MCP command names. All commands return a record. Collection commands include both the collection and item_count. Task mutation commands return the updated task record.

Discovery​

CommandArgumentsReturns
list_listsOptional include_archived boolean.lists, item_count.
list_sectionsRequired list_id.sections in manual order, item_count.
list_list_groupsNone.list_groups, item_count.
list_smart_listsNone.smart_lists, item_count.
list_tagsOptional tag_group_id.tags, item_count. Tags include paused.
list_tag_groupsNone.tag_groups, item_count.
list_locationsNone.locations, item_count.
get_default_task_destinationNone.destination: the list new tasks go to by default, with destination_id, list_id, and title. Password-aware: it uses the same destination logic as task creation, so it always returns an editable normal list.

smart_search contains the Smart List's saved text query. It does not describe all of the list's settings. has_additional_filters is true when the list also has a saved date filter, searches a specific list, ignores start dates when filtering by date, or has Focus Mode turned on. Phonetic matching is part of the text search and does not set this flag.

For example, a Smart List for the next three days can return smart_search:"*" with has_additional_filters:true. Call query_tasks with the list's smart_list_id to get matching tasks.

Older app versions may not return has_additional_filters. If the field is missing, do not assume that the list has no additional filters.

Sorting and Focus Mode​

Read or change how tasks are sorted in a list, project, or checklist, and turn a list's Focus Mode on or off. Your 2Do build must include get_list_settings and update_list_settings in its scripting dictionary. MCP clients also need extension version 0.3.0 or later.

CommandArgumentsReturns
get_list_settingsExactly one of list_id, smart_list_id, or focus.The target identifier, sorting, and focus_enabled.
update_list_settingsExactly one of list_id, smart_list_id, or focus, plus sorting, focus_enabled, or both.The target identifier and its updated sorting and focus_enabled.

Use list_lists or list_smart_lists to find a list's ID. For a built-in Focus List, focus accepts all, today, starred, scheduled, or done. These commands do not accept a List Group, section, or project ID.

This example reads Today's current settings, then sorts it by due date and turns on Focus Mode:

tell application "2Do"
set currentSettings to get_list_settings given arguments:{focus:"today"}
update_list_settings given arguments:{focus:"today", sorting:{field:"due_date", direction:"ascending"}, focus_enabled:true}
end tell

Set focus_enabled to true or false to enable or disable the list's existing Focus Filter. This leaves its conditions unchanged. Done does not accept Focus Mode updates. Accessible lists allow these view changes even when their task content is read-only; changing a project's or checklist's sorting still requires permission to edit that task.

Projects and Checklists​

Project and checklist records include sorting. Use get_task with the parent's task_id to read it, or pass sorting to create_task or update_task to set it. The task must be a project or checklist after the command. You can therefore set task_type and sorting together when converting a normal task.

This example creates a project in your default task list, sorted by title, then changes it to manual sorting:

tell application "2Do"
set destinationResult to get_default_task_destination
set targetListID to list_id of destination of destinationResult
set createdResult to create_task given arguments:{list_id:targetListID, title:"Course lessons", task_type:"project", sorting:{field:"title", direction:"ascending"}}
set projectID to task_id of task of createdResult
update_task given arguments:{task_id:projectID, sorting:{field:"manual", direction:"ascending"}}
end tell

An explicit sorting value takes precedence over Default Sorting preferences during creation or conversion. Omit it to use the preference when creating a project or checklist or converting a normal task. Omitting it when updating an existing project or checklist leaves its sorting unchanged, subject to the supported fields when converting between types.

Normal tasks and child records inside subtasks do not accept sorting. If create_task includes subtasks without a task_type, 2Do creates a project and accepts sorting on that parent.

Sorting Fields​

Every sorting record requires a field and a direction. Direction is ascending or descending.

TargetAccepted field values
Normal lists, Smart Lists, Focus Lists other than Done, and projectsstatus, priority, list, start_date, due_date, creation_date, modification_date, notes, title, manual, tags, locations, duration.
Checklistsstatus, priority, creation_date, modification_date, notes, title, manual, tags, locations, duration.
Donepriority, list, completion_date, notes, title.

Manual sorting keeps the saved positions regardless of direction. Completion sorting keeps the most recently completed tasks first regardless of direction. Reads can also return saved fields such as url or separated that are not accepted for new sorting choices.

The sort argument on query_tasks and list_subtasks only orders that command's results. Its field names also differ from sorting; see Reading Tasks. To change the saved view in 2Do, use sorting.

Each settings change is one Edit > Undo step. An update that leaves the settings unchanged adds no undo step.

Sections​

Sections group top-level tasks within a normal list. Create a section, then use its returned section_id to create tasks in it, move tasks into it, or query its members. Section titles do not have to be unique.

CommandArgumentsReturns
create_sectionRequired list_id, title; optional description.section.
move_sectionRequired section_id and destination list_id.section.
reorder_sectionsRequired list_id and a section_ids list containing every section ID once, in the desired order.sections, item_count.

This example creates a section and a task in the first available list:

tell application "2Do"
set listsResult to list_lists
set targetListID to list_id of item 1 of lists of listsResult
set createdSection to create_section given arguments:{list_id:targetListID, title:"Planning", description:"Ideas to develop"}
set sectionID to section_id of section of createdSection
create_task given arguments:{section_id:sectionID, title:"Draft proposal"}
query_tasks given arguments:{section_id:sectionID, paused_filter:"include", include_completed:true}
end tell

Pass section_id as the only destination to create_task or move_task; do not also pass list_id or parent_task_id. Moving a project or checklist keeps its children together. Moving a sub-task into a section makes it a top-level task.

For a top-level task staying in its current list, update_task accepts a section ID from that list. Use section_id:missing value to remove the task from its section, or omit the field to keep its membership. Moving a task to its current list_id also keeps its section. Use move_task to assign it to a section in another list.

Before calling reorder_sections, read list_sections and arrange all returned section IDs in the desired order. Incomplete orders, duplicates, and sections from other lists are rejected. The unsectioned area and Done area are not sections in this array. Reordering leaves task membership and sorting unchanged.

move_section places the heading after the destination list's existing sections and moves all its tasks, including completed and paused tasks and project or checklist children. The section keeps its ID, title, and description. Query it again for current task IDs after the move. Repeating the command with the same destination makes no change.

Each section change is one Edit > Undo step in 2Do. Undoing a section move restores the heading and its tasks together.

Reading Tasks​

CommandArgumentsReturns
get_taskRequired task_id.task.
query_tasksOptional target section_id, list_id, list_group_id, smart_list_id, or focus; optional search, due/start date windows, paused_filter, sort, offset, limit, include_completed (default: true).tasks, item_count, total_count.
list_subtasksRequired task_id; optional paused_filter, sort, include_completed (default: true).tasks, item_count, parent_task_id.
selected_tasksNone.tasks, item_count. Requires the Mac app UI.

query_tasks accepts at most one target identifier. A section query returns top-level members; use list_subtasks to read their children. When no target is supplied, 2Do queries the built-in All focus scope. focus accepts all, today, starred, scheduled, or done. Passing a list_group_id queries the same dynamic List Group task view shown when you click a List Group in the Mac sidebar. search must contain 1 through 256 characters and matches literal text only: a case-insensitive and diacritic-insensitive substring of title, notes, current tag titles, and current location titles, with no query-operator or boolean syntax. Date windows use inclusive yyyy-MM-dd fields: due_on_or_after, due_on_or_before, start_on_or_after, and start_on_or_before; tasks without the corresponding date never match a window. offset must be zero or greater. Because offset is an AppleScript command, write its record label as |offset| in AppleScript source. limit must be 1 or greater. total_count counts all matching tasks before offset/limit; item_count counts the returned tasks.

paused_filter values:

ValueBehavior
hideDefault. Hide tasks paused by a paused tag.
includeInclude paused and unpaused tasks.
onlyReturn only tasks paused by a paused tag.
tip

Query with paused_filter:"include" when you want Claude or a script to reason about hidden paused-tag work.

sort is an object with:

KeyValues
fieldtitle, due_date, start_date, priority, duration_seconds, created, modified, completed.
directionOptional. ascending or descending. Default: ascending.

Example:

tell application "2Do"
set groupsResult to list_list_groups
set groupRecord to item 1 of list_groups of groupsResult

set tasksResult to query_tasks given arguments:{list_group_id:(list_group_id of groupRecord), search:"invoice", paused_filter:"include", sort:{field:"due_date", direction:"ascending"}, |offset|:0, limit:20}
set starredResult to query_tasks given arguments:{focus:"starred", search:"invoice", |offset|:0, limit:20}
end tell
tip

Use list_subtasks with a returned task_id to inspect a project or checklist before modifying its children.

Attachments and Voice Notes​

Read images and audio attached to a task, or get the text of a voice note without changing the task. These commands require 2Do for Mac 2026.4.7 or later. MCP clients also need extension version 0.4.0 or later.

CommandArgumentsReturns
list_attachmentsRequired task_id.attachments, item_count.
read_attachmentRequired task_id, attachment_id.attachment, mime_type, byte_count, data_base64.
transcribe_attachmentRequired task_id, attachment_id.task_id, attachment_id, transcript.

In AppleScript source, read these fields as |attachments| and |attachment|, for example |attachment| of readResult. The bars distinguish record labels from the attachment class in 2Do's dictionary. JSON clients use the unescaped field names.

Start by listing the attachments of a task whose ID you obtained from get_task, query_tasks, or selected_tasks:

tell application "2Do"
set attachmentsResult to list_attachments given arguments:{task_id:"task-uid"}
return |attachments| of attachmentsResult
end tell

The result lists active attachments in saved order. Each record has attachment_id, task_id, kind, file_size_bytes, and available. Optional fields include display_name, duration_seconds, and link_url. Kinds are image, audio, document, video, other, link, or unknown. Deleted attachments are omitted. Missing local files remain listed with available:false; links have no local file and are never followed.

read_attachment supports audio and image files up to 8 MiB. In AppleScript, data_base64 holds the complete file as a base64 string. mime_type describes the returned file, including CAF audio for Mac recordings. byte_count is the actual number of bytes; the file_size_bytes metadata may be older. MCP returns the same media in a native image or audio block, with the metadata in its text and structured result, rather than repeating base64 in the text.

For a voice note, choose an audio attachment_id from the list and request a transcript. Allow extra time for the first request, which may download Apple's speech model:

with timeout of 600 seconds
tell application "2Do"
set transcriptResult to transcribe_attachment given arguments:{task_id:"task-uid", attachment_id:"attachment-uid"}
return transcript of transcriptResult
end tell
end timeout

Transcription runs on the Mac using its current language. It requires macOS 26 or later, supported hardware and a supported language, and a locally available recording no larger than 64 MiB. It returns only the completed transcript and reports an error if no speech is recognized or recognition fails. It does not save text to notes; use update_task if you want to save it.

Both IDs must belong together. The app and list must be unlocked, and 2Do checks access again before returning a transcript. These commands do not fetch missing files or change attachment metadata. An unavailable or oversized file produces an error, never partial media. For MCP data handling, see Privacy and Security.

Writing Tasks​

CommandArgumentsReturns
create_taskRequired title and exactly one of list_id, section_id, or parent_task_id; optional task_type, subtasks, sorting, and task write fields.task, and subtasks when supplied.
update_taskRequired task_id; optional task_type, section_id, sorting, and task write fields.task.
update_task_actionRequired task_id, action.task.
delete_taskExactly one of task_id or task_ids; optional recursive boolean. Default: true.Single: task_id, deleted; batch: task_ids, deleted, item_count.
duplicate_taskRequired task_id.task.
move_taskExactly one of task_id or task_ids; exactly one of list_id, section_id, or parent_task_id.Single: task; batch: tasks, item_count.
complete_taskExactly one of task_id or task_ids; optional recursive boolean. Default: true.Single: task; batch: tasks, item_count.
uncomplete_taskExactly one of task_id or task_ids; optional recursive boolean (default: true); optional update_parent boolean (default: false, requires recursive: true) to reconcile a completed parent after uncompleting a child.Single: task; batch: tasks, item_count.

task_type values are normal, project, and checklist.

Creating a task with parent_task_id creates a sub-task. If the parent is a normal task, 2Do converts it to a project before adding the child. subtasks is accepted only with list_id or section_id; it must contain 1 through 100 child records, and each child requires a non-empty title. Project children may have their own dates, priorities, tags, locations, alarms, recurrence, and actions. Child records cannot include section_id, other destinations, task_type, sorting, or nested subtasks. Checklist children cannot set due/start fields, duration, recurrence, or relative alarms because they inherit scheduling from the checklist; absolute sound alarms remain supported. task_ids batches are capped at 100 unique task IDs and are validated before any task is changed.

Completing a recurring task advances it to its next occurrence. Repeating the same complete_task call advances it again, so scripts must not retry recurring completion as an idempotent operation.

Task write fields:

FieldTypeNotes
titleStringRequired for create_task; optional for update_task.
notesStringReplaces notes. Use an empty string to clear notes; omit the field to leave notes unchanged.
starredBooleanReplaces the starred state.
sortingRecordRequired field and direction. Applies only to projects and checklists. See Sorting and Focus Mode.
section_idString or missing valueIn update_task, assign a top-level task to a section in its current list, or clear its membership. See Sections.
due_dateString or missing valueyyyy-MM-dd. missing value clears the due date and due time.
due_timeString or missing valueHH:mm. Requires a due date.
start_dateString or missing valueyyyy-MM-dd.
start_timeString or missing valueHH:mm. Requires a start date.
duration_secondsIntegerMust be from 0 through 2147483647.
priorityStringnone, low, medium, or high.
tag_updateRecordSee Tags and Locations.
location_updateRecordSee Tags and Locations.
alarmsListOmitted means unchanged. Empty list clears. Non-empty list replaces all sound alarms. A task may have at most 10 total alarms.
recurrenceRecordOmitted means unchanged. {frequency:"none"} clears.
actionRecordReplaces the task action.

Example:

tell application "2Do"
set listsResult to list_lists
set inboxList to item 1 of lists of listsResult

set created to create_task given arguments:{list_id:(list_id of inboxList), title:"Call printer repair", starred:true, notes:"Ask for warranty status", due_date:"2026-07-03", due_time:"09:30", duration_seconds:1800, priority:"medium", action:{type:"call", value:"+1 555 0100"}, subtasks:{{title:"Find receipt"}, {title:"Confirm serial number", starred:true}}}
complete_task given arguments:{task_ids:{task_id of task of created}, recursive:true}
end tell

Tags and Locations​

tag_update and location_update use the same shape:

KeyValues
operationset, append, or remove.
tag_idsFor tag_update, a list of tag_id strings.
location_idsFor location_update, a list of location_id strings.

Use set with an empty list to clear all tags or locations.

tell application "2Do"
set tagsResult to list_tags
set waitingTag to item 1 of tags of tagsResult

set selectedResult to selected_tasks
repeat with taskRecord in tasks of selectedResult
update_task given arguments:{task_id:(task_id of taskRecord), tag_update:{operation:"append", tag_ids:{tag_id of waitingTag}}}
end repeat
end tell

Pausing Tags​

Paused tags hide matching tasks from normal task views. Automation exposes the public field as paused; it does not expose the internal model name.

CommandArgumentsReturns
pause_tagRequired tag_id.tag.
unpause_tagRequired tag_id.tag.

Both commands are idempotent. Pausing an already paused tag returns the current tag record without creating a second action.

tell application "2Do"
set tagsResult to list_tags
set tagRecord to item 1 of tags of tagsResult

pause_tag given arguments:{tag_id:(tag_id of tagRecord)}
set pausedTasks to query_tasks given arguments:{paused_filter:"only"}
end tell

Actions​

Task actions can be set during create_task, replaced during update_task, or changed directly with update_task_action.

TypePayload
none{type:"none"} clears the action.
call{type:"call", value:"+1 555 0100"}
message{type:"message", value:"+1 555 0100"}
mail{type:"mail", value:"person@example.com"}
visit{type:"visit", value:"1 Infinite Loop, Cupertino, CA"}
url{type:"url", value:"https://example.com"}
google{type:"google", value:"search text"}

Automation uses 2Do's entered action variants. Contact-backed birthday and anniversary actions are not exposed in this API.

tell application "2Do"
update_task_action given arguments:{task_id:"TASK-UID-HERE", action:{type:"url", value:"https://www.2doapp.com"}}
end tell
tip

Use update_task_action when your script only needs to set, replace, or clear a task action.

Alarms​

Automation exposes sound alarms only.

Alarm object:

KeyTypeNotes
sound_nameStringOptional. Omit to use 2Do's normal/default alarm sound.
triggerRecordRequired. See below.

Absolute trigger:

{kind:"absolute", date:"2026-07-03 09:15"}

Relative trigger:

{kind:"relative", seconds:-900, anchor:"task_time"}

Absolute alarm dates use floating local yyyy-MM-dd HH:mm values. Do not include timezone names, Z suffixes, or UTC offsets.

Relative alarms require the task to have a due date or start date after applying the same write payload. anchor is task_date or task_time, and seconds must be between -63071999 and 63071999. A task may have at most 10 total alarms, including existing non-sound alarms that automation preserves.

Example:

tell application "2Do"
update_task given arguments:{task_id:"TASK-UID-HERE", due_date:"2026-07-03", due_time:"09:30", alarms:{{trigger:{kind:"relative", seconds:-900, anchor:"task_time"}}}}
end tell

Recurrence​

Recurrence replacement is supported in create_task and update_task.

KeyValues
frequencyRequired. none, daily, weekly, monthly, yearly, weekdays, or custom.
based_onRequired unless frequency is none. due_date or completion.
unitRequired for custom. day, week, month, or year.
intervalRequired for custom. Must be between 1 and 999.
weekdaysOptional for weekly. Values: sunday, monday, tuesday, wednesday, thursday, friday, saturday. Write this label as `
weekdayRequired with ordinal for monthly ordinal weekday recurrence.
ordinalRequired with weekday for monthly ordinal weekday recurrence. Supports 1 through 5, or -1 for the last matching weekday.
end_ruleOptional. {type:"never"}, {type:"on_date", date:"yyyy-MM-dd"}, or {type:"after_count", occurrence_count:n} where n is 1 through 99.

Recurrence requires the task to have a due date or start date after applying the same write payload, unless frequency is none to clear recurrence.

tell application "2Do"
update_task given arguments:{task_id:"TASK-UID-HERE", due_date:"2026-07-06", recurrence:{frequency:"weekly", based_on:"due_date", |weekdays|:{"monday", "wednesday", "friday"}, end_rule:{type:"after_count", occurrence_count:12}}}
end tell

Clear recurrence:

tell application "2Do"
update_task given arguments:{task_id:"TASK-UID-HERE", recurrence:{frequency:"none"}}
end tell

These commands require the Mac app UI.

CommandArgumentsReturns
select_listRequired list_id.selected, list_id.
select_list_groupRequired list_group_id.selected, list_group_id.
select_smart_listRequired smart_list_id.selected, smart_list_id.
select_focusRequired focus: all, today, starred, scheduled, or done.selected, collection_id.
open_taskRequired task_id.opened, task_id.

Returned Records​

Task records include:

FieldNotes
task_id, title, notes, list_id, task_typeCurrent task identity and core fields.
list_title, collection_id, list_group_idThe owning list's name and namespaced collection identity, plus its List Group when it belongs to one.
section_id, section_titlePresent on top-level tasks assigned to a live section in their list. Omitted on unsectioned tasks and children.
parent_task_idPresent when the task is a child task.
sortingSaved field and direction, present on projects and checklists.
child_task_idsPresent for projects or checklists with children.
child_task_destination_idPresent on editable projects and checklists that can currently accept children: the task's namespaced identity as a child destination (parent-task:<uid>). Use the task's task_id as parent_task_id when creating or moving children.
completed, starred, pausedCompletion state, starred state, and paused-by-tag state.
due_date, due_time, start_date, start_time, duration_secondsDate and duration fields when present.
prioritynone, low, medium, or high.
tags, locationsFull tag and location records with stable IDs.
action, alarms, recurrenceStructured action, sound alarms, and recurrence records. recurrence is missing value when not repeating.

Other records:

RecordFields
Listlist_id, collection_id, title, archived, editable, sorting, focus_enabled, optional list_group_id.
Sectionsection_id, list_id, title, description, display_order.
List Grouplist_group_id, collection_id, title, type (collect, focus, all_lists, smart_lists, shared_lists, or any), collapsed.
Smart Listsmart_list_id, collection_id, title, smart_search, has_additional_filters, sorting, focus_enabled.
Tagtag_id, title, paused, optional tag_group_id.
Tag Grouptag_group_id, title.
Locationlocation_id, title, address.
Default destinationdestination_id, list_id, title (from get_default_task_destination).

Errors​

AppleScript errors use standard AppleScript error number -10000. The error message starts with the stable automation error code, such as:

CodeMeaning
invalid_argumentsUnknown command, unknown argument key, missing required value, malformed date/time, or unknown enum value.
not_foundA supplied item was not found, was deleted, or belongs to a password-protected list that is still locked and hidden from automation.
edit_rejected2Do could not apply the requested model change.
automation_unavailableThe command requires Mac UI state that is not available.
operation_failedA lower-level save or delete operation failed.
access_denied2Do is locked, or access was revoked while an in-flight write was being revalidated.
tell application "2Do"
try
create_task given arguments:{title:"Missing list"}
on error errMsg number errNum
log "2Do automation failed (" & errNum & "): " & errMsg
end try
end tell