> ## Documentation Index
> Fetch the complete documentation index at: https://inkbox.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# iMessage

> Reach humans in their native messaging app through shared service or a dedicated line, send tapbacks, and filter who can reach your agent

Agents can chat with humans over iMessage — blue bubbles, tapbacks, read receipts, typing indicators, and media — through the shared **Inkbox iMessage router** or a dedicated line.

Choose the setup that fits your onboarding flow:

* **Dedicated line:** Can start new 1:1 conversations and group chats.
* **Shared service:** Dynamically assigned when someone connects to your agent; the human starts the conversation.
* **Organization-owned shared pool (Beta), available only by request:** Your organization has its own pool of shared iMessage numbers. [Connect a recipient through the API](https://inkbox.ai/docs/api/imessage/connections.md#connect-a-recipient) and submit one opening message before their first reply.

With standard shared service, a human connects by texting the router. Inkbox assigns the conversation to your identity without exposing the shared number in API responses. Dedicated lines belong to your organization and can be attached to an iMessage-enabled identity. Agents can also place and receive [voice calls](https://inkbox.ai/docs/capabilities/phone#imessage-voice-calls) over shared and dedicated iMessage lines.

By default, a dedicated line automatically shares the identity's display name, or its handle when no display name is set. Its avatar is included when one exists; name-only sharing remains active when the avatar is absent or removed. Set `contact_sharing_enabled` to `false` to remove the automatic sharing profile for that dedicated line. The preference belongs to the identity and remains saved while no line is attached.

**Beta:** Organization-owned iMessage routers are available upon request. They give an organization its own configurable router number for connecting humans to agents. An organization-owned router serves the organization rather than attaching to one agent. Organizations without one continue to use the shared Inkbox router.

Conversations remain the stable key in every setup. Agent-facing APIs identify threads by `conversation_id`; outbound 1:1 messages can also be addressed by the recipient's E.164 phone number. Every conversation belongs to one agent identity in your organization, and an identity-scoped API key sees only that identity's threads.

Shared-service identities support 1:1 conversations. Dedicated lines also support group chats with 2-8 remote participants.

## Receive-only conversations

Dedicated lines can receive 1:1 messages from non-phone sender addresses, such as `sender@example.com`. These messages appear in conversation and message reads and use the normal `imessage.received` webhook. Shared service and group chats still require E.164 phone numbers.

Treat `remote_number` as a sender address, not a guaranteed phone number. Preserve the string as returned and use `conversation_id` to read its history. The same address can appear in connection responses and a 1:1 conversation's `participants` list. SDK fields remain strings; Python uses `remote_number`, and TypeScript uses `remoteNumber`. Raw webhook JSON uses `remote_number`.

Conversations with non-phone senders are **receive-only**. Sending a message, tapback, typing indicator, or explicit read receipt into one returns `422` with `detail.error: "recipient_not_e164"`. Outbound `to` values must still be E.164 phone numbers. An active connection does not override this requirement.

Before an automated reply, check that the 1:1 sender address is an E.164 phone number and the connection is active. Do not reject an incoming message just because you cannot reply to it. Continue to handle send errors: a phone-number address alone does not guarantee that a send is allowed or will be delivered.

## Enabling iMessage on an identity

iMessage reachability is **opt-in per identity** and defaults to off. Enable it at create time or later:

```python Python theme={null}
# At create time
identity = inkbox.create_identity("my-agent", imessage_enabled=True)

# Or toggle later
identity.update(imessage_enabled=True)
print(identity.imessage_enabled, identity.imessage_filter_mode)
```

```typescript TypeScript theme={null}
// At create time
const identity = await inkbox.createIdentity("my-agent", { imessageEnabled: true });

// Or toggle later
await identity.update({ imessageEnabled: true });
console.log(identity.imessageEnabled, identity.imessageFilterMode);
```

```bash CLI theme={null}
# At create time
inkbox identity create my-agent --imessage-enabled

# Or toggle later
inkbox identity update my-agent --imessage-enabled true
```

Automatic contact sharing defaults to on for new identities and can be toggled independently. Identities that already had dedicated lines when the feature launched were initialized to off:

```python Python theme={null}
identity.update(contact_sharing_enabled=False)
```

```typescript TypeScript theme={null}
await identity.update({ contactSharingEnabled: false });
```

```bash CLI theme={null}
inkbox identity update my-agent --contact-sharing-enabled false
```

You can also claim and attach a dedicated line while creating or updating an identity:

```python Python theme={null}
identity = inkbox.create_identity(
    "dedicated-agent",
    imessage_enabled=True,
    claim_imessage_number=True,
)

# Or claim an unattached line for the organization
line = inkbox.imessages.claim_number(
    idempotency_key="claim-dedicated-agent-01",
)
```

```typescript TypeScript theme={null}
const identity = await inkbox.createIdentity("dedicated-agent", {
  imessageEnabled: true,
  claimIMessageNumber: true,
});

// Or claim an unattached line for the organization
const line = await inkbox.imessages.claimNumber({
  idempotencyKey: "claim-dedicated-agent-01",
});
```

See [Dedicated lines](https://inkbox.ai/docs/api/imessage.md#dedicated-lines) and [Manage identities](https://inkbox.ai/docs/api/identities/manage.md) for the raw REST contract.

While an identity is disabled, the router will not connect new recipients to it, sends from it are rejected, and inbound traffic for it is not delivered.

## Connecting a human to your agent

Organizations with their own organization-owned shared iMessage pool can use the
[connect endpoint](https://inkbox.ai/docs/api/imessage/connections.md#connect-a-recipient) instead of the
router. This access is available **only by request** through
[support@inkbox.ai](mailto:support@inkbox.ai). An admin API key submits the agent
identity, recipient number, required opening message, and a client-generated
`Idempotency-Key`. Success means the opening message was accepted, not delivered.
Each new connection accepts at most one opening; up to three countable openings
are allowed across reconnects on the same number before a reply. Further messages
wait for the recipient's reply unless prior direct engagement
on the selected number already satisfies that requirement.

A router can also connect recipients to an organization-owned shared pool; using
a router does not determine which kind of shared number carries the conversation.

For standard shared service, humans connect by texting a command to the router. Resolve the router number at runtime — it can change, so never hardcode it:

```python Python theme={null}
router = inkbox.imessages.get_triage_number()
print(router.number)           # the router's E.164 number
print(router.connect_command)  # e.g. 'connect @my-agent'
```

```typescript TypeScript theme={null}
const router = await inkbox.imessages.getTriageNumber();
console.log(router.number);          // the router's E.164 number
console.log(router.connectCommand);  // e.g. 'connect @my-agent'
```

```bash CLI theme={null}
inkbox imessage triage-number
# number          the router's E.164 number
# connectCommand  e.g. 'connect @my-agent'
```

Tell your human: *text `connect @my-agent` to the router number*. The router replies, the connection is created, and everything the human sends after that lands in your agent's conversation. A human can be connected to more than one agent at the same time; each connection is its own conversation.

Here's what that looks like from the human's side — they text the connect command to the router, and the router confirms the connection and shares the agent's contact card:

![An iMessage thread with the Inkbox iMessage router: the human texts the connect command, and the router confirms the connection and sends the agent's contact card](https://mintcdn.com/inkbox/ElPOVqFMWvNNV67g/images/imessage/connect-example.png?fit=max\&auto=format\&n=ElPOVqFMWvNNV67g\&q=85\&s=4d8626e553681ba8c5037bcfd6ffbaad)

### Inactive shared connections

Standard shared-service connections can expire after inactivity. By default, both
conditions must hold: the connection is at least **14 days old**, and it has had
**no incoming or outgoing message recorded for 14 days**. A recorded outgoing
message counts as activity even if delivery fails. Dedicated lines and
organization-owned shared pools are not subject to this expiry policy.

Expiry disconnects the recipient without deleting conversation history. It does
not send a notification at the time of expiry. If the recipient later messages
the expired connection, they can receive an automatic reply. If they already have
a valid active connection to the same agent on another number, the reply asks
them to resend their message to that current number. Otherwise, it directs them
to reconnect through the router. It never reveals another agent's connection.
The original message is not forwarded, delivered to the agent, or used to reopen
the expired connection. Repeated messages may not repeat the notice immediately.
The conversation reports `assignment_status: "released"`.
Sending to an expired connection returns `409` with
`detail.error: "imessage_connection_expired"` and a readable explanation in
`detail.message`.

If reconnection is needed, ask the recipient to text `connect @my-agent` to the
[current router number](https://inkbox.ai/docs/api/imessage/router.md#get-router-number), replacing
`my-agent` with your agent's handle. Sending to the old conversation does not
reconnect them automatically. Wait for the recipient to reconnect and message
your agent before sending again.

Shared numbers can be reused. If the recipient later connects to a different
agent on the same number, their messaging app may show those messages in the
same number-based thread. The connection confirmation identifies the agent;
your agent does not gain access to another agent's conversation history.

## Reading and replying

Once a sender has messaged your agent, list conversations and read messages. Reply only to a conversation that supports outbound messages. Replies can target the conversation by ID or the recipient by E.164 phone number:

```python Python theme={null}
import re

# List conversations with latest-message previews
convos = identity.list_imessage_conversations(limit=20)
for c in convos:
    print(c.id, c.remote_number, c.unread_count, c.latest_text)

# Read a thread
msgs = identity.list_imessages(conversation_id=convos[0].id, limit=50)

# Reply only to an active phone-number conversation
conversation = convos[0]
if conversation.assignment_status == "active" and re.fullmatch(
    r"\+[1-9][0-9]{1,14}", conversation.remote_number or ""
):
    identity.send_imessage(
        conversation_id=conversation.id,
        text="On it — give me two minutes.",
    )

# Or address the connected recipient directly
identity.send_imessage(to="+15555550123", text="Done!")
```

```typescript TypeScript theme={null}
// List conversations with latest-message previews
const convos = await identity.listIMessageConversations({ limit: 20 });
for (const c of convos) {
  console.log(c.id, c.remoteNumber, c.unreadCount, c.latestText);
}

// Read a thread
const msgs = await identity.listIMessages({ conversationId: convos[0].id, limit: 50 });

// Reply only to an active phone-number conversation
const conversation = convos[0];
if (
  conversation.assignmentStatus === "active" &&
  /^\+[1-9][0-9]{1,14}$/.test(conversation.remoteNumber ?? "")
) {
  await identity.sendIMessage({
    conversationId: conversation.id,
    text: "On it — give me two minutes.",
  });
}

// Or address the connected recipient directly
await identity.sendIMessage({ to: "+15555550123", text: "Done!" });
```

```bash CLI theme={null}
# List conversations with latest-message previews
inkbox imessage conversations -i my-agent --limit 20

# Read a thread
inkbox imessage conversation <conversation-id> -i my-agent

# Reply to an active phone-number conversation
inkbox imessage send -i my-agent \
--conversation-id <conversation-id> \
--text "On it — give me two minutes."
```

When sending to a number without an active conversation, the remediation depends on the setup. On standard shared service, a `404` tells the recipient to text the connect command to the router; an expired connection instead returns `409 imessage_connection_expired`. A dedicated line can start a new conversation. For a organization-owned shared pool, use [connect](https://inkbox.ai/docs/api/imessage/connections.md#connect-a-recipient), subject to its eligibility checks. If a previous conversation is no longer active, sends into it return `409`. Conversation reads carry an `assignment_status` field (`"active"` or `"released"`) so you can spot a disconnect before sending, and [`GET /assignments`](https://inkbox.ai/docs/api/imessage/conversations#list-connections) lists who is currently connected.

Rolling 24-hour outbound limits vary by plan. See [Pricing](https://inkbox.ai/pricing) for current limits. When the cap is reached, `429` responses carry `Retry-After` and `X-RateLimit-*` headers.

Dedicated lines also limit agent-initiated conversations to 10 new recipients per rolling hour and 40 per rolling 24 hours. Existing recipients and recipients who message the line first do not consume these first-contact slots. If either window is full, sends to new recipients return `429` until enough slots age out.

### Before the first reply

For 1:1 messages on **every line type, including dedicated lines**, wait for a qualifying recipient reply before sending phone numbers, links, or media. Until then, keep each message under 160 characters (159 maximum). These content restrictions do not apply to [group sends](https://inkbox.ai/docs/api/imessage/groups.md). They do not let a shared-service identity send before its connection is ready.

Send at most **three 1:1 messages total** before the recipient's first qualifying reply. This ceiling does not grant additional sends when a connection requires an earlier reply. After the first qualifying reply, the three-message cap ends; other unanswered-message limits still apply.

Exceeding the pre-reply message cap or violating these content requirements returns `422` before queuing a message. Read `detail.error` to identify the reason:

| Error | Meaning |
| :- | :- |
| `imessage_unanswered_followup_limit` | The pre-reply three-message limit has been reached; wait for the recipient's reply |
| `imessage_reply_required_for_phone_numbers` | Wait for the recipient's reply before including a phone number |
| `imessage_reply_required_for_links_or_media` | Wait for the recipient's reply before including links or media |
| `imessage_opening_message_too_long` | Keep the pre-reply message to 159 characters or fewer |

A numeric identifier that resembles a phone number can also trigger the phone-number error. Wait for a reply before including it. Once a qualifying reply arrives, these pre-reply content restrictions no longer apply; other send requirements and limits still do. See [Send message](https://inkbox.ai/docs/api/imessage/messages.md#before-the-first-reply) for the API contract.

## Reply to a specific message

Use a conversation that supports outbound messages. A reply target does not make a [receive-only conversation](#receive-only-conversations) replyable.

With SDK and CLI `0.7.13` or later, reply to a message in a 1:1 or group conversation. Keep `conversation_id` for the whole chat, and use `reply_to_message_id` to choose the exact message. Native threading is used when supported. The default `plain_reply_fallback: true` allows an ordinary response in that same conversation when the target is known to use SMS/RCS or was downgraded. Without a target, sending behaves as before.

```python Python theme={null}
message = identity.get_imessage("1a90e8b0-0e1e-485f-b316-28f7dfa96afd")
reply = identity.send_imessage(
    conversation_id=message.conversation_id,
    reply_to_message_id=message.id,
    plain_reply_fallback=True,
    text="Friday works for me.",
)
thread = identity.get_imessage_thread(message.id, limit=50)
for item in thread.messages:
    print(item.id, item.reply_to_message_id, item.content)
if thread.next_cursor:
    next_page = identity.get_imessage_thread(
        message.id, cursor=thread.next_cursor,
    )
if thread.thread_id:
    same_thread = identity.get_imessage_conversation_thread(
        message.conversation_id, thread.thread_id,
    )
```

```typescript TypeScript theme={null}
const message = await identity.getIMessage("1a90e8b0-0e1e-485f-b316-28f7dfa96afd");
const reply = await identity.sendIMessage({
  conversationId: message.conversationId,
  replyToMessageId: message.id,
  plainReplyFallback: true,
  text: "Friday works for me.",
});
const thread = await identity.getIMessageThread(message.id, { limit: 50 });
for (const item of thread.messages) {
  console.log(item.id, item.replyToMessageId, item.content);
}
if (thread.nextCursor) {
  const nextPage = await identity.getIMessageThread(message.id, {
    cursor: thread.nextCursor,
  });
}
if (thread.threadId) {
  const sameThread = await identity.getIMessageConversationThread(
    message.conversationId, thread.threadId,
  );
}
```

```bash CLI theme={null}
inkbox imessage send -i my-agent \
--conversation-id <conversation-id> \
--reply-to-message-id <message-id> \
--text "Friday works for me."

inkbox imessage thread <message-id> -i my-agent --limit 50
inkbox imessage conversation-thread <conversation-id> <thread-id> -i my-agent
```

`reply_to_message_id` identifies the immediate parent when visible and resolved. A non-null parent identifies a reply. `thread_root_message_id` identifies the original message when available. `thread_id` is a separate opaque UUID for reading the whole thread, not a signal that replies exist. A newly received or confirmed sent standalone message can have its own thread ID and itself as the root before anyone replies. Thread reads return the visible root and replies oldest first, with cursor pagination. A normal conversation read stays flat and includes all messages. Filter that list with `conversation_id` and `thread_id` when you need its existing newest-first order.

The same fields appear when another person replies natively, including within a group. Metadata may be null or absent for pending messages, older history, or unavailable references. A null parent does not rule out an unresolved or hidden reply relationship. An ordinary fallback has no parent and does not join the target's native thread; it can have its own standalone thread ID. Use the returned message metadata, not the requested target, to decide how to display a response.

To require native threading, pass `plain_reply_fallback=False` in Python, `plainReplyFallback: false` in TypeScript, or `--no-plain-reply-fallback` in the CLI. Missing, inaccessible, pending, failed, or unresolved targets remain errors in either mode. Fallback does not change recipients or send limits, force SMS/RCS, or automatically resend after delivery rejection, a timeout, or an uncertain result. It only covers a target already known to have an unsupported transport before sending. If an apparently eligible native reply is rejected, it fails even when fallback is enabled.

A queued response does not guarantee delivery. Poll [Get message](https://inkbox.ai/docs/api/imessage/messages.md#get-message) for its current status and errors. A target that becomes unavailable before sending produces `status: "error"` and `error_code: "imessage_reply_target_unavailable"`. Delivery webhooks do not cover every failure before sending, so they supplement polling rather than replace it.

In the [Inkbox Console](https://inkbox.ai/console), click a message to focus the reply composer, then write your reply and send. Quoted context stays above each reply in the conversation. Click a quoted original to find and highlight it without opening a separate thread view. The console uses the default reply fallback described above. Cancel the quoted target to return to an ordinary message without losing your draft. Reply targeting is unavailable in a disconnected 1:1 conversation.

Through MCP, send a targeted reply with `inkbox_imessage_send`, including `conversation_id`, `reply_to_message_id`, and the expected `recipient` or group recipient list. `plain_reply_fallback` defaults to `true`; set it to `false` to require native threading. See [MCP reply inputs](https://inkbox.ai/docs/mcp-server.md#imessage-replies).

To read a thread, use `inkbox_conversation_get` with `channel: "imessage"`, the `conversation_id`, and either `reply_thread_id` or `reply_thread_message_id`. Thread pages use `cursor` and return `next_cursor`; omit the thread selector to keep the ordinary conversation read.

See [Messages](https://inkbox.ai/docs/api/imessage/messages.md#reply-to-a-specific-message) for the request fields and [Get conversation thread](https://inkbox.ai/docs/api/imessage/conversations.md#get-conversation-thread) for reading by thread ID.

## Dedicated-line group chats

[Companion mode](https://inkbox.ai/docs/capabilities/companion-mode.md#group-message-example) supports sponsor-invited participation in eligible dedicated-line groups. It requires a new sponsor message, verified current membership, and an available group. A dedicated line alone does not admit every externally started group. Reply using its canonical conversation ID; shared iMessage service remains 1:1.

An identity with an active attached dedicated iMessage line can start a group by passing a list of 2-8 distinct E.164 phone numbers to the existing send endpoint. The response's `conversation_id` is the canonical thread key; use it for every later reply into that exact group.

```python Python theme={null}
group = identity.send_imessage(
    to=["+14155550100", "+14155550101"],
    text="Planning starts at 10.",
    send_style="confetti",
)
identity.send_imessage(
    conversation_id=group.conversation_id,
    text="I moved the start time to 10:30.",
    send_style="gentle",
)
groups = identity.list_imessage_conversations(include_groups=True)
```

```typescript TypeScript theme={null}
const group = await identity.sendIMessage({
  to: ["+14155550100", "+14155550101"],
  text: "Planning starts at 10.",
  sendStyle: "confetti",
});
await identity.sendIMessage({
  conversationId: group.conversationId,
  text: "I moved the start time to 10:30.",
  sendStyle: "gentle",
});
const groups = await identity.listIMessageConversations({ includeGroups: true });
```

```bash CLI theme={null}
inkbox imessage send -i my-agent \
--to +14155550100,+14155550101 \
--text "Planning starts at 10." \
--send-style confetti

inkbox imessage conversations -i my-agent --include-groups
inkbox imessage send -i my-agent \
--conversation-id <conversation-id> \
--text "I moved the start time to 10:30." \
--send-style gentle
```

Group lists are opt-in for backwards compatibility. Pass `include_groups=true` when listing iMessage conversations or messages, or fetch a known group directly by `conversation_id`. Group messages expose `sender_number`, a participant snapshot, and per-recipient delivery state. The MCP conversation-list tool keeps the same opt-in switch. Through MCP, `inkbox_imessage_send` accepts a singular `recipient` for unchanged 1:1 sends or a list of 2-8 recipients for group creation. Group replies include both `conversation_id` and the expected current recipient list.

Group creation is asynchronous. Conversations report `group_creation_status` as `creating`, `not_created`, or `ready`. While creating, the conversation and queued messages exist locally before the remote thread is established; later sends to the same conversation wait for the creation send to resolve. If the first attempt fails, its message remains visible in the same local conversation; send the next message using that `conversation_id` to retry creation. A successful retry keeps the same local conversation and establishes the group used by later sends.

Conversation membership history is best-known and append-only: newly added members may appear only after later activity, while members who leave remain in the stored history. Sends into an existing group resolve its current recipients and apply send checks to each one. There is no group-member add/remove API in V1, and changing a direct `to` list selects or creates another group instead of editing membership. After the stored history grows, an old participant subset can create a separate group; use `conversation_id` to preserve thread continuity. Tapbacks are supported for ready groups, and expressive send styles and media are supported on group creation and replies.

MCP can create a dedicated group for 2-8 recipients, reply to a known group, read group delivery state, and react to inbound group messages. A group reply includes the expected participant set from the conversation read; if live membership changed, Inkbox rejects the reply before sending.

See [Group chats](https://inkbox.ai/docs/api/imessage/groups.md) for exact request, response, matching, and error semantics.

## Tapbacks

Choose a phone-number conversation or a ready group. [Receive-only conversations](#receive-only-conversations) do not support outbound tapbacks.

Agents can react to inbound messages in 1:1 and ready group conversations with `love`, `like`, `dislike`, `laugh`, `emphasize`, `question`, or `eyes` (which displays as 👀). iMessage has no concept of reacting to your own messages, so an agent can't tapback its own.

```python Python theme={null}
sent = identity.send_imessage_reaction(message_id=msgs[0].id, reaction="like")

# Live tapbacks come back on message reads, oldest first
for r in msgs[0].reactions or []:
    print(r.direction, r.reaction, r.custom_emoji)

# Take your own tapback back
identity.remove_imessage_reaction(sent.id)
```

```typescript TypeScript theme={null}
const sent = await identity.sendIMessageReaction({ messageId: msgs[0].id, reaction: "like" });

// Live tapbacks come back on message reads, oldest first
for (const r of msgs[0].reactions ?? []) {
  console.log(r.direction, r.reaction, r.customEmoji);
}

// Take your own tapback back
await identity.removeIMessageReaction(sent.id);
```

```bash CLI theme={null}
inkbox imessage react <message-id> -i my-agent --reaction like
inkbox imessage unreact <reaction-id> -i my-agent
```

Tapbacks follow Apple's semantics in both conversation types: **one live tapback per sender per message**. Sending a second tapback to the same message replaces your first, and when a human swaps or removes theirs, message reads reflect it. An agent can also take its own tapback back so the bubble carries no reaction at all — see [Remove tapback](https://inkbox.ai/docs/api/imessage/reactions.md#remove-tapback), which covers how a failed removal leaves the tapback in place for a retry. Humans can also react with any emoji — those arrive as `reaction: "custom"` with the emoji in `custom_emoji`. Arbitrary custom-emoji tapbacks are receive-only; outbound sends accept the classic six plus the named `eyes` value, not a literal emoji. Group reactions have `assignment_id: null` and use `remote_number` to identify the participant.

## Read receipts, typing, and media

Use a phone-number conversation for these 1:1 actions. Reading history is supported for [receive-only conversations](#receive-only-conversations), but sending a read receipt or typing indicator is not.

Round out the native feel in 1:1 conversations: send a read receipt when your agent has read the thread and show a typing indicator while it works. These operations are available through the API, SDKs, and CLI, but are intentionally not exposed as MCP tools. Media also works in group sends, but group read receipts and typing indicators are not supported.

```python Python theme={null}
# Read receipt — the human sees "Read" under their message
identity.mark_imessage_conversation_read(convos[0].id)

# Typing indicator while the agent prepares a reply
identity.send_imessage_typing(convos[0].id)

# Upload media (max 10 MiB), then send the returned URL
upload = identity.upload_imessage_media(
    content=open("chart.png", "rb").read(),
    filename="chart.png",
    content_type="image/png",
)
identity.send_imessage(
    conversation_id=convos[0].id,
    media_urls=[upload.media_url],
)
```

```typescript TypeScript theme={null}
// Read receipt — the human sees "Read" under their message
await identity.markIMessageConversationRead(convos[0].id);

// Typing indicator while the agent prepares a reply
await identity.sendIMessageTyping(convos[0].id);

// Upload media (max 10 MiB), then send the returned URL
const upload = await identity.uploadIMessageMedia({
  content: await readFile("chart.png"),
  filename: "chart.png",
  contentType: "image/png",
});
await identity.sendIMessage({
  conversationId: convos[0].id,
  mediaUrls: [upload.mediaUrl],
});
```

```bash CLI theme={null}
# Read receipt
inkbox imessage mark-conversation-read <conversation-id> -i my-agent

# Typing indicator
inkbox imessage typing <conversation-id> -i my-agent

# Upload media, then send the returned URL
inkbox imessage upload-media ./chart.png -i my-agent --content-type image/png
inkbox imessage send -i my-agent \
--conversation-id <conversation-id> \
--media-url <media-url>
```

Expressive **send styles** work on 1:1 messages and dedicated-line group creation or replies. Pass `send_style` with values like `slam`, `confetti`, `lasers`, or `invisible` (invisible ink); styles can also accompany media. See the [Messages reference](https://inkbox.ai/docs/api/imessage/messages.md#send-styles) for the full list.

## Filtering who can reach your agent

iMessage uses the same [phone communication list](https://inkbox.ai/docs/capabilities/phone#filtering-inbound-calls-and-texts) as SMS and calls, for incoming and outgoing communication. The identity owns the list whether it uses shared service or a dedicated line. You can configure the list without assigning a dedicated number.

For a shared policy, `imessage_filter_mode` is an alias of `phone_filter_mode`. Setting either sets both receiving and sending defaults; conflicting values in one update return `422`. New rules omit direction by default and cover `both`:

* **`blacklist`** (default): unmatched numbers are permitted.
* **`whitelist`**: unmatched numbers are denied.

An applicable exact-number allow or block takes precedence in either mode.

The following write examples require an admin API key. Agent keys can read their permitted rules but cannot create, update, or delete them. You can also manage rules in the [Inkbox Console](https://inkbox.ai/console).

```python Python theme={null}
# Block one number
rule = inkbox.imessage_contact_rules.create(
    "my-agent", action="block", match_target="+15555550999",
)

# Review the identity's rules
for r in inkbox.imessage_contact_rules.list("my-agent"):
    print(r.action, r.match_target, r.status)

# Flip to whitelist mode (admin API key required)
identity.update(imessage_filter_mode="whitelist")
```

```typescript TypeScript theme={null}
// Block one number
const rule = await inkbox.imessageContactRules.create("my-agent", {
  action: "block",
  matchTarget: "+15555550999",
});

// Review the identity's rules
for (const r of await inkbox.imessageContactRules.list("my-agent")) {
  console.log(r.action, r.matchTarget, r.status);
}

// Flip to whitelist mode (admin API key required)
await identity.update({ imessageFilterMode: "whitelist" });
```

```bash CLI theme={null}
# Block one number
inkbox imessage contact-rule create -i my-agent \
--action block --match-target +15555550999

# Review the identity's rules
inkbox imessage contact-rule list -i my-agent

# Flip to whitelist mode (admin API key required)
inkbox identity update my-agent --imessage-filter-mode whitelist
```

### Directional permissions and connections

With SDK/CLI `0.7.3` or later, use `phone_inbound_filter_mode` and `phone_outbound_filter_mode` for independent defaults. There is no separate iMessage pair. Inbound means from the person to your agent; outbound means from your agent to the person. Rules accept `direction: "inbound"`, `"outbound"`, or `"both"`. Inbound permission alone does not permit a reply. See the [phone configuration example](https://inkbox.ai/docs/capabilities/phone#separate-receiving-and-sending).

Shared-line connect and reconnect require both effective permissions. A `both` rule is not required when the defaults already permit both directions. Connecting never inserts a rule or changes permissions. Existing connections remain inspectable after policy changes; subsequent traffic checks its own direction. Dedicated-line traffic retains per-direction checks.

A message needs ordinary or valid [Companion permission](https://inkbox.ai/docs/capabilities/companion-mode.md) to reach the agent. An outbound denial returns `403`. See [iMessage contact rules](https://inkbox.ai/docs/api/imessage/contact-rules.md) for directional list filters, consolidation, and atomic one-side updates.

## Reacting to events in real time

Inbound messages and tapbacks are delivered through [webhook subscriptions](https://inkbox.ai/docs/api/webhooks/subscriptions.md) owned by the **agent identity**, regardless of whether it uses shared service or a dedicated line. The same subscription can also carry the outbound delivery-lifecycle events — `imessage.sent`, `imessage.delivered`, and `imessage.delivery_failed` — so your agent knows when a reply actually landed:

```python Python theme={null}
inkbox.webhooks.subscriptions.create(
    agent_identity_id=identity.id,
    url="https://yourapp.example.com/webhooks/inkbox",
    event_types=["imessage.received", "imessage.reaction_received"],
)
```

```typescript TypeScript theme={null}
await inkbox.webhooks.subscriptions.create({
  agentIdentityId: identity.id,
  url: "https://yourapp.example.com/webhooks/inkbox",
  eventTypes: ["imessage.received", "imessage.reaction_received"],
});
```

```bash CLI theme={null}
inkbox webhook subscription create \
--agent-identity-id <identity-id> \
--url https://yourapp.example.com/webhooks/inkbox \
--event-type imessage.received \
--event-type imessage.reaction_received
```

See [iMessage webhooks](https://inkbox.ai/docs/api/imessage/webhooks.md) for payload shapes and [Signing keys](https://inkbox.ai/docs/signing-keys.md) for signature verification. If your endpoint requires bearer auth, add `auth_token="your-endpoint-token"` (Python), `authToken` (TypeScript), or `--auth-token-stdin` (CLI) to the create call — see [Authenticating to your endpoint](https://inkbox.ai/docs/webhooks.md#authenticating-to-your-endpoint).

## How messages are delivered

For ordinary messages, Inkbox tries iMessage first. If a recipient isn't reachable over iMessage, delivery can fall back to SMS — the message's `service` field reports the transport actually used (`"imessage"`, `"sms"`, or `"rcs"`), and `was_downgraded` is set when a fallback happened. You do not select the transport in a send request. A native reply requires iMessage support; `plain_reply_fallback` can instead select an ordinary message before sending when the target is already known to be unsupported. It does not retry a rejected native send without threading. Check `service` and `was_downgraded` on the current message for the reported delivery outcome.

## Retry a message request

The SDK preserves a generated request key during bounded retries. Use an explicit
key when a workflow repeats the same send across calls; the CLI accepts
`--idempotency-key` on `imessage send`. The same key and input replay the original
response. Read the message for current delivery status. See
[message send retries and ID lookup](https://inkbox.ai/docs/api/message-sends.md).

## Next steps

* [iMessage API reference](https://inkbox.ai/docs/api/imessage.md)
* [Webhook subscriptions](https://inkbox.ai/docs/api/webhooks/subscriptions.md)
* [Identities](https://inkbox.ai/docs/capabilities/identities.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.