Docs menu

Send a message

POST/v1/profiles/{profile_id}/messages

  • Scope messages:send
  • Idempotency-Key required

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_idstringrequired

    The line (prf_…).

Request body

  • tostringrequired

    A phone number, email or group chat id. US and Canadian numbers need no +1: (415) 555-0142 and +14155550142 are the same person. Other countries need their + code.

  • textstring

    The message, up to 20,000 characters. Needs text or attachments, or both.

  • service"iMessage" | "RCS" | "SMS"

    iMessage, RCS or SMS. Leave it out to let the line choose: iMessage when the person has it, else a text.

  • attachmentsarray of object

    Up to 10 files: { url, file_name? } with a public https URL, or { upload_id, file_name? } for a file uploaded with POST /v1/profiles/{profile_id}/uploads.

  • reply_tostring

    A msg_… to reply to (an inline reply).

  • effectstring

    An iMessage effect: slam, loud, gentle, invisible-ink, confetti, echo, fireworks, balloons, love, lasers, celebration, shooting-star or spotlight.

  • display_namestring

    A name for a new group chat.

  • queueboolean

    While the line has trouble, wait and send once it's back (default true). false fails at once with 503 line_unavailable instead.

  • queue_minutesinteger

    How 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

  • idstringrequired

    msg_…

  • object"message"required

  • profile_idstringrequired

    prf_…

  • chat_idstringrequired

    cht_…

  • chat_handlestring

    The chat's address: a phone number, email or group chat id.

  • direction"inbound" | "outbound"required

  • senderstring or nullrequired

    Who sent an inbound message (in group chats, one of the members).

  • textstring or nullrequired

  • attachmentsarray of Attachmentrequired

    Fields of attachments
    • idstringrequired

      att_…

    • file_namestring or nullrequired

    • mime_typestring or nullrequired

    • size_bytesinteger or nullrequired

    • urlstringrequired

      A path on the API: GET it with your key and follow the 302 to a short-lived download link.

  • servicestring or nullrequired

    How it went or came: iMessage, RCS or SMS. Null until known.

  • requested_servicestring or nullrequired

    The service the send asked for, if any.

  • fallback_fromstring or nullrequired

    Set when the message failed over: the service it started on (iMessage).

  • reactionsarray of Reactionrequired

    Fields of reactions
    • kind"love" | "like" | "dislike" | "laugh" | "emphasize" | "question" or "emoji"required

      One of the six tapbacks, or emoji for an emoji reaction.

    • emojistring or nullrequired

      The emoji, when kind is emoji.

    • 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"required

    queued → dispatched → sent → delivered → read (iMessage only), or failed / unconfirmed. Inbound messages are received.

  • errorobject or nullrequired

    Why a message failed: line_unavailable, recipient_not_allowed, sending_paused, unconfirmed or send_failed.

    Fields of error
    • codestringrequired

    • messagestringrequired

  • guidstring or nullrequired

    The message's id in Messages, once it has one.

  • created_attimestamprequired

  • sent_attimestamp or nullrequired

  • delivered_attimestamp or nullrequired

  • read_attimestamp or nullrequired

  • queue_untiltimestamp or nullrequired

    While queued: when the send gives up if the line is still unavailable.

With a draft-only key: a Draft

  • idstringrequired

    drf_…

  • object"draft"required

  • profile_idstringrequired

    prf_…

  • chat_idstring or nullrequired

  • tostringrequired

  • textstring or nullrequired

  • attachmentsarray of objectrequired

  • reply_tostring or nullrequired

  • servicestring or nullrequired

  • effectstring or nullrequired

  • status"pending" | "approved" | "rejected"required

  • reasonstring or nullrequired

    Why it was rejected, if the person said.

  • message_idstring or nullrequired

    Once approved: the message it became.

  • created_bystringrequired

    api_key:key_… (the draft-only key that wrote it).

  • decided_bystring or nullrequired

    user:usr_… or api_key:key_….

  • decided_attimestamp or nullrequired

  • created_attimestamprequired

Errors

StatusCodeMeans
400idempotency_key_requiredA send or call came without an Idempotency-Key header.
409idempotency_key_reusedThe Idempotency-Key was used before for a different request. Nothing was sent.
403recipient_not_allowedThe recipient isn't on this key's allowed recipients.
429rate_limitedThe key's sends for this window are used up.
429new_conversation_limitThe 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.
403sending_pausedWe 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.
402payment_requiredThe team's subscription isn't paid up, so sending is paused.
409profile_not_readyThe line is still being set up.
503line_unavailableThe line is having trouble right now.
409not_sent_yetThe message hasn't gone out yet, so it can't be reacted or replied to.
400validation_failedA field is missing or invalid.
401unauthorizedThe API key is missing, unknown or revoked.
403insufficient_scopeThe API key lacks the scope this needs.
404not_foundNo such object, or the key can't see it.

Every error is { "error": { "code", "message" } }. All error codes.

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