# iMessage as an API: 34 message verbs on the owner's Mac, each call receipted

slug: imessage-api-on-the-mac · https://miscsubjects.com/a/imessage-api-on-the-mac · category: build · tags: imessage, mac, capability-fabric, device-ledger, api · updated 2026-09-09T01:07:11.417Z

iMessage is Apple's messaging service; every text the owner of a Mac has sent or received through it sits in one database file on that Mac, and the Mac's Messages app can send new ones under the owner's own phone number and email. An API, here, means a row in this site's directory that any model or program can call with one HTTP request, that runs on the owner's Mac through the Mac bridge (an authenticated tunnel into one process on that machine), and that leaves a public receipt on the ledger for every call. On 2026-09-08 the Mac's iMessage became 34 such rows. Each was created over the directory's REST interface, ten were then called through the normal dispatch path and returned receipts, a real message was sent from the Mac and confirmed delivered, and a reaction was placed on it, both through the bridge.

**Where the messages are and why a plain read fails.** The Messages database is `~/Library/Messages/chat.db`. On this Mac it holds 673,552 messages across 2,843 conversations (201 of them groups) and 29,824 attachments. Since roughly March 2026 Messages stops writing most bodies into the plain `text` column and stores them only as a binary `attributedBody` blob: of the 6,084 messages on this Mac since 2026-08-01, 5,402 have an empty `text` column. A raw SQL read therefore returns blanks for 89% of recent messages. That single measurement decided the design: the executor had to decode the blobs.

**The two programs underneath.** Reading, searching, streaming and plain sending run through [imsg](/a/imsg), a Swift command line that opens the database read-only, decodes the blobs, streams new rows as JSON, and asks the Messages app to send, then confirms the outgoing row appeared and reports whether it was delivered. Actions on specific messages, a reaction, a quoted reply, an edit, an unsend, a typing indicator, marking a chat read, run through [platform-imessage](/a/platform-imessage), Beeper's library, which drives a second window of the Messages app through macOS Accessibility, because Apple's scripting surface for Messages can send text and files and nothing else. Both run with System Integrity Protection on. Both were installed on the Mac with Homebrew and both answered through the bridge on the first call, because the bridge process already holds Full Disk Access and Accessibility.

**How a call reaches the Mac.** A row's body names the command; dispatch substitutes the caller's arguments into the command's argument list structure by structure, so a quotation mark inside a search query arrives as a character, not as shell syntax (tested: the query `it"s` reached the program intact). A small wrapper script on the Mac owns the defaults and the quoting, so no row body contains shell code. Every row runs on the Mac only; there is no cloud fallback for a machine's own message store.

## The 34 verbs

**Reading.** `IMSG_CHATS` lists recent conversations with their row ids, guids, participants, service and unread counts. `IMSG_UNREAD` lists only conversations with unread inbound messages. `IMSG_HISTORY` reads the last N messages of one chat with decoded bodies, sender, reactions, reply context and attachment metadata. `IMSG_SEARCH` searches all 673,552 messages by text. `IMSG_STATS` counts messages by service, chat, sender and date. `IMSG_GROUP`, `IMSG_WHOIS`, `IMSG_ACCOUNT`, `IMSG_STATUS`, `IMSG_SCHEDULED`, `IMSG_MESSAGES`, `IMSG_MESSAGE`, `IMSG_ACTIVITY`, `IMSG_CURRENT_USER` and `IMSG_VERBS` read a chat's identity, whether a handle is known and on which service, the signed-in account, executor health, messages queued with Send Later, Beeper's view of a chat with message ids, one message, whether the other party is typing or in Do Not Disturb, the owner's own identity, and the verb list.

**Inbound.** `IMSG_AFTER` is a cursor: given a message row id it returns everything newer, including reactions and edits, with the next cursor and a has-more flag, so a flow or agent that keeps the cursor sees every message exactly once. `IMSG_SEND_STATUS` returns the delivery state of a sent message by guid. `IMSG_INBOX`, `IMSG_INBOX_SINCE` and `IMSG_WATCH_STATUS` read the event log written by the inbound watcher described below.

**Sending.** `IMSG_SEND` sends a text to a phone number or email under the owner's identity and returns the new message's id and guid. `IMSG_SEND_CHAT` sends into an existing conversation by row id, including groups. `IMSG_SEND_FILE` sends a file, with audio arriving as a voice message. `IMSG_CREATE_CHAT` starts a new direct or group conversation with addresses never messaged before.

**Acting on a message.** `IMSG_REACT` and `IMSG_UNREACT` add or remove a tapback or emoji on any message by id, or on `latest` and `latest-1`. `IMSG_REACT_LATEST` reacts to the most recent incoming message of a chat through imsg's own route. `IMSG_REPLY` sends a quoted reply to one message. `IMSG_EDIT` and `IMSG_UNSEND` change or retract a message the owner sent, inside Apple's windows. `IMSG_TYPING` turns the typing indicator on or off. `IMSG_MARK_READ` and `IMSG_MARK_UNREAD` change a chat's read state. `IMSG_LOAD_ATTACHMENT` forces an offloaded attachment to download.

The call shape is the same for every row: `POST https://miscsubjects.com/api/dispatch` with `{"key":"IMSG_SEARCH","body":"invoice|10"}` and the caller's key; arguments are joined with a vertical bar in the order each row's schema states. The live rows, with their schemas and test state, are the [iMessage API sheet](/sheet/sh_94mg44b6).

## What was proven, with receipts

| call | result | latency | receipt |
| --- | --- | --- | --- |
| IMSG_CHATS 2 | two conversations, decoded | 454 ms | [inv_2fhwaze5qp](/receipt/inv_2fhwaze5qp) |
| IMSG_AFTER 677275, 2 | two newer messages, next cursor | 400 ms | [inv_h26qrni500](/receipt/inv_h26qrni500) |
| IMSG_SEND_STATUS (an earlier proof message) | send_state delivered, delivered_at 19:17:39Z | 300 ms | [inv_nvhvrixojr](/receipt/inv_nvhvrixojr) |
| IMSG_WHOIS (a number never messaged) | known false, service unknown | 46 ms | [inv_ijalm9asg1](/receipt/inv_ijalm9asg1) |
| IMSG_STATUS | database ready, SIP enabled, 14 live RPC methods | 41 ms | [inv_0aohsk7rsl](/receipt/inv_0aohsk7rsl) |
| IMSG_VERBS | 36 verbs | 40 ms | [inv_g444m2ezhz](/receipt/inv_g444m2ezhz) |
| IMSG_WATCH_STATUS | watching false, before the watcher was repaired | 43 ms | [inv_fmn0qce9e0](/receipt/inv_fmn0qce9e0) |
| IMSG_HISTORY 2803, 2 | two messages with decoded text | 167 ms | [inv_m1v6eji4ml](/receipt/inv_m1v6eji4ml) |
| IMSG_SEND (through the bridge) | accepted as row 677351, status sent | 329 ms | [inv_5fk14dt3p8](/receipt/inv_5fk14dt3p8) |
| IMSG_SEND_STATUS (that message) | sent, delivered 01:02:53.326Z, read 01:02:53.516Z | 300 ms | [inv_roinbe5iec](/receipt/inv_roinbe5iec) |

The send itself: one message to the owner's own number, called as `IMSG_SEND` through dispatch, carried to the Mac by the bridge, accepted by Messages as row 677351, and reported by `message.send_status` as delivered at 01:02:53.326Z and read 190 milliseconds after that. An earlier send from a different process had already proven the mechanism; this one proves the path the rows actually use. The reaction: `IMSG_REACT` placed a thumbs-up on that message through the bridge process in 2,870 ms, verified by the program against the window, with no consent dialog, because Accessibility was already granted to the bridge. A full-account `IMSG_STATS` took 7,180 ms and counted 666,877 messages; every other read finished under 1.2 seconds.

## A grant belongs to a program, not to a person

macOS attaches automation and privacy rights to an exact executable. The bridge process holds Full Disk Access, Accessibility and Screen Recording, and Apple Events consent for System Events, Calendar and Chrome; consent for Messages was added on 2026-09-08 at 19:31. That single row is what moved the four sending verbs from mechanism to path: the send above raised no dialog and needed no attention.

The same rule broke the inbound side, in the opposite direction, and the failure is worth the space. A launchd job whose program is a shell script runs as the shell, and the shell holds none of those grants. So the watcher's read of the Messages store returned nothing, it passed an empty cursor to a program that refuses one, and the job restarted 695 times in 105 seconds while reporting exit status zero. The collector beside it kept running and kept posting, but every store read inside it returned nothing, so only its heartbeat was true. Neither job logged an error, because from each program's point of view nothing had gone wrong.

The repair is an entry point rather than a permission. Both launchd scripts now re-execute their work under the one binary that already holds the grants, and the child process inherits them. That is the shape the Mac bridge itself has always had: launchd runs a shell script, the script hands off to the granted binary, and everything below it can see the machine. Within one restart the watcher resumed from message row 677347, and the collector went back to reading every local store.

## Inbound: messages as events

Two inbound paths exist. The first needs nothing running: any flow keeps a cursor and calls `IMSG_AFTER`. The second is a watcher on the Mac that streams every new message as it lands, appends the full record to a local event log (readable through `IMSG_INBOX` and `IMSG_INBOX_SINCE`), and posts one metadata-only observation to the [device capability ledger](/device-capability-ledger) per message: direction, chat, direct or group, service, attachment count, text length. Never the text, never the handle. The watcher runs as a launchd service. It resumed at message row 677347, captured the send described above as row 677352 about four seconds after dispatch returned, and advanced its cursor; `IMSG_WATCH_STATUS` reports it watching, with its cursor and its event count.

Alongside it runs a state collector that samples the Mac every 60 seconds and writes only what changed: frontmost app, Focus mode, power source, Wi-Fi network (hashed), screen locked or not, presence by idle time, Bluetooth devices, the set of running apps, attached displays, the row counts of the Mail, Safari, Chrome, Photos, Notes, Calendar, Messages and Contacts stores, the next calendar event's start time, and whether the paired iPhone answers over the network. Its first run wrote 19 observations to the ledger under receipt [8261ba99](/receipt/8261ba99-845f-40a0-b1e9-2590cfec0d4a), and it now writes only the differences, minute by minute.

## What the ledger now records

The same ingest that carries those observations carries the research behind the choice of programs. Fifteen open-source iMessage projects were read from source, and each is now an executor row in the ledger with its mechanism, its requirements, what it uniquely adds and its verdict; two were absorbed (the two programs above), seven are reference material only, six were rejected, one of them for forging device identities against Apple's push service, and the rest for needing SIP disabled, being dead, or exposing a network port with weak authentication. The ledger's [machine projection](/api/capability-census) lists 109 executors, 9 of them ready on this Mac, and 36 verified capabilities, each with the receipt of the call that verified it. Twenty-four of those were verified today through the bridge: the iMessage reads above, and read access to the Mac's Contacts (408 records), Calendar (174 items), Notes (1,012), Mail (262 envelopes), Photos (47,213 assets), Safari and Chrome history, Spotlight, power, Bluetooth and process state. Also recorded as candidates, not yet invoked: the owner's Home shortcuts (door lock, gate code) callable by `shortcuts run`, and the AppleScript dictionaries of Excel, Word, Outlook, Keynote, Numbers, Pages, Chrome, Safari and the ChatGPT desktop app, each a licensed or signed-in program the Mac can operate without a vendor API.

## What decides the next step

Three facts bound what comes next. The iPhone answers over the network (iOS 26.6.1) for device information and file transfer, but every developer service, including screenshots and element-level control, requires Developer Mode, which iOS refuses to enable while a passcode is set. The Mac's Messages, Contacts, Calendar, Notes, Mail and Photos stores are all readable today through the bridge, so the reading half of the personal data surface is done; the writing half is one Apple Events consent per app. And the watcher and collector, both running, prove the pattern that turns any local state change into a ledger row without a model in the loop: sample, diff, post. The [device capability ledger](/device-capability-ledger) is where each new verb lands first, and a verb is promoted into the directory only after a real call has returned real data.


## Sources

1. openclaw/imsg README, Permissions — https://github.com/openclaw/imsg
2. beeper/platform-imessage README — https://github.com/beeper/platform-imessage
3. Device capability ledger, machine projection (executor rows and verified capabilities with receipts) — https://miscsubjects.com/api/capability-census


---

# platform-imessage: Beeper's Swift library that drives the Messages app through Accessibility

slug: platform-imessage · https://miscsubjects.com/a/platform-imessage · category: reference · tags: reference, imessage, mac, messaging, accessibility · updated 2026-09-08T20:13:35.726Z

platform-imessage is an open-source Swift library and command-line program from Beeper, the multi-network chat company, that automates the Messages app on a Mac. Its README describes it as "A standalone Swift library and CLI that lets you and your agents send/receive messages and fully automate iMessage locally on your Mac." It is licensed MIT, installs with `brew install beeper/tap/imessage-cli`, and is the code behind the iMessage connection in Beeper's own Mac app: "This library powers the iMessage integration on" Beeper for macOS.

**Two mechanisms, one program.** For reading, it opens the Messages database (`~/Library/Messages/chat.db`, the SQLite file where macOS stores every message) and watches it for changes. For acting, it does what a person does: it drives the Messages app's own window through macOS Accessibility, the same programmatic surface that screen readers use to click buttons and read labels, plus Apple's automation events for plain sends. The README says it "works with automation and accessibility APIs" and compares itself to OpenAI's Codex computer use, "but surgical and faster".

**Why that matters.** Apple's scripting dictionary for Messages can send a text or a file and nothing else. Everything a modern conversation contains beyond that, a reaction on a specific message, a quoted reply, an edit, an unsend, a typing indicator, marking a chat read, is not reachable through scripting. The other established route to those features, BlueBubbles, reaches them through a Private API helper that only loads when System Integrity Protection is off; the README's feature table marks each of those rows and footnotes them: "BlueBubbles supports this through its Private API helper, which requires disabling SIP." platform-imessage reaches the same rows with SIP on, by operating the real window.

**What the command line does.** `chats`, `chat`, `messages`, `message`, `search` read history with contact-resolved names, tapbacks, stickers, mentions, replies and edit history. `send` and `send-file` send to an address or an existing chat; `create-chat` starts a new direct or group chat with people never messaged before. `reply` and `reply-file` send quoted replies to a message id (or to `latest`, `latest-1`). `react` and `unreact` add or remove a tapback on any message by id, including arbitrary emoji. `edit` and `undo-send` change or retract a sent message inside Apple's time windows. `typing` turns the typing indicator on or off; `mark-read`, `mark-unread`, `mute`, `unmute`, `notify-anyway` and `delete-chat` manage a chat; `activity-status` reports whether the other party is typing and their Do Not Disturb state; `load-attachment` forces an offloaded attachment to download. `start-watching` streams database changes as events. Output is YAML by default and JSON with `--json`.

**How it avoids fighting the person at the keyboard.** By default it launches a secondary instance of the Messages app and drives that window, so the primary window a person is using is left alone. The flag `--no-use-secondary-instance` turns that off.

**Permissions and limits.** Four macOS grants: Accessibility, Contacts (optional, for names), Messages data (Full Disk Access) and Automation for Messages. The README states what it will not do: "expose more features if you disable SIP, allow automating multiple iMessage accounts, work on Windows/Linux". Group management (rename, add or remove members, leave, photo) and rich sends (effects, subjects, captions) are listed as planned. Only one process may drive the Messages app at a time. There is no HTTP server, no webhook and no push relay; the README's table gives that row to BlueBubbles.

**Fragility.** Because acting means locating message cells in a live window, a macOS release that rearranges the Messages interface can break an action until the library is updated; the project's todo list tracks such fixes per macOS version. Reading is not affected by that, since it comes from the database.

**Verdict.** On a Mac with SIP on, platform-imessage is the only maintained program that reaches reactions on arbitrary messages, quoted replies, edits, unsends, typing and read state. Its cost is the Accessibility route: slower than a database read, dependent on the window layout, and exclusive of any other automation touching the Messages app at the same moment.


## Sources

1. beeper/platform-imessage README — https://github.com/beeper/platform-imessage
2. beeper/platform-imessage README, feature table footnote — https://github.com/beeper/platform-imessage#features


---

# imsg: a Swift command line that reads, streams and sends iMessage from a Mac

slug: imsg · https://miscsubjects.com/a/imsg · category: reference · tags: reference, imessage, mac, messaging · updated 2026-09-08T20:13:06.672Z

imsg is an open-source command-line program for a Mac that reads, streams and sends iMessage and SMS through the Messages app already signed in on that Mac. Its README states the scope in one line: it "is a Swift CLI for reading, watching, and sending iMessage and SMS from macOS". It is written in Swift 6, licensed MIT, requires macOS 14 or newer, and installs with one Homebrew command, `brew install steipete/tap/imsg`. On 2026-09-08 the repository showed about 1,300 stars and its latest release, 0.15.3, was published the day before.

**Where the messages come from.** Every iMessage and SMS a Mac has ever received or sent sits in one SQLite file, the Messages database at `~/Library/Messages/chat.db`. imsg opens that file directly. The README is precise about the mode: "Read commands open the database in SQLite read-only mode." Nothing is written to the database; the program decodes what Messages already stored. That decoding is the reason the tool exists rather than a plain SQL query: since 2026 Messages stores most message bodies not in the plain `text` column but in a binary `attributedBody` blob, and imsg decodes those blobs back into text, reactions, reply context, attachment records and scheduled messages.

**Streaming.** The `watch` command emits one JSON object per new message as it arrives. It follows filesystem events on the database and its write-ahead log, with a polling fallback for the cases where macOS drops an event, and it can start from a saved row id so a consumer that was offline replays exactly what it missed. Output discipline is explicit: the flag "emits one JSON object per line. Human progress and warnings stay on stderr, so stdout remains safe to stream."

**Sending.** `send` asks the Messages app to send, through Apple's own automation surface (AppleScript), and then confirms the outgoing row appeared in the database, returning its id and guid. A separate `message.send_status` method reports whether that row was later marked delivered or read. Text, files and audio go through the same path. For SMS the README requires Text Message Forwarding on the paired iPhone and states the limit plainly: the send path "cannot force a particular outgoing number when several numbers share one Apple ID".

**A long-running interface for programs.** `imsg rpc` speaks JSON-RPC 2.0 over standard input and output, with no network port: initialize, chats.list, messages.history, messages.search, messages.after (a cursor over everything newer than a row id), messages.stats, watch.subscribe, send, send.tracked (idempotent, caller-supplied id), message.send_status and typing, plus a set of methods that only work with the optional helper described below.

**Permissions.** Three macOS grants govern what works. "Full Disk Access is required for local database reads." Sending and the six standard tapbacks additionally need Automation for Messages, and Contacts access is optional and only adds names to handles. Grants attach to the parent process that launches imsg, not to imsg itself.

**The two tiers.** Everything above runs with System Integrity Protection on. The README states that the normal commands "do not use private frameworks or process injection". A second tier, called Advanced IMCore, injects a helper into the Messages app to reach read receipts, typing indicators, rich sends, editing, unsending, stickers, polls and group management; those features "require SIP to be disabled and may be blocked by library validation or private-entitlement checks" on current macOS. With SIP on, `imsg status` reports those methods as unavailable and the first tier keeps working.

**What it does not do.** No HTTP server, no webhooks, no push notifications, no FaceTime, no multi-account support. Reactions on the first tier reach only the most recent incoming message of a chat and are performed through UI automation of the Messages window, which needs the Accessibility grant.

**Verdict.** For a Mac that is signed in to Messages and stays awake, imsg is the most complete SIP-on program for turning that Mac's own message history and identity into something a script can call: decoded history, a replayable stream, verified sends, and a stdio API. Its ceiling is Apple's: anything Messages will not do through AppleScript needs the SIP-off helper, and that helper is explicitly research-grade.


## Sources

1. openclaw/imsg README — https://github.com/openclaw/imsg
2. openclaw/imsg README, Permissions and Advanced IMCore — https://github.com/openclaw/imsg#permissions

