Skip to main content
GET
Get messages or conversations for a messaging platform. Retrieval times differ on each social network. On Facebook, Instagram, and WhatsApp, messages are available via Ayrshare in real time. On X/Twitter, there is a delay of up to 3 minutes to see new message updates. Please contact support to learn more about the Enterprise Plan if you need real-time X/Twitter message access.
Response caching: For Facebook and Instagram, responses are cached for 60 seconds. For X/Twitter, responses are cached for 15 seconds to better support polling. WhatsApp reads messages already received through Meta webhooks, so a newly received message can appear as soon as Ayrshare processes its webhook. The response still includes lastUpdated and nextUpdate metadata.
Initial message history retrieval for Facebook and Instagram is limited to the last 20 messages. Please see the Message History Retrieval for Facebook and Instagram section for more information.
WhatsApp conversations are identified by the correspondent’s phone number (digits only, E.164 without the leading +). A stored outbound message may include a status value of sent, delivered, read, or failed.
WhatsApp messages sent through Send Message are not currently added to Get Messages history. Incoming WhatsApp messages received through webhooks are stored and returned here.

Header Parameters

Path Parameters

string
required
The platform to get the message: facebook, instagram, twitter, whatsapp

Query Parameters

string
default:"active"
required
Return active conversations or archived conversations. Values: active or archived.
string
Only return the specific conversation.
string
Only return messages in one direction. Values: sent or received. Omit to return both.
boolean
default:false
Return conversations instead of messages. Returns one page of conversations — follow meta.pagination.next for the rest. If true, conversationId is ignored.
When conversationsOnly=true, conversation details are returned in converstationsDetails. This spelling is part of the current API response.
integer
Page size for messages and for conversation lists: an integer from 1 to 100, with a default and maximum of 100.On X/Twitter limit also chooses which set of messages you read. Omit it to page your stored messages, which is what every other platform does and what applies status, action and conversationsOnly. Supply it to page X’s live timeline through X’s own cursor instead, which applies none of those three filters.That choice is made by the first request only. Once you are following a cursor, the cursor decides: a stored cursor keeps returning stored messages even if you send limit, and an X cursor keeps returning the live timeline even if you omit it. You cannot switch between the two mid-pagination.
string
Opaque cursor from meta.pagination.next. Pass it as next with the same profile, platform and filters. Continue while meta.pagination.hasMore is true, even if a filtered page comes back short or empty. limit may be omitted on subsequent requests and defaults to 100; on X/Twitter the cursor already records which set of messages it came from, so sending or omitting limit alongside it will not switch you to the other one.

Fetching the next page

Start with GET /api/messages/instagram?limit=100. To continue, URL-encode the returned meta.pagination.next value and send GET /api/messages/instagram?limit=100&next=<opaque cursor>. The parameter is next, not cursor. Keep the same Profile-Key and query filters throughout. Check meta.pagination.hasMore, not the number of results, to decide when to stop. A filtered request may return fewer than limit results, or an empty page with a continuation, because each request scans a bounded portion of history. Messages in stored history are ordered newest first, with document ID breaking ties. Conversation lists are ordered by document ID. Paging is not a frozen snapshot: new messages appear when you restart from the first page, and changing conversation statuses can change filtered results. Existing message fields and the converstationsDetails spelling are unchanged. Integrations that previously expected a complete list from one request — whether of messages or of conversations, on any platform — must follow the continuation cursor; increasing limit above 100 is not supported.