readyDocs Open the appOpen the app

Conversations

The inbox has one thread per contact. To reply, send to the contact with POST /v1/messages; it lands in the same thread. View-only teammates can read conversations but not change them. Reading a thread still marks it read (see List a thread’s messages). An id that isn’t on your account returns 404 CONVERSATION_NOT_FOUND. An id that isn’t a whole number returns 400 invalid_field.

#The Conversation object

List conversations returns this object. Find a contact’s conversation returns a shorter row (see there). Ignore fields you don’t recognize.

idinteger
The conversation id.
contact_idinteger
The contact id.
first_namestring
The contact’s first name.
last_namestring
The contact’s last name.
phoneE.164 string
The contact’s phone.
statusstring
open, closed or archived. null and active mean open: treat them the same. Set it with Set a conversation’s status.
unread_countinteger
Unread messages in the thread. Mark read and Archive clear it; Mark unread sets it to 1.
starredinteger
1 or 0. Toggle it with Star or unstar a conversation.
pinnedinteger
1 or 0.
assigned_tointeger | null
Who the thread is assigned to, or null. This is the contact’s owner when the contact has one, else the thread’s own assignee. Set it with Assign a conversation.
last_message_atISO 8601 string
When the newest message was sent or received. The list is sorted by it, newest first.
last_message_previewstring
The start of the most recent message.
phone_number_idinteger
The id of your number the thread uses, as in GET /v1/numbers and line_ids.
from_numberE.164 string
Your number the thread uses.
tagsstring
The contact’s tags as a JSON array in a string, like "[\"vip\"]". Parse it before you use it.
contact_statusstring | null
The contact’s status.
dnd_smsinteger | null
1 when the contact is on do not disturb for texts.
opt_out_atISO 8601 string | null
When the contact opted out, or null.

#List conversations

Your inbox threads, newest message first. Starring doesn’t change the order; use filter=starred. Returns a list of Conversation objects in data.

Parameters

limitinteger, queryDefault 50Max 1000
Page size.
offsetinteger, queryDefault 0
Rows to skip: a whole number, 0 or more.
filterenum, query
Which view; default is every thread that isn’t archived, closed ones included. Unknown values are ignored.
  • unread
  • starred
  • archived
  • spam
  • blocked
line_idsstring, query
Comma-separated number ids from GET /v1/numbers (not phone numbers), up to 100, for example line_ids=2647,2648. Invalid values are ignored. When none of them is a number id the whole inbox comes back, and the answer has ignored_filters: ["line_ids"] to say the filter was dropped.
freshinteger, query
Lists are cached up to 30 seconds, and longer when the server is slow to refresh them. Send 1 after a change to read live.
Returns
data[]object[]
Conversation objects.
has_moreboolean
Keep paging while true.
search_timed_outboolean
true when a search ran out of time. If data is empty, that is not "no matches": narrow the search and retry.
search_partialboolean
true means some matches may be missing.
totalinteger
Threads matching filter and search, counted up to 1,000. While searching, or filtering by tag, assignee or campaign, total is the rows returned so far, not a count, so use has_more. With line_ids, total and counts cover only those numbers.
total_cappedboolean
true when the count passed the cap.
count_capinteger
The cap, 1000.
countsobject
Thread counts per view: all (the default view, without archived), unread, starred, pinned, archived, spam.
Errors
HTTPCodeWhen
400invalid_offsetNot a whole number, 0 or more (in error_code).

#List messages in a conversation

One thread’s messages: the newest page, oldest first within the page. Returns a list of Message objects in data, with the differences under Returns.

Reading any page marks the thread as read, for everyone on the account, unless a reply came in after the newest message on that page. Sync jobs should add mark_read=0. A test key never marks a thread read.

Parameters

idinteger, pathRequired
The conversation id.
mark_readinteger, query
Send 0 to leave the unread state alone.
limitinteger, queryDefault 50Max 500
Page size.
offsetinteger, queryDefault 0
Increase to go further back in time.
Returns
data[].idinteger
This thread’s message id, the one quoted_message_id takes on Send a message.
data[].to_numberE.164 string
Recipient.
data[].from_numberE.164 string
Sender.
data[].costnumber
What the message cost, in USD.
data[].failed_atISO 8601 string | null
When it failed, or null.
Errors
HTTPCodeWhen
403CONVERSATION_NOT_ASSIGNEDTeammate access doesn’t cover this thread: it’s assigned to someone else. Also CONVERSATION_NOT_ALLOCATED: the thread’s number isn’t allocated to you.

#Find a contact’s conversation

The thread for one contact, or null if there isn’t one. An unknown contact id also returns null, not a 404.

Parameters

contactIdinteger, pathRequired
The contact id.
Returns
dataobject | null
A shorter Conversation object, or null. It has no tags. Its assigned_to is the thread’s own assignee, and contact_assigned_to is the contact’s owner, so it can differ from the list’s assigned_to.
Errors
HTTPCodeWhen
403CONVERSATION_NOT_ASSIGNEDTeammate access doesn’t cover this thread: it’s assigned to someone else. Also CONVERSATION_NOT_ALLOCATED: the thread’s number isn’t allocated to you.

#Best time to text a contact

A 2-hour window when this contact has replied to you most, from the hours of their past replies. It needs at least 3 replies; with fewer you get best: null. The window always falls between 9 AM and 7 PM in your account’s time zone. Read only.

Parameters

contactIdinteger, pathRequired
The contact id.
Returns
bestobject | null
The window, at the top level, or null when there aren’t enough replies.
best.start_hhmmstring
Start of the window, like 14:00.
best.end_hhmmstring
End of the window, 2 hours later.
best.labelstring
The window in words, like 2 PM to 4 PM.
best.sampleinteger
How many replies it’s based on.
best.sourcestring
Always contact.
best.reasonstring
A short sentence you can show.
timezonestring
Your account’s IANA time zone. The window’s hours are in this zone.
Errors
HTTPCodeWhen
400INVALID_CONTACT_IDNot a contact id (for example a phone number).
403CONVERSATION_NOT_ASSIGNEDTeammate access doesn’t cover this thread: it’s assigned to someone else. Also CONVERSATION_NOT_ALLOCATED: the thread’s number isn’t allocated to you.
500best_time_unavailableWe couldn’t work it out right now. This is a failure, not "no data"; retry.