OAuth for iCloud developer guide

Use Selected Apple Notes as Agent Memory

Selected Notes folders can act as agent memory that the user can read and correct on any Apple device. OAuth for iCloud has a read scope for Notes. Writeback is a design for a developer-owned helper on a Figment-hosted Mac.

Figment editorial teamPublished Updated Facts checked November 12, 2026

Selected Apple Notes folders can serve as an AI agent's persistent memory: readable on every Apple device the user owns, correctable by hand, and updated by the agent through structured writeback. Figment's OAuth for iCloud has a read scope for Notes, notes:read (/icloud). This article is an integration design guide for developers building a Notes-backed agent that also writes back, with Apple-native access methods on a Figment-hosted Mac.

Why does Apple Notes work as an agent memory store?

Because the user can read and correct it. Apple Notes syncs across iPhone, iPad, Mac, and Apple Vision Pro through iCloud (iCloud Notes overview). Notes support tags, Smart Folders, rich text, attachments, and inline PDFs, which is enough structure for most agent workflows without a separate database.

The advantage over a vector store or SQL table is human editability. When the agent writes something wrong, the user fixes it in the note, and that correction becomes the agent's source of truth on the next read. The memory stays legible, correctable, and with the user, which matters as much as recall accuracy.

iCloud sync also carries the memory across sessions. The user can annotate a note on an iPhone during the day, and the agent reads the updated text that evening from the Mac-side helper.

How does the agent read notes?

Through native Mac operations, because Apple's third-party authorization covers iCloud Mail, Calendar, and Contacts and not Notes (Apple support 121539). Two methods work:

Markdown export (macOS 26+). Apple Notes supports per-note Markdown export: open the note, choose File → Export as → Markdown, and save to a chosen folder (Apple Notes export guide). A local helper script on the Figment-hosted Mac can automate this for a user-defined folder: export each note to a staging directory, read the files, and write updated files back for re-import. Attachments and locked notes are not fully exported, and the patterns below account for those gaps.

AppleScript access. A tell application "Notes" block can read note titles and body text from a named folder without a separate export step. It runs on the Figment-hosted Mac inside the signed-in user session. The developer owns this helper script. Figment provides the execution environment, not the script.

Both methods need Notes open and iCloud sync enabled. Neither can read a locked note until the user explicitly opens it.

Which folders should the agent read and write?

Only deliberate project folders. Notes organizes content into standard project folders, Quick Notes (notes started outside the app), Math Notes (math work synced from the Calculator app on iPhone and iPad), Shared (collaborator content), and Recently Deleted (held up to 30 days).

FolderAgent accessRationale
Agent MemoryRead + writePrimary write target for facts, summaries, decisions
ResearchRead onlyUser curates; agent reads but does not alter
[Named project folders]Read + writeScoped to explicit user setup
Quick NotesExcludedCatch-all for unstructured user input
Math NotesExcludedCalculation scratchpad; not a stable memory source
SharedExcludedCollaborator content outside user's direct control
Recently DeletedExcludedDiscarded content

Keep agent-writable folders in the iCloud account, not in Gmail or Yahoo third-party folder sources. Notes can be locked only if stored in iCloud, so keeping agent folders there gives consistent lock-status behavior and sync availability.

What should the agent do with locked notes?

Skip any locked note and tell the user. Never attempt programmatic access to it. Apple lets users lock individual notes with a password (Apple iCloud locked notes). Notes locked with a device passcode or macOS login password cannot be viewed on iCloud.com. Notes locked with a custom Notes password can be viewed on iCloud.com after entering that password, but a local helper still cannot surface them until the user explicitly opens them.

Build the folder structure so agent-writable notes are never individually locked. Reserve locking for private notes the agent should never see.

How should the agent write back without breaking content?

Match the rule to the note's purpose. Overwriting destroys user edits, and unstructured appends pile up noise the user cannot scan.

Note purposeWriteback rule
Running log (e.g. "Research log 2026")Append a dated block at the bottom; never delete existing lines
Decision recordAppend below a — Agent additions — separator; preserve all user content above it
Summary noteReplace only the designated block between [AGENT SUMMARY START] and [AGENT SUMMARY END] markers
Read-only folderNo write; read access only

Before every write, confirm the Notes helper can reach the target note. If it cannot, queue the write and retry after a configurable back-off. Generate a stable write-intent key (for example, a UUID) once per intended write, before the first attempt, and embed it in the entry. Skip the write if that key already appears in the note. This prevents duplicate entries on retry without a separate state store. Do not recompute a key if the content changes after a failed attempt. Generate a fresh key for the new content, and poll the note directly to find out whether the previous attempt landed before treating its outcome as unknown.

How does the agent cite its sources inside notes?

Every paragraph the agent writes opens with a provenance line. This makes the memory auditable and stops the agent from mistaking its own earlier output for an independent source.

[Agent • 2026-11-12T14:32Z • source: Research/Article-draft.md • action: summarize]

The four fields are Agent (author), an ISO 8601 UTC timestamp, the source note path or external reference, and the action type (summarize, extract, decide, update). These are application-owned metadata fields embedded as plain text, not Apple API fields. If the agent reads a note it wrote earlier, the citation chain makes that loop visible, and a long chain is a signal for the user to step in.

What does the full ruleset look like?

Put this declaration in the agent's system prompt or configuration file. It removes ambiguity about which folders to touch, how to format an entry, and when to skip a write.

NOTES MEMORY RULES

Readable folders:
  - Agent Memory
  - Research
  - [Project folders defined at setup]

Writable folders:
  - Agent Memory
  - [Project folders where write access was explicitly granted]

Excluded (never read or write):
  - Shared
  - Quick Notes
  - Math Notes
  - Recently Deleted
  - Any note whose status is locked

Access guard:
  - Only proceed if the Notes helper can reach the target folder
  - If unavailable: queue write, retry after back-off; do not write

Writeback strategy:
  - Running logs     → append a dated block; never delete existing lines
  - Decision records → append below "— Agent additions —" separator
  - Summary notes    → replace only content between
                       [AGENT SUMMARY START] … [AGENT SUMMARY END] markers
  - Read-only folder → read only; no write under any condition

Citation format (prepend to every agent-authored paragraph):
  [Agent • {ISO8601_UTC} • source: {source_ref} • action: {action_type}]

Idempotency:
  - Generate a unique write-intent key (e.g., a UUID) once, before the first attempt
  - Embed the key in the entry text
  - If the key already appears in the note: skip write; do not create a duplicate
  - If content changes after a failed attempt: generate a new key for the new content;
    poll the note to determine whether the previous attempt landed before treating
    its outcome as unknown

Locked notes:
  - Skip read; never attempt write
  - Surface to user: "Note is locked — unlock in Apple Notes to include"

The ruleset is plain text, so any agent framework that accepts a system prompt can use it without code changes. Folder names can be parameterized at setup. The citation format and writeback strategy stay fixed.

Where does OAuth for iCloud fit?

The execution environment is a Figment-hosted Mac running within the signed-in user session. Figment's OAuth layer manages app consent and scoped access tokens for supported services, and notes:read is its read scope for Notes. The Notes helper itself is developer-owned code that runs on that Mac. Start with the read path in Read Apple Notes with a Scoped Mac Helper, then add write logic once your folder selection and citation rules are validated.

For related Apple data sources (photos, files, and Safari), see Connect Apple Notes, Photos, Files, and Safari. For task creation alongside note memory, see Create Apple Reminders with EventKit on Mac.

Connect Apple Account to register your app and start in the sandbox. Sandbox access is free. Notes is part of the Full iCloud suite, which is $29/month per connected Apple Account, and you request a demo for live access. That price does not include direct access to a Mac. Mac rentals are a separate Figment product.

Connect Apple data to your app

Register your app and start with synthetic sandbox data. Choose the permissions your app needs.

Connect Apple Account

Sandbox is free. Live access is $14 or $29 per connected Apple Account, per month.