Send a message
| Field | Required | Description |
|---|---|---|
from | Yes | The line handle to send from |
to | Yes | Recipient phone number, Apple ID, or chat ID (cht_... for group chats) |
text | Conditional | Message text. Required unless attachments is set. |
attachments | Conditional | Array of file IDs (max 1) from POST /v1/files. Required unless text is set. |
reply_to | No | Message ID (msg_...) or iMessage GUID to thread the message as a reply. |
Reply to a specific message
Pass the original message’sid or guid as replyTo to thread your reply
underneath it in the recipient’s conversation:
Group chats
Pass a chat ID (cht_...) returned by listChats
as to:
Contact-first restriction
To keep lines healthy with Apple’s spam detection, you can only send to a contact (or group chat) after they have messaged your line first. Trying to send first returns:Track delivery
Register a webhook formessage.sent and your server will receive a POST when
the message is delivered:
| Status | Meaning |
|---|---|
pending | Queued for delivery |
claimed | Being processed |
sent | Delivered |
failed | Delivery failed (check the error field) |
Errors
| Status | Code | Cause |
|---|---|---|
| 400 | missing_required_parameter | Missing from, to, or both text and attachments |
| 400 | invalid_parameter_value | attachments is malformed (e.g. wrong ID prefix or more than 1 entry) |
| 401 | missing_api_key | No Authorization header |
| 403 | insufficient_scope | Key lacks messages:write scope |
| 403 | line_not_accessible | Key can’t access this line |
| 403 | contact_has_not_messaged | The recipient (or chat) hasn’t messaged your line first |
| 404 | line_not_found | Invalid line handle |
| 404 | chat_not_found | The cht_... ID doesn’t exist on this line |
| 404 | file_not_found | An attachment file ID doesn’t exist |
| 404 | message_not_found | reply_to references a message that doesn’t exist |
| With the SDK, errors are thrown as typed exceptions: |