Docs menu

Send and read iMessage and SMS: messages and chats

Send iMessage and SMS from a bubblr line, follow delivery, send photos and files, react, show typing, and read and search conversations.

A line sends iMessage to people who have it and a text message (SMS, or RCS where available) to everyone else. You send the same way either way; the message says how it went.

Who you can send to

to takes a phone number, an email address (iMessage only) or a group chat's id.

  • US and Canadian numbers need no +1: (415) 555-0142, 415-555-0142 and +14155550142 are the same person and the same conversation.
  • Other countries need their + country code.
  • Group chats: use the chat's handle from GET …/chats.

Sending

Shell
curl -X POST https://api.bubblr.io/v1/profiles/prf_2Wq8nT4kLm/messages \
  -H "Authorization: Bearer $BUBBLR_API_KEY" -H "Idempotency-Key: $(uuidgen)" -H "Content-Type: application/json" \
  -d '{"to": "+14155550142", "text": "Your order is ready for pickup."}'
Field
to Who to send to (required).
text Up to 20,000 characters. A send needs text, attachments, or both.
attachments Up to 10 photos or files (below).
service iMessage, RCS or SMS to force one. Leave it out to let the line choose.
reply_to A msg_… to reply to inline.
effect An iMessage effect: slam, loud, gentle, invisible-ink, confetti, echo, fireworks, balloons, love, lasers, celebration, shooting-star, spotlight.
queue, queue_minutes What happens while the line has trouble (below).

A key that covers exactly one line can leave the line out: POST /v1/messages.

The answer is always 202 Accepted with the message, status: "queued". Sending happens right after.

Idempotency

Every send needs an Idempotency-Key header, any unique string up to 255 characters. Retrying with the same key and the same body answers the same message (with Idempotent-Replayed: true) and never sends it twice, so a timeout or a crash between your request and our answer can't double-text someone. The same key with a different body is 409 idempotency_key_reused: nothing was sent. The SDK makes keys for you.

Following a message

status Means
queued Waiting to go out.
dispatched On its way.
sent Sent. service says how: iMessage, RCS or SMS.
delivered Reached the person's device.
read They read it (iMessage, when they share read receipts).
failed Not sent; error.code says why.
unconfirmed We couldn't confirm it went out. Check with the person before sending it again.
received A message someone sent to the line.

Each step is also an event (message.sent, message.delivered, message.read, message.failed), by webhook or the live stream. When iMessage can't reach someone, the line sends the message again as a text: you get message.fallback, then message.sent with the new service, and the message's fallback_from says iMessage.

Failure codes in error.code: line_unavailable (the line had trouble longer than the queue window), recipient_not_allowed (the key's guardrails), unconfirmed, send_failed.

While the line has trouble

A line's state is working most of the time. When it's having_trouble, sends wait in the queue (status: queued, with queue_until) and go out once the line is back. After queue_minutes (default 15, up to 1,440) they fail with line_unavailable. Send with "queue": false to get 503 line_unavailable at once instead, for messages that are only worth sending now. GET /v1/profiles/{profile_id}/status shows the queue.

Photos and files

Send files from a public https:// URL:

JSON
{ "to": "+14155550142", "text": "Here's the floor plan", "attachments": [{ "url": "https://example.com/floorplan.pdf" }] }

Or upload them first, for files that aren't public:

  1. POST /v1/profiles/{profile_id}/uploads with file_name, mime_type and size_bytes. The answer has an upload_url and an id (upl_…).
  2. PUT the file's bytes to upload_url within 15 minutes.
  3. Send with "attachments": [{ "upload_id": "upl_…" }]. An upload can be sent for 7 days.

Messages list their files in attachments, each with a url like /v1/attachments/att_…. GET it with your key: the answer is a 302 to a short-lived download link. Ask again each time rather than storing the link.

Reading conversations

Shell
# The line's chats, most recent first, with each chat's newest message and unread count
curl "https://api.bubblr.io/v1/profiles/prf_2Wq8nT4kLm/chats?limit=20" -H "Authorization: Bearer $BUBBLR_API_KEY"

# The chat with one person, by their number in any format
curl "https://api.bubblr.io/v1/profiles/prf_2Wq8nT4kLm/chats?handle=4155550142" -H "Authorization: Bearer $BUBBLR_API_KEY"

# A chat's messages, newest first
curl "https://api.bubblr.io/v1/profiles/prf_2Wq8nT4kLm/chats/cht_5Rf1sD8hJw/messages" -H "Authorization: Bearer $BUBBLR_API_KEY"

# Search every message on the line
curl "https://api.bubblr.io/v1/profiles/prf_2Wq8nT4kLm/messages?q=invoice" -H "Authorization: Bearer $BUBBLR_API_KEY"

Reading works while the line has trouble. Chats carry contact, the name and tags your team gave the person (see contacts), and filter by tag and assigned_to.

Pages

Messages, chats, drafts, calls and contacts come newest first, limit at a time (default 50, up to 200). When has_more is true, pass the answer's next_before as before for the next page:

Shell
curl "https://api.bubblr.io/v1/profiles/prf_2Wq8nT4kLm/messages?limit=100&before=msg_9KxT3vQ7Pa" -H "Authorization: Bearer $BUBBLR_API_KEY"

The SDK does this for you: for await (const m of bubblr.messages.list({ profile_id })).

Reactions, typing and read receipts

These reach the other person at once, so they need the line working (503 line_unavailable otherwise):

  • React: POST …/messages/{message_id}/reactions {"reaction": "love"}: love, like, dislike, laugh, emphasize or question; "remove": true takes it back. iMessage only (409 imessage_only). Reactions people send arrive as message.reaction events, and every message lists its reactions.
  • Typing: POST /v1/profiles/{profile_id}/typing {"chat_id": "cht_…"} shows the typing indicator; "typing": false stops it.
  • Mark read: POST …/chats/{chat_id}/read marks the chat read, which sends read receipts if the line has them on. To clear the unread count without telling the other person, PATCH …/chats/{chat_id} {"seen": true}.

Handing chats between agents and people

PATCH /v1/profiles/{profile_id}/chats/{chat_id} {"assigned_to": "human"} marks who handles a chat: agent, human or null. It sends chat.updated, shows in the app's inbox, and lists filter on it (?assigned_to=agent). A common pattern: your agent answers chats assigned to agent (or nobody) and leaves the rest to your team.

For agents that should never send without a person's approval, see draft-only keys.

Keys come with your first line.

Request an invite and we'll set up a line for your team. API access is part of every plan.

Request an invite