Apple has no public iMessage API. Figment fills that gap with a user-approved connection to a signed-in Mac, then exposes a REST interface your app calls like any other HTTP service. The user grants access through Figment's hosted consent screen, and your app receives a scoped bearer token, not an Apple password. Reading history, searching conversations, and sending replies live behind exactly two scopes: messages:read and messages:send.
Why is a Mac required?
iMessage operates on a device-local basis: message history is accessible on a Mac signed in to the user's Apple Account. Figment runs a signed-in isolated Mac that hosts the native Messages app. Your application calls a REST API, and the Mac executes the Apple-native operations against its local message store.
A service can be in any of these states: connecting, needs_approval, syncing, ready, offline, reconnect_required, or revoked. ready is required for the service to accept read and send operations. Non-ready services reject requests outright. A ready state does not prove Automation permission, guaranteed delivery, complete history, or continuous uptime. The status endpoint enforces authorization as well, so it may return a non-2xx response for a revoked or non-ready connection instead of a diagnostic state object. Use figment.so/icloud/account to monitor and manage connection setup.
How do I register and connect?
Register your application at figment.so/icloud/developers to receive a client_id. Authorization uses PKCE with S256, and you generate a fresh verifier and state for each attempt:
GET https://figment.so/icloud/authorize
?client_id=YOUR_CLIENT_ID
&redirect_uri=https://your-app.example.com/callback
&response_type=code
&scope=messages%3Aread%20messages%3Asend
&state=OPAQUE_RANDOM_VALUE
&code_challenge=BASE64URL_SHA256_OF_VERIFIER
&code_challenge_method=S256
The redirect_uri is the exact HTTPS URL you registered, and its path is not fixed by Figment. When the user is redirected back, validate that the returned state matches the value you sent before the token exchange.
Figment's consent screen lets the user select an existing Mac connection and approve the requested scopes. When messages:send is in scope, the user selects which existing conversations your app may send into. That selection is recorded in the grant and enforced on every send. Figment issues the grant and token, and this is not an Apple-issued authorization redirect.
Exchange the authorization code for tokens:
POST https://figment.so/api/icloud/oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&client_id=YOUR_CLIENT_ID&redirect_uri=https%3A%2F%2Fyour-app.example.com%2Fcallback&code=AUTHORIZATION_CODE&code_verifier=YOUR_CODE_VERIFIER
The response includes access_token, refresh_token, expires_in (900 s for the access token), scope, and connection_id. Tokens are opaque strings, not JWTs. Store connection_id alongside your tokens. To refresh, send grant_type=refresh_token, client_id, and refresh_token as form fields, and store the new refresh token returned by each successful refresh. Refresh tokens rotate per grant, so serialize refresh calls per grant.
All paths below are relative to BASE_URL = https://figment.so/api/icloud.
How do I read conversations?
Call the chats and messages endpoints with messages:read. Both history and search require it, and the connection must be ready first.
Check connection status:
GET /v1/connections/{connection_id}
Authorization: Bearer ACCESS_TOKEN
{
"connection": {
"id": "con_...",
"mode": "live",
"services": {
"messages": { "state": "ready", "reason": null, "observedAt": 1794398400000 }
}
}
}
Each service entry is an object with state, reason, and observedAt (epoch milliseconds). Read connection.services.messages.state. Only granted services appear. A ready state confirms the connection is accepted but does not guarantee complete history, because older messages may still be arriving from iCloud.
List open chats:
GET /v1/connections/{connection_id}/chats?limit=20&offset=0
Authorization: Bearer ACCESS_TOKEN
Responses use {data, mode, offset, nextOffset, hasMore, historyComplete, scope}. Follow hasMore and nextOffset to paginate. nextOffset is null when exhausted. Use each chat item's guid as chatGuid in history and search calls. displayName may be absent.
Pull messages from a thread. URL-encode chatGuid from the chats response before placing it in a query string, because a raw + decodes as a space:
GET /v1/connections/{connection_id}/messages?chatGuid=iMessage%3B-%3B%2B15551234567&limit=20
Authorization: Bearer ACCESS_TOKEN
Message items include guid, text, isFromMe, and chatGuid. Check historyComplete and hasMore instead of treating an empty page as a definitive absence of history.
How do I search message history?
Call the search endpoint with the same messages:read scope. Full-text search runs against the locally available message store, and there is no separate search scope:
GET /v1/connections/{connection_id}/messages/search?query=invoice&chatGuid=iMessage%3B-%3B%2B15551234567&limit=20
Authorization: Bearer ACCESS_TOKEN
Coverage is bounded by history present on the Mac at query time. Accepted parameters are query, chatGuid, limit (default 20, max 100), and offset (max 10 000). When the grant covers selected conversations, chatGuid is required. Encode chatGuid with a URL builder.
A chat appearing in search results is not automatically authorized for sends. The messages:send grant must already include that exact existing conversation from the user's original approval. A search result alone does not confer send access.
How do I send a message without duplicates?
Submit the message with an Idempotency-Key, then poll the receipt with the same key.
Step 1, send:
POST /v1/connections/{connection_id}/messages/send
Authorization: Bearer ACCESS_TOKEN
Idempotency-Key: order-8821-shipped-notify
Content-Type: application/json
{"chatGuid": "iMessage;-;+15551234567", "text": "Your order has shipped. Tracking: 1Z999AA1."}
Generate and persist the Idempotency-Key before the first request, and derive it from a stable intent identifier such as an order ID plus an action label. Do not use a body hash alone, because two separately intended identical messages would share that hash and wrongly merge. A repeated request with the same key and body returns the same recorded action, and a changed body is rejected.
Step 2, poll the receipt:
GET /v1/connections/{connection_id}/messages/receipt
Authorization: Bearer ACCESS_TOKEN
Idempotency-Key: order-8821-shipped-notify
Fresh send result (sandbox):
{
"data": {
"idempotencyKey": "order-8821-shipped-notify",
"state": "simulated",
"delivery": "simulated",
"retrySend": false
},
"mode": "sandbox",
"replayed": false
}
Re-polling the same receipt returns replayed: true. Receipt states:
| State | Meaning |
|---|---|
submitted | Bridge accepted; delivery in progress |
delivered | Confirmed delivered to recipient's device |
read | Recipient opened the message |
failed | Send failed; same key returns the recorded failure, not a new attempt |
unknown | Outcome could not be determined |
simulated | Sandbox result; no real recipient contacted |
A submitted state is not proof of delivery. A failed receipt is preserved as is, and you decide independently whether to start a fresh action under a new key. An unknown outcome means the system could not confirm whether the message was sent: hold the original key, wait, and re-poll. Never resend an unknown outcome under a new key.
How does an AI agent use this API?
An agent uses the same REST endpoints with a stored bearer token. It surfaces context with GET /messages/search, produces a reply, and submits it with POST /messages/send. Idempotency rules apply, so unknown outcomes must not trigger a blind retry. Confirm the chatGuid is in the granted conversation set before sending.
OAuth for iCloud includes an MCP server, listed on the product page. To use these operations with custom tools in an MCP-compatible workflow, build a local adapter over the Figment REST API.
Does it cover SMS, MMS, and RCS?
Yes, when Messages in iCloud is enabled. Apple's forwarding guide explains that Messages in iCloud includes SMS, MMS, RCS, and iMessage, with forwarding built in when Messages in iCloud is enabled on iPhone. Previously synced carrier history remains available on the Mac when the iPhone is offline, and phone availability affects only new carrier messages sent or received. If your use case covers mixed threads, confirm the iPhone is set up with Messages in iCloud before building the read path.
How much does it cost?
Sandbox access is free. Messages is part of the Full iCloud suite, which costs the developer $29 per month per connected Apple Account. For live access, request a demo. Mac rental is a separate product line.
Start in sandbox first at figment.so/icloud/developers. Set up a live connection when you are ready to work with your own messages. Manage an existing grant at figment.so/icloud/account.