MessageOS
APIMessages

Send a message

POST
/messages

Sends one message to one person. The smallest body is to and text.

What it carries

  • A message is exactly one of text, card, carousel, file, or template.
  • Text, a card, a carousel, and a file can carry suggestions: replies the person taps, and actions that open a link, call a number, show a place, ask for their location, or add a calendar event.
  • Where GET /whoami shows richMessages false, only text and template are accepted.
  • A message can carry an expiry, expiresAt or ttlSeconds but not both, and a trafficType. Where GET /whoami shows rcsExtras false, a body with one of those three returns 422.
  • A tap on a suggestion labeled STOP, START, HELP, or another consent keyword counts as that keyword.

Who it goes to, and consent

  • to needs contactId, phoneNumber, or externalId.
  • A phone number that is not yet a contact needs consent in the same request: the contact is created with it and the message is sent. Without it the send is blocked with no_consent_record.
  • A person who opted out is never sent anything.
  • The class compliance is reserved for MessageOS and is rejected.

Quiet hours

  • Where GET /whoami shows quietHoursEnforced true, a send you start during quiet hours is blocked with quiet_hours unless onQuiet is defer, which answers 202 with deferredUntil and sends nothing.
  • Where it is false, the time of day is yours to keep, and onQuiet reject or defer asks for the hold on one request. It is false for an agent set up as API only.

Replies

A send whose inReplyTo names a message this contact sent in the last hour is a reply: it needs no consent record and quiet hours do not hold it, for up to three sends per message and never for a promotional send.

Drafts

With mode set to craft, where that is enabled, the text is written from instructions and stored as a draft for approval instead of being sent.

What comes back

  • A message that was sent answers 201 with its id and the status sent. GET /messages/{id} reads its latest status, and the message.delivered, message.read, and message.failed events report the same changes as they happen.
  • A send the messaging network does not accept is not reported as sent: it returns 409 blocked with a reason, and the same Idempotency-Key can be sent again.

Scope: messages:write.

Authorization

bearer
headerAuthorizationBearer <mosc_...>

A client key (mosc_).

Header Parameters

Idempotency-Key*string

8 to 128 characters. The same key and body return the stored response.

Length8 <= length <= 128

Request Body

application/json
  1. body
mode?string

Leave it out. exact is accepted and means the same: the message is sent as written.

to*

Who gets the message: one of contactId, phoneNumber, or externalId.

text?string

The words of a text message, up to 2000 characters.

Length1 <= length <= 2000
suggestions?array<|||||>

Up to 11 suggested replies and actions shown under the message. They show only under the newest message in the conversation.

Itemsitems <= 11
card?

One rich card: a title, a description, media, and buttons. At least one of title, description, or media.

carousel?

A row of rich cards.

file?

One file, sent by its address. MessageOS does not download it: the phone network fetches it from your address.

template?

A text template this agent has, with a value for each of its slots. A convenience for text: it carries no card or file.

class?string
Default"service"
Value in"service""transactional""promotional"
reference?string

Your own id for this message, such as an order number. It comes back in the answer, in GET /messages/{id}, and in the message.delivered, message.read, and message.failed events.

Length1 <= length <= 200
consent?

The consent you hold for this person, so a first message takes one call. With to.phoneNumber for a number that is not yet a contact, the contact is created with this record and the message is sent. For a contact that has no consent record, it is stored. A contact that already has one keeps it.

onQuiet?string

What to do when it is quiet hours for the person. reject answers 409 quiet_hours. defer answers 202 with deferredUntil and sends nothing. send does not check the time. GET /whoami shows which applies when you leave it out: with quietHoursEnforced false it is send, and send is accepted; with quietHoursEnforced true it is reject, and send returns 422.

Value in"send""reject""defer"
inReplyTo?integer

The id of the message from this contact that this send answers: inboundMessageId in the reply.received event, or the id of an inbound message in the conversation. When that message arrived within the reply window (an hour, shown by GET /whoami as replyWindowSeconds), the send is a reply: it needs no consent record, and quiet hours do not hold it. Up to three sends can answer one message this way, and a promotional send never counts as a reply. Where replies are not turned on, replyWindowSeconds is null and a body with inReplyTo returns 422.

Range1 <= value <= 2147483647
expiresAt?string

When the message expires: an RFC 3339 time that is still ahead, written with an uppercase T, a Z or an offset such as -05:00, and at most three digits after the seconds. The messaging network considers the message expired at that time. Send expiresAt or ttlSeconds, not both. Where GET /v1/whoami shows rcsExtras false, a body with this field returns 422 until MessageOS turns it on for you.

Formatdate-time
ttlSeconds?integer

How many seconds the message lives before the messaging network takes it back automatically. A whole number, 1 or more. Send ttlSeconds or expiresAt, not both. Where GET /v1/whoami shows rcsExtras false, a body with this field returns 422 until MessageOS turns it on for you.

Range1 <= value
trafficType?string

The kind of traffic this message is, declared to the messaging network. Left out, none is declared, and MessageOS never sets one from class. Where GET /v1/whoami shows rcsExtras false, a body with this field returns 422 until MessageOS turns it on for you.

Value in"authentication""transaction""promotion""serviceRequest""acknowledgement"

Response Body

The message was sent, or stored as a draft.

application/json
  1. response
id*string

msg_ followed by auditId.

status*string
type*string

What was sent. An agent that cannot send a card sends its words as text, and this says text.

Value in"text""card""carousel""file"
channel*string
contactId*integer

The contact the message went to.

reference*|

The reference you sent with the message, or null.

auditId*integer

The send record. message.delivered and message.failed carry the same number as messageId.

Example request

curl -X POST 'https://api.messageos.ai/v1/messages' \  -H 'Authorization: Bearer mosc_...' \  -H 'Idempotency-Key: visit-reminder-42-2026-10-28' \  -H 'Content-Type: application/json' \  -d '{  "to": {    "phoneNumber": "+15555550123"  },  "text": "Your table is ready."}'

Example response

{  "id": "msg_123",  "status": "sent",  "type": "text",  "channel": "rcs",  "contactId": 42,  "reference": "order-8841",  "auditId": 123}