Send a message
POST/v1/profiles/{profile_id}/messages
- Scope
messages:send Idempotency-Keyrequired
Queues a message and answers 202 at once with it (status: queued); follow it with webhooks, the event stream or GET …/messages/{message_id}. The line sends iMessage when the person has it and falls back to a text otherwise.
Idempotency: the Idempotency-Key header is required. The same key with the same body returns the same message (Idempotent-Replayed: true) and never sends twice; the same key with a different body is 409 idempotency_key_reused.
Draft-only keys get a draft back instead (object: "draft"): nothing is sent until a person approves it.
Mass texting isn't allowed: write to people who expect to hear from you. If we pause sending on your account or a line while we review its activity, every send answers 403 sending_paused (incoming messages still arrive), and a line may have a daily limit on new conversations (429 new_conversation_limit); replies are never limited.
Parameters
Path
profile_idstringrequiredThe line (
prf_…).
Request body
tostringrequiredA phone number, email or group chat id. US and Canadian numbers need no +1:
(415) 555-0142and+14155550142are the same person. Other countries need their+code.textstringThe message, up to 20,000 characters. Needs
textorattachments, or both.service"iMessage" | "RCS" | "SMS"iMessage,RCSorSMS. Leave it out to let the line choose: iMessage when the person has it, else a text.attachmentsarray of objectUp to 10 files:
{ url, file_name? }with a public https URL, or{ upload_id, file_name? }for a file uploaded withPOST /v1/profiles/{profile_id}/uploads.reply_tostringA
msg_…to reply to (an inline reply).effectstringAn iMessage effect:
slam,loud,gentle,invisible-ink,confetti,echo,fireworks,balloons,love,lasers,celebration,shooting-starorspotlight.display_namestringA name for a new group chat.
queuebooleanWhile the line has trouble, wait and send once it's back (default
true).falsefails at once with503 line_unavailableinstead.queue_minutesintegerHow long a queued send may wait, 1–1440 minutes (default 15). After that it fails with
line_unavailable.
Response
202 AcceptedThe queued message, or a draft for a draft-only key.
A Message
idstringrequiredmsg_…object"message"requiredprofile_idstringrequiredprf_…chat_idstringrequiredcht_…chat_handlestringThe chat's address: a phone number, email or group chat id.
direction"inbound" | "outbound"requiredsenderstring or nullrequiredWho sent an inbound message (in group chats, one of the members).
textstring or nullrequiredattachmentsarray of AttachmentrequiredFields of
attachmentsidstringrequiredatt_…file_namestring or nullrequiredmime_typestring or nullrequiredsize_bytesinteger or nullrequiredurlstringrequiredA path on the API:
GETit with your key and follow the302to a short-lived download link.
servicestring or nullrequiredHow it went or came:
iMessage,RCSorSMS. Null until known.requested_servicestring or nullrequiredThe
servicethe send asked for, if any.fallback_fromstring or nullrequiredSet when the message failed over: the service it started on (
iMessage).reactionsarray of ReactionrequiredFields of
reactionskind"love" | "like" | "dislike" | "laugh" | "emphasize" | "question" or "emoji"requiredOne of the six tapbacks, or
emojifor an emoji reaction.emojistring or nullrequiredThe emoji, when
kindisemoji.fromstringrequired"me"for the line's own reaction, else the person's address.attimestamp or nullrequired
status"queued" | "dispatched" | "sent" | "delivered" | "read" | "failed" | "unconfirmed" | "received"requiredqueued→dispatched→sent→delivered→read(iMessage only), orfailed/unconfirmed. Inbound messages arereceived.errorobject or nullrequiredWhy a message failed:
line_unavailable,recipient_not_allowed,sending_paused,unconfirmedorsend_failed.Fields of
errorcodestringrequiredmessagestringrequired
guidstring or nullrequiredThe message's id in Messages, once it has one.
created_attimestamprequiredsent_attimestamp or nullrequireddelivered_attimestamp or nullrequiredread_attimestamp or nullrequiredqueue_untiltimestamp or nullrequiredWhile
queued: when the send gives up if the line is still unavailable.
With a draft-only key: a Draft
idstringrequireddrf_…object"draft"requiredprofile_idstringrequiredprf_…chat_idstring or nullrequiredtostringrequiredtextstring or nullrequiredattachmentsarray of objectrequiredreply_tostring or nullrequiredservicestring or nullrequiredeffectstring or nullrequiredstatus"pending" | "approved" | "rejected"requiredreasonstring or nullrequiredWhy it was rejected, if the person said.
message_idstring or nullrequiredOnce approved: the message it became.
created_bystringrequiredapi_key:key_…(the draft-only key that wrote it).decided_bystring or nullrequireduser:usr_…orapi_key:key_….decided_attimestamp or nullrequiredcreated_attimestamprequired
Errors
| Status | Code | Means |
|---|---|---|
| 400 | idempotency_key_required | A send or call came without an Idempotency-Key header. |
| 409 | idempotency_key_reused | The Idempotency-Key was used before for a different request. Nothing was sent. |
| 403 | recipient_not_allowed | The recipient isn't on this key's allowed recipients. |
| 429 | rate_limited | The key's sends for this window are used up. |
| 429 | new_conversation_limit | The line started as many new conversations in the last 24 hours as it may. Replies, and messages to anyone who already wrote to the line, still go. |
| 403 | sending_paused | We paused sending on your account (or this line) while we review recent activity that looked like mass texting. Incoming messages still arrive. details.scope is team or line. |
| 402 | payment_required | The team's subscription isn't paid up, so sending is paused. |
| 409 | profile_not_ready | The line is still being set up. |
| 503 | line_unavailable | The line is having trouble right now. |
| 409 | not_sent_yet | The message hasn't gone out yet, so it can't be reacted or replied to. |
| 400 | validation_failed | A field is missing or invalid. |
| 401 | unauthorized | The API key is missing, unknown or revoked. |
| 403 | insufficient_scope | The API key lacks the scope this needs. |
| 404 | not_found | No such object, or the key can't see it. |
Every error is { "error": { "code", "message" } }. All error codes.