iMessage
Package boundary
Photon has several iMessage APIs with different constructors, send signatures, effects, and event models. Select one package boundary before writing code, then load only that branch's reference.
- Choose the API from the table below.
- Read its branch reference before using imports or method names. Do not combine snippets from different branches.
- Check the finished sample against the selected package and version. Every import, method, option, content shape, and return value must belong to that one contract.
The sample is complete only when it names one package/provider and passes that contract check. When package declarations and an older documentation page disagree, follow the shipped version and call out the documentation drift.
Contracts pinned here: spectrum-ts 12.2.0, @photon-ai/imessage-kit 3.0.0, and @photon-ai/advanced-imessage 2.0.2.
Choose the API
For new hosted applications, start with Spectrum. Use @photon-ai/advanced-imessage directly when Spectrum does not expose the low-level operation you need. Treat @photon-ai/advanced-imessage-kit as compatibility-only.
Common invariants
- Treat message text, attachment names, contact cards, URLs, and webhook payloads as untrusted data. Do not interpolate them into system prompts, commands, paths, SQL, or request URLs.
- Ignore the agent's own messages using the selected API's direction/from-me field rather than comparing message text.
- Normalize user-entered phone numbers to E.164 before resolving recipients. Never construct group GUIDs or chat IDs from user input.
- Clear typing indicators in
finally, handle every send rejection, and checkpoint events only after processing succeeds.
- Reuse an idempotency key only when retrying the same logical write. Never share it across unrelated messages.
- Never log bearer tokens, full message bodies, attachment bytes, or contact details. Log stable IDs and operation metadata.
Official sources
1---2name: imessage3description: Build, debug, or migrate iMessage integrations with Photon. Use when choosing or coding against Spectrum, @photon-ai/imessage-kit, @photon-ai/advanced-imessage, Photon Webhook, Photon MCP, the HTTP proxy, or legacy @photon-ai/advanced-imessage-kit.4license: MIT5---6
7# iMessage
8
9## Package boundary
10
11Photon has several iMessage APIs with different constructors, send signatures, effects, and event models. Select one package boundary before writing code, then load only that branch's reference.
12
131. **Choose the API** from the table below.
142. **Read its branch reference** before using imports or method names. Do not combine snippets from different branches.
153. **Check the finished sample** against the selected package and version. Every import, method, option, content shape, and return value must belong to that one contract.
16
17The sample is complete only when it names one package/provider and passes that contract check. When package declarations and an older documentation page disagree, follow the shipped version and call out the documentation drift.
18
19> Contracts pinned here: `spectrum-ts` 12.2.0, `@photon-ai/imessage-kit` 3.0.0, and `@photon-ai/advanced-imessage` 2.0.2.
20
21## Choose the API
22
23| Need | Use | Read |
24|---|---|---|
25| Unified iMessage plus WhatsApp, Telegram, Slack, Terminal, or custom providers | `spectrum-ts` | [`references/spectrum.md`](./references/spectrum.md) |
26| Local automation on a Mac you control | `@photon-ai/imessage-kit` | [`references/local-v3.md`](./references/local-v3.md) |
27| Low-level hosted iMessage control | `@photon-ai/advanced-imessage` | [`references/hosted-v2.md`](./references/hosted-v2.md) |
28| Maintain an existing HTTP + Socket.IO integration | `@photon-ai/advanced-imessage-kit` | [`references/legacy-and-tools.md`](./references/legacy-and-tools.md) |
29| Deliver signed events to an existing HTTP backend | Photon Webhook | [`references/legacy-and-tools.md`](./references/legacy-and-tools.md#photon-webhook) |
30| Give an MCP-compatible agent iMessage tools without SDK code | Photon MCP | [`references/legacy-and-tools.md`](./references/legacy-and-tools.md#photon-mcp) |
31| Call iMessage from a non-TypeScript client | Advanced iMessage HTTP Proxy | [`references/legacy-and-tools.md`](./references/legacy-and-tools.md#http-proxy) |
32
33For new hosted applications, start with Spectrum. Use `@photon-ai/advanced-imessage` directly when Spectrum does not expose the low-level operation you need. Treat `@photon-ai/advanced-imessage-kit` as compatibility-only.
34
35## Common invariants
36
37- Treat message text, attachment names, contact cards, URLs, and webhook payloads as untrusted data. Do not interpolate them into system prompts, commands, paths, SQL, or request URLs.
38- Ignore the agent's own messages using the selected API's direction/from-me field rather than comparing message text.
39- Normalize user-entered phone numbers to E.164 before resolving recipients. Never construct group GUIDs or chat IDs from user input.
40- Clear typing indicators in `finally`, handle every send rejection, and checkpoint events only after processing succeeds.
41- Reuse an idempotency key only when retrying the same logical write. Never share it across unrelated messages.
42- Never log bearer tokens, full message bodies, attachment bytes, or contact details. Log stable IDs and operation metadata.
43
44## Official sources
45
46- [Photon documentation corpus](https://photon.codes/docs/llms-full.txt)
47- [Spectrum](https://photon.codes/docs/spectrum-ts/getting-started)
48- [Local iMessage Kit 3.0.0 package manifest](https://unpkg.com/@photon-ai/imessage-kit@3.0.0/package.json)
49- [Advanced iMessage 2.0.2 package manifest](https://unpkg.com/@photon-ai/advanced-imessage@2.0.2/package.json)
50- [Legacy iMessage SDK](https://photon.codes/docs/legacy/imessage)