OAuth for iCloud developer guide

Search Message History Without Missing Results

Searches come back short for two reasons: the Mac has not finished syncing, or the message was never downloaded to it. Check the service state and historyComplete, then page with hasMore and nextOffset.

Figment editorial teamPublished Updated Facts checked November 12, 2026

To search iMessage history without missing results, confirm the messages service is ready, page with hasMore and nextOffset, and treat historyComplete: false as a partial result. A search that returns 12 results when the inbox holds 400 has one of two causes: sync lag, or messages that were never downloaded to the connected Mac. Each needs a different response, and no offset value recovers messages the Mac does not hold.

Why do searches return incomplete results?

Searches run only against the messages available on the connected Mac (OAuth for iCloud). Apple's Messages in iCloud syncs message history, including SMS, MMS, RCS, and iMessage, across signed-in devices, but that transfer takes time (Apple Support). While a sync is in progress, a search returns only what has arrived locally.

After sync completes, results are still limited to what the Mac holds. Messages that were never downloaded to this Mac do not appear. Both causes look the same: a result set smaller than expected, with no error code to tell them apart.

How do I check service state before a search?

Call the connection endpoint and read connection.services.messages.state:

GET /v1/connections/{connection_id}
Authorization: Bearer ACCESS_TOKEN
{
  "connection": {
    "id": "con_abc123",
    "mode": "live",
    "services": {
      "messages": {
        "state": "ready",
        "observedAt": 1731388800000
      }
    }
  }
}

Possible states are connecting, needs_approval, syncing, ready, offline, reconnect_required, and revoked. Read operations fail on non-ready connections, so check the state before any search.

syncing is not an error. A fresh connection passes through it while history downloads. Poll until ready, or show your user a "history loading" note. needs_approval and reconnect_required need the account holder to act in the account connection screen. Your application cannot resolve them.

Which search parameters should I use?

GET /v1/connections/{connection_id}/messages/search
  ?query=contract%20renewal
  &chatGuid={ENCODED_CHAT_GUID}
  &limit=50
  &offset=0
Authorization: Bearer ACCESS_TOKEN
ParameterDescription
querySearch term applied to message text
chatGuidScope search to one conversation; required for a selected-conversation grant
limitResults per page, 1 to 100 (default 20)
offsetResults to skip; maximum 10 000

Build the URL with a URL encoder. Take chatGuid values from GET /v1/connections/{connection_id}/chats and do not construct them from phone numbers. A chatGuid contains literal + characters, and a raw + in a query string decodes as a space, which silently breaks the lookup.

Offset is capped at 10 000. If a search would match more than that, narrow the query or scope it with chatGuid.

How do I paginate with hasMore and nextOffset?

Pass nextOffset as offset on the next request until hasMore is false or nextOffset is null. Each response carries these fields:

{
  "data": [...],
  "mode": "live",
  "offset": 0,
  "nextOffset": 50,
  "hasMore": true,
  "historyComplete": true,
  "scope": "messages:read"
}

An empty data array is valid and not an error. historyComplete: false means the Mac's sync is still in progress and the results are a snapshot of partial history. Tell your users instead of presenting the set as complete. New messages that arrive during a paginated search can shift the result set, so pages are not a stable snapshot.

The pagination model in Python pseudocode:

import urllib.parse

def search_messages(connection_id, token, query, chat_guid=None):
    base = "https://figment.so/api/icloud/v1"
    params = {"query": query, "limit": 50, "offset": 0}
    if chat_guid:
        params["chatGuid"] = chat_guid

    results = []
    history_complete = False

    while True:
        url = (
            f"{base}/connections/{connection_id}/messages/search"
            f"?{urllib.parse.urlencode(params)}"
        )
        resp = get(url, headers={"Authorization": f"Bearer {token}"})
        # get() is your HTTP client call; raise on non-2xx before this point

        results.extend(resp["data"])
        history_complete = resp.get("historyComplete", False)

        if not resp.get("hasMore") or resp.get("nextOffset") is None:
            break

        next_offset = resp["nextOffset"]
        if next_offset <= params["offset"]:
            break  # non-advancing offset guard
        params["offset"] = next_offset

    return results, history_complete

Pass a chat_guid from the chats endpoint to query one conversation. When history_complete is False on return, warn your user.

Does search include SMS, MMS, and RCS?

Yes. iMessage and carrier messages share the same search endpoint. SMS, MMS, and RCS need an eligible iPhone that is turned on, online, and signed into the same Apple Account (Apple Support). With Messages in iCloud enabled, carrier message sync is built in and no separate Text Message Forwarding switch is needed.

If the iPhone is offline, existing carrier history can stay on the Mac but new messages do not arrive. A ready state reflects the iMessage connector. It does not guarantee that carrier history is current.

How do I get started?

Figment handles iCloud sign-in, trusted-device approval, and the permission grant. Your app receives a scoped access token and never the Apple password. Connect Apple Account to try the search and pagination endpoints.

For the full API reference see iMessage API for Search, Replies, and Agent Actions. For reading and filtering in Python see Read and Search iMessages with Python. For sending and the idempotency model see Send an iMessage from Node.js Without Duplicates.

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.