imsgd

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: Apache-2.0

README

imsgd

iMessage for your local network. imsgd is a small daemon that runs on a Mac signed in to Messages. It gives apps on your LAN a documented HTTP API to:

  • read chats, messages, attachments and contact names;
  • receive new messages, delivery and read receipts, edits and reactions in real time, over WebSocket or signed webhooks;
  • send text and attachments to existing chats, phone numbers or email addresses, with confirmation that each message actually went out.

It's a single Go binary with no Electron, no cloud services and no Firebase. imsgd learned a lot from BlueBubbles, but it is a new, smaller design, and its API is not BlueBubbles-compatible.

curl -H "Authorization: Bearer $KEY" "http://mac.local:8642/api/v1/chats?limit=5&include=last_message"

curl -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d '{"to":"+15551234567","text":"Dinner is ready 🍝","client_ref":"a1b2c3"}' \
  http://mac.local:8642/api/v1/messages

Requirements

  • macOS 13 or later, tested on macOS 26.5. You need a user account signed in to Messages, and it must stay logged in.
  • Go 1.25+ to build.
  • A code-signing identity, so macOS permissions survive rebuilds. A self-signed one is fine: scripts/create-signing-cert.sh creates it.

Quick start (about 5 minutes)

git clone … imsgd && cd imsgd
scripts/create-signing-cert.sh        # once: a stable signing identity
make install                          # build, sign, install to ~/.local/bin/imsgd

imsgd keys create my-app              # prints an API key; store it
imsgd install-agent                   # start now and at every login

Then give imsgd its macOS permissions:

  1. Full Disk Access. In System Settings → Privacy & Security → Full Disk Access, click +, press ⌘⇧G, enter ~/.local/bin/imsgd, and turn it on.
  2. Automation. Run imsgd doctor -automation (or send your first message) and click Allow when macOS asks whether imsgd may control Messages.
  3. Check. Run imsgd doctor and imsgd status. Every line should be ✓.

imsgd logs the LAN URLs it is reachable at. See docs/operations.md for details and troubleshooting.

Documentation

docs/api.md API guide: auth, pagination, sync, real-time events, webhooks, sending, attachments
api/openapi.yaml OpenAPI 3.0 specification, also served at /api/v1/openapi.yaml
docs/operations.md Installing, permissions, configuration, TLS, logs, upgrading, troubleshooting
examples/ A WebSocket client (Go) and a webhook receiver (Python)

Development

make test                              # unit, contract (OpenAPI) and integration tests
make fuzz                              # fuzz the typedstream decoder
IMSGD_LOAD=1 go test ./internal/api -run TestLoad -v   # load test

Commands that need Full Disk Access or Automation must run under launchd, because macOS applies permissions to the program launchd started, not to your terminal. Two scripts help:

  • scripts/launchd-run.sh <imsgd args> runs one command, e.g. scripts/launchd-run.sh doctor.
  • scripts/dev-agent.sh start|stop|logs runs a development server.

Tests never touch your real Messages data. They build synthetic chat.db files from the real macOS schema (internal/imessage/fixture).

What it can't do

Sending uses AppleScript, so these features are not available: reactions, edits, unsends, inline replies, typing indicators, marking chats read, and creating or managing group chats. They need Apple's private frameworks (and disabling System Integrity Protection). imsgd still reports all of them when they happen on other devices.

Security

imsgd can read every message and send as you. Treat API keys like passwords:

  • Give each app its own key (imsgd keys create) so you can revoke it on its own (imsgd keys revoke).
  • Keep imsgd on a trusted network. Enable TLS (imsgd gen-cert) if other people share the LAN.
  • Bind it to a single interface with listen: if the Mac has several.

See docs/operations.md#security.

License

Apache License 2.0. See NOTICE for attributions.

Directories

Path Synopsis
Package api holds the imsgd OpenAPI specification, the source of truth for the HTTP API.
Package api holds the imsgd OpenAPI specification, the source of truth for the HTTP API.
cmd
imsgd command
Command imsgd is a headless iMessage server for the local network.
Command imsgd is a headless iMessage server for the local network.
examples
watch command
Command watch is an example imsgd client: it streams events over WebSocket, reconnecting and resuming from the last event it saw.
Command watch is an example imsgd client: it streams events over WebSocket, reconnecting and resuming from the last event it saw.
internal
api
Package api implements the imsgd HTTP API described by api/openapi.yaml.
Package api implements the imsgd HTTP API described by api/openapi.yaml.
config
Package config loads imsgd configuration from a YAML file with environment variable overrides.
Package config loads imsgd configuration from a YAML file with environment variable overrides.
contacts
Package contacts resolves phone numbers and emails to contact names by reading the macOS AddressBook databases directly (no Contacts framework, no CGO).
Package contacts resolves phone numbers and emails to contact names by reading the macOS AddressBook databases directly (no Contacts framework, no CGO).
events
Package events is the in-process event bus.
Package events is the in-process event bus.
imessage/appledate
Package appledate converts between Apple's Core Data epoch timestamps (as stored in chat.db) and time.Time.
Package appledate converts between Apple's Core Data epoch timestamps (as stored in chat.db) and time.Time.
imessage/db
Package db provides read-only access to the Messages database (chat.db).
Package db provides read-only access to the Messages database (chat.db).
imessage/fixture
Package fixture builds synthetic chat.db files for tests, using the real schema captured from macOS 26.5 (no private data).
Package fixture builds synthetic chat.db files for tests, using the real schema captured from macOS 26.5 (no private data).
imessage/keyedarchive
Package keyedarchive decodes binary property lists, resolving NSKeyedArchiver object graphs into plain Go values.
Package keyedarchive decodes binary property lists, resolving NSKeyedArchiver object graphs into plain Go values.
imessage/typedstream
Package typedstream decodes NeXTSTEP/Apple "typedstream" archives, the legacy NSArchiver format Messages uses for message.attributedBody.
Package typedstream decodes NeXTSTEP/Apple "typedstream" archives, the legacy NSArchiver format Messages uses for message.attributedBody.
logging
Package logging configures the process-wide slog logger.
Package logging configures the process-wide slog logger.
macos
Package macos wraps macOS-specific facilities: OS version detection, AppleScript execution and permission probes.
Package macos wraps macOS-specific facilities: OS version detection, AppleScript execution and permission probes.
media
Package media inspects and converts attachment files: image dimensions, HEIC→JPEG and audio→M4A conversion (via sips/afconvert), and Live Photo companions.
Package media inspects and converts attachment files: image dimensions, HEIC→JPEG and audio→M4A conversion (via sips/afconvert), and Live Photo companions.
present
Package present converts database models into the JSON shapes of the public API (api/openapi.yaml).
Package present converts database models into the JSON shapes of the public API (api/openapi.yaml).
send
Package send delivers outgoing messages through Messages.app.
Package send delivers outgoing messages through Messages.app.
send/sendtest
Package sendtest provides a fake send.Runner that behaves like Messages by inserting rows into a fixture chat.db.
Package sendtest provides a fake send.Runner that behaves like Messages by inserting rows into a fixture chat.db.
store
Package store is imsgd's own SQLite database (webhooks, delivery queue).
Package store is imsgd's own SQLite database (webhooks, delivery queue).
tracker
Package tracker turns changes in chat.db into events.
Package tracker turns changes in chat.db into events.
watcher
Package watcher signals when the Messages database may have changed.
Package watcher signals when the Messages database may have changed.
webhook
Package webhook delivers events to registered HTTP endpoints.
Package webhook delivers events to registered HTTP endpoints.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL