SMS and Conversations
Every Saperly line can receive inbound SMS. You can reply and inspect conversation history through the API.
explicit_outbound consent record on file for that recipient on this line (recorded via POST /v1/consent or a documented web-form opt-in). When neither holds, the API returns 403 with conversation_window_expired. This is a carrier compliance requirement.Two paths to a successful outbound SMS:
- Reply within 24h — automatic; no extra setup required.
- Explicit consent — record an
explicit_outboundconsent for the recipient viaPOST /v1/consent(or a documented web-form opt-in) before sending. Once recorded, you can send to that recipient on that line outside the 24h reply window.
See Compliance and Consent for how to capture and record opt-ins.
What happens on inbound SMS
Your webhook receives an event like this:
The timestamp is Unix milliseconds. The message_sid is the upstream carrier identifier.
event field: sms_received for SMS, message for voice calls. This works for both webhook-mode and hosted-mode lines — voice mode does not gate SMS routing. A line without webhookUrl still records the consent record and logs the sms_received compliance event on inbound, but Saperly has nowhere to deliver the event, so your code cannot auto-reply with its own LLM.Reply to a message
Send a reply with the line id, recipient number, and message text. The recipient must have texted you within the last 24 hours, OR you must have an active explicit_outbound consent record on file for that (line, recipient).
Response shape
A successful POST /api/v1/messages returns the queued message:
The status field transitions from queued to sent to delivered (or failed) as the carrier processes the message.
List conversation threads
Get one thread
Response shape
GET /api/v1/conversations/{lineId}/{phoneNumber} returns the full message history for the thread, ordered newest to oldest (most recent first):
Each message has a direction (inbound or outbound), the text body, and a timestamp in ISO 8601 format.
Practical constraints
The simplest useful mental model is “reply to active conversations.”
If you are designing a workflow around outbound cold SMS from scratch, stop and check your carrier and registration requirements first.
Good uses
- support follow-up
- appointment confirmation
- delivery coordination
- threaded AI assistance after a user texts first
