curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://api.ayrshare.com/api/messages/facebook
const apiKey = 'API_KEY';
const url = 'https://api.ayrshare.com/api/messages/facebook';
const headers = {
'Authorization': `Bearer ${apiKey}`,
};
fetch(url, {
method: 'GET',
headers: headers,
})
.then(response => {
if (response.ok) {
return response.json();
} else {
throw new Error(`Request failed. Status code: ${response.status}`);
}
})
.then(data => {
console.log('Response:', data);
})
.catch(error => {
console.error('Error:', error.message);
});
import requests
api_key = 'API_KEY'
url = 'https://api.ayrshare.com/api/messages/facebook'
headers = {
'Authorization': f'Bearer {api_key}',
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = response.json()
print('Response:', data)
else:
print(f'Request failed. Status code: {response.status_code}')
<?php
$apiKey = 'API_KEY';
$url = 'https://api.ayrshare.com/api/messages/facebook';
$headers = [
'Authorization: Bearer ' . $apiKey,
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if ($response === false) {
$error = curl_error($ch);
echo 'Error: ' . $error;
} else {
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode === 200) {
$responseData = json_decode($response, true);
print_r($responseData);
} else {
echo 'Request failed. Status code: ' . $statusCode;
}
}
curl_close($ch);
?>
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Text.Json;
class Program
{
static async Task Main()
{
string apiKey = "API_KEY";
string url = "https://api.ayrshare.com/api/messages/facebook";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
try
{
var response = await client.GetAsync(url);
if (response.IsSuccessStatusCode)
{
var responseBody = await response.Content.ReadAsStringAsync();
var responseData = JsonSerializer.Deserialize<dynamic>(responseBody);
Console.WriteLine("Response:");
Console.WriteLine(responseData);
}
else
{
Console.WriteLine($"Request failed. Status code: {response.StatusCode}");
}
}
catch (HttpRequestException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String apiKey = "API_KEY";
String url = "https://api.ayrshare.com/api/messages/facebook";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.GET()
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
String responseBody = response.body();
System.out.println("Response:");
System.out.println(responseBody);
} else {
System.out.println("Request failed. Status code: " + response.statusCode());
}
} catch (IOException | InterruptedException e) {
System.out.println("Error: " + e.getMessage());
}
}
}
{
"status": "success",
"messages": [
{
"senderId": "106638148652444",
"senderDetails": {
"name": "Ayrshare"
},
"conversationId": "t_10161117434308444",
"created": "2024-06-06T00:54:32.455Z",
"action": "sent",
"recipientId": "7101149746568444",
"id": "m_JH6o-yS83JoxWmQaLrmgSaHwGtfTgQ",
"message": "Howdy!",
"platform": "facebook",
"reactions": {
"7101149746568522": "😆". // Reaction by the customer on the Howdy! message
}
},
{
"recipientDetails": {
"name": "Sara Smith",
"id": "736532028017333",
"picture": "https://img.ayrshare.com/333/messages/facebook-eTZzhE2b.jpeg"
},
"senderId": "106638148652329",
"attachments": [
{
"type": "image",
"url": "https://scontent.xx.fbcdn.net/v/t1.15752-9/490986808_1193328359195158"
}
],
"conversationId": "t_3567590438533",
"created": "2024-06-06T00:54:32.455Z",
"action": "sent",
"recipientId": "736532028017333",
"id": "m_WJlfgzopxfdRM1wFTKYHKv7zh75P",
"updated": "2024-06-06T00:54:32.455Z",
"platform": "facebook",
"senderDetails": {
"name": "Ayrshare"
}
},
{
"senderId": "7101149746568444",
"senderDetails": {
"name": "John Smith",
"profileImage": "https://platform-lookaside.fbsbx.com/platform/profilepic/"
},
"conversationId": "t_10161117434308444",
"created": "2024-06-06T00:54:28.102Z",
"action": "received",
"recipientId": "106638148652329",
"id": "m_HGbotYJUmf4AzyPlJ-2uZqHwGtfTgQihX",
"message": "Look up!",
"platform": "facebook"
},
{
"senderId": "7101149746568444",
"senderDetails": {
"name": "John Smith",
"profileImage": "https://platform-lookaside.fbsbx.com/platform/profilepic/"
},
"conversationId": "t_10161117434308444",
"created": "2024-06-06T00:49:11.679Z",
"action": "received",
"recipientId": "106638148652444",
"id": "m_jXoYQIwTXaq2u06PG6Z8vaHwGtfTgQ",
"message": "How is the weather?",
"platform": "facebook"
}
],
"lastUpdated": "2024-06-09T21:46:04.233Z",
"nextUpdate": "2024-06-09T21:47:04.233Z"
}
{
"status": "success",
"messages": [
{
"id": "1893410668991234567",
"conversationId": "1234567890-9876543210",
"senderId": "9876543210",
"created": "2024-06-09T21:30:00.000Z",
"message": "Hey, how are you?",
"action": "received",
"senderDetails": {
"name": "Jane Doe",
"username": "janedoe"
}
},
{
"id": "1893410668991234566",
"conversationId": "1234567890-9876543210",
"senderId": "1234567890",
"created": "2024-06-09T21:28:00.000Z",
"message": "Hello!",
"action": "sent",
"senderDetails": {
"name": "My Account",
"username": "myaccount"
}
}
],
"messagesCount": 2,
"lastUpdated": "2024-06-09T21:46:04.233Z",
"nextUpdate": "2024-06-09T21:46:19.233Z",
"meta": {
"pagination": {
"hasMore": true,
"limit": 5,
"next": "eyJwYWdpbmF0aW9uVG9rZW4iOiIxODkzNDEwNjY4OTkxMjM0NTY1In0="
}
}
}
{
"status": "success",
"messages": [
{
"id": "wamid.HBgLMTQxNTU1NTEyMzQVAgARGBI3MEM3Q0NDQjlGRTUzMjJBNEUA",
"conversationId": "14155551234",
"senderId": "14155551234",
"recipientId": "123456789012345",
"created": "2026-05-18T17:10:02.000Z",
"message": "When is my order shipping?",
"action": "received",
"platform": "whatsapp"
},
{
"id": "wamid.HBgLMTQxNTU1NTEyMzQVAgARGBI4OUYxRkExNzE0M0EwQTYwM0EA",
"conversationId": "14155551234",
"senderId": "14155551234",
"recipientId": "123456789012345",
"created": "2026-05-18T17:08:41.000Z",
"attachments": [
{
"type": "image",
"url": "https://img.ayrshare.com/abc123/whatsapp/whatsapp_image_x9aB2pK7.jpg"
}
],
"action": "received",
"platform": "whatsapp"
}
],
"lastUpdated": "2026-05-18T17:13:00.000Z",
"nextUpdate": "2026-05-18T17:14:00.000Z"
}
{
"status": "success",
"conversationIds": ["14155551234", "447700900123"],
"converstationsDetails": [
{
"id": "14155551234",
"participant": {
"id": "14155551234",
"name": "Jane Customer"
},
"status": "active",
"unread": 2
},
{
"id": "447700900123",
"participant": {
"id": "447700900123"
},
"status": "active",
"unread": 0
}
],
"lastUpdated": "2026-05-18T17:13:00.000Z",
"nextUpdate": "2026-05-18T17:14:00.000Z"
}
{
"status": "success",
"conversationIds": ["t_10161117434308444", "t_356759043857444"],
"converstationsDetails": [
{
"id": "t_10161117434308444",
"participant": {
"name": "John Smith",
"id": "7101149746568444",
"picture": "https://platform-lookaside.fbsbx.com/platform/profilepic/"
},
"status": "active",
"watermark": 1717889607444
},
{
"id": "t_356759043857444",
"participant": {
"name": "Sara Johnson",
"id": "7365320280173444",
"picture": "https://platform-lookaside.fbsbx.com/platform/profilepic/"
},
"status": "active"
}
],
"lastUpdated": "2024-06-09T21:46:04.233Z",
"nextUpdate": "2024-06-09T21:47:04.233Z"
}
{
"action": "messages",
"status": "error",
"code": 361,
"message": "Messaging is not enabled for this User Profile. Please subscribe to Messaging and activate Messaging for this User Profile."
}
{
"action": "messages",
"status": "error",
"code": 362,
"message": "Messaging तक पहुँचने के लिए सोशल नेटवर्क को relink करने की आवश्यकता है। कृपया unlink करें, relink करें, और पुनः प्रयास करें।",
"resolution": {
"relink": true,
"platform": "facebook"
}
}
Messages
Get Messages
एक messaging प्लेटफ़ॉर्म के लिए संदेश या वार्तालाप प्राप्त करें
GET
/
messages
/
:platform
curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://api.ayrshare.com/api/messages/facebook
const apiKey = 'API_KEY';
const url = 'https://api.ayrshare.com/api/messages/facebook';
const headers = {
'Authorization': `Bearer ${apiKey}`,
};
fetch(url, {
method: 'GET',
headers: headers,
})
.then(response => {
if (response.ok) {
return response.json();
} else {
throw new Error(`Request failed. Status code: ${response.status}`);
}
})
.then(data => {
console.log('Response:', data);
})
.catch(error => {
console.error('Error:', error.message);
});
import requests
api_key = 'API_KEY'
url = 'https://api.ayrshare.com/api/messages/facebook'
headers = {
'Authorization': f'Bearer {api_key}',
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = response.json()
print('Response:', data)
else:
print(f'Request failed. Status code: {response.status_code}')
<?php
$apiKey = 'API_KEY';
$url = 'https://api.ayrshare.com/api/messages/facebook';
$headers = [
'Authorization: Bearer ' . $apiKey,
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if ($response === false) {
$error = curl_error($ch);
echo 'Error: ' . $error;
} else {
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode === 200) {
$responseData = json_decode($response, true);
print_r($responseData);
} else {
echo 'Request failed. Status code: ' . $statusCode;
}
}
curl_close($ch);
?>
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Text.Json;
class Program
{
static async Task Main()
{
string apiKey = "API_KEY";
string url = "https://api.ayrshare.com/api/messages/facebook";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
try
{
var response = await client.GetAsync(url);
if (response.IsSuccessStatusCode)
{
var responseBody = await response.Content.ReadAsStringAsync();
var responseData = JsonSerializer.Deserialize<dynamic>(responseBody);
Console.WriteLine("Response:");
Console.WriteLine(responseData);
}
else
{
Console.WriteLine($"Request failed. Status code: {response.StatusCode}");
}
}
catch (HttpRequestException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String apiKey = "API_KEY";
String url = "https://api.ayrshare.com/api/messages/facebook";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.GET()
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
String responseBody = response.body();
System.out.println("Response:");
System.out.println(responseBody);
} else {
System.out.println("Request failed. Status code: " + response.statusCode());
}
} catch (IOException | InterruptedException e) {
System.out.println("Error: " + e.getMessage());
}
}
}
{
"status": "success",
"messages": [
{
"senderId": "106638148652444",
"senderDetails": {
"name": "Ayrshare"
},
"conversationId": "t_10161117434308444",
"created": "2024-06-06T00:54:32.455Z",
"action": "sent",
"recipientId": "7101149746568444",
"id": "m_JH6o-yS83JoxWmQaLrmgSaHwGtfTgQ",
"message": "Howdy!",
"platform": "facebook",
"reactions": {
"7101149746568522": "😆". // Reaction by the customer on the Howdy! message
}
},
{
"recipientDetails": {
"name": "Sara Smith",
"id": "736532028017333",
"picture": "https://img.ayrshare.com/333/messages/facebook-eTZzhE2b.jpeg"
},
"senderId": "106638148652329",
"attachments": [
{
"type": "image",
"url": "https://scontent.xx.fbcdn.net/v/t1.15752-9/490986808_1193328359195158"
}
],
"conversationId": "t_3567590438533",
"created": "2024-06-06T00:54:32.455Z",
"action": "sent",
"recipientId": "736532028017333",
"id": "m_WJlfgzopxfdRM1wFTKYHKv7zh75P",
"updated": "2024-06-06T00:54:32.455Z",
"platform": "facebook",
"senderDetails": {
"name": "Ayrshare"
}
},
{
"senderId": "7101149746568444",
"senderDetails": {
"name": "John Smith",
"profileImage": "https://platform-lookaside.fbsbx.com/platform/profilepic/"
},
"conversationId": "t_10161117434308444",
"created": "2024-06-06T00:54:28.102Z",
"action": "received",
"recipientId": "106638148652329",
"id": "m_HGbotYJUmf4AzyPlJ-2uZqHwGtfTgQihX",
"message": "Look up!",
"platform": "facebook"
},
{
"senderId": "7101149746568444",
"senderDetails": {
"name": "John Smith",
"profileImage": "https://platform-lookaside.fbsbx.com/platform/profilepic/"
},
"conversationId": "t_10161117434308444",
"created": "2024-06-06T00:49:11.679Z",
"action": "received",
"recipientId": "106638148652444",
"id": "m_jXoYQIwTXaq2u06PG6Z8vaHwGtfTgQ",
"message": "How is the weather?",
"platform": "facebook"
}
],
"lastUpdated": "2024-06-09T21:46:04.233Z",
"nextUpdate": "2024-06-09T21:47:04.233Z"
}
{
"status": "success",
"messages": [
{
"id": "1893410668991234567",
"conversationId": "1234567890-9876543210",
"senderId": "9876543210",
"created": "2024-06-09T21:30:00.000Z",
"message": "Hey, how are you?",
"action": "received",
"senderDetails": {
"name": "Jane Doe",
"username": "janedoe"
}
},
{
"id": "1893410668991234566",
"conversationId": "1234567890-9876543210",
"senderId": "1234567890",
"created": "2024-06-09T21:28:00.000Z",
"message": "Hello!",
"action": "sent",
"senderDetails": {
"name": "My Account",
"username": "myaccount"
}
}
],
"messagesCount": 2,
"lastUpdated": "2024-06-09T21:46:04.233Z",
"nextUpdate": "2024-06-09T21:46:19.233Z",
"meta": {
"pagination": {
"hasMore": true,
"limit": 5,
"next": "eyJwYWdpbmF0aW9uVG9rZW4iOiIxODkzNDEwNjY4OTkxMjM0NTY1In0="
}
}
}
{
"status": "success",
"messages": [
{
"id": "wamid.HBgLMTQxNTU1NTEyMzQVAgARGBI3MEM3Q0NDQjlGRTUzMjJBNEUA",
"conversationId": "14155551234",
"senderId": "14155551234",
"recipientId": "123456789012345",
"created": "2026-05-18T17:10:02.000Z",
"message": "When is my order shipping?",
"action": "received",
"platform": "whatsapp"
},
{
"id": "wamid.HBgLMTQxNTU1NTEyMzQVAgARGBI4OUYxRkExNzE0M0EwQTYwM0EA",
"conversationId": "14155551234",
"senderId": "14155551234",
"recipientId": "123456789012345",
"created": "2026-05-18T17:08:41.000Z",
"attachments": [
{
"type": "image",
"url": "https://img.ayrshare.com/abc123/whatsapp/whatsapp_image_x9aB2pK7.jpg"
}
],
"action": "received",
"platform": "whatsapp"
}
],
"lastUpdated": "2026-05-18T17:13:00.000Z",
"nextUpdate": "2026-05-18T17:14:00.000Z"
}
{
"status": "success",
"conversationIds": ["14155551234", "447700900123"],
"converstationsDetails": [
{
"id": "14155551234",
"participant": {
"id": "14155551234",
"name": "Jane Customer"
},
"status": "active",
"unread": 2
},
{
"id": "447700900123",
"participant": {
"id": "447700900123"
},
"status": "active",
"unread": 0
}
],
"lastUpdated": "2026-05-18T17:13:00.000Z",
"nextUpdate": "2026-05-18T17:14:00.000Z"
}
{
"status": "success",
"conversationIds": ["t_10161117434308444", "t_356759043857444"],
"converstationsDetails": [
{
"id": "t_10161117434308444",
"participant": {
"name": "John Smith",
"id": "7101149746568444",
"picture": "https://platform-lookaside.fbsbx.com/platform/profilepic/"
},
"status": "active",
"watermark": 1717889607444
},
{
"id": "t_356759043857444",
"participant": {
"name": "Sara Johnson",
"id": "7365320280173444",
"picture": "https://platform-lookaside.fbsbx.com/platform/profilepic/"
},
"status": "active"
}
],
"lastUpdated": "2024-06-09T21:46:04.233Z",
"nextUpdate": "2024-06-09T21:47:04.233Z"
}
{
"action": "messages",
"status": "error",
"code": 361,
"message": "Messaging is not enabled for this User Profile. Please subscribe to Messaging and activate Messaging for this User Profile."
}
{
"action": "messages",
"status": "error",
"code": 362,
"message": "Messaging तक पहुँचने के लिए सोशल नेटवर्क को relink करने की आवश्यकता है। कृपया unlink करें, relink करें, और पुनः प्रयास करें।",
"resolution": {
"relink": true,
"platform": "facebook"
}
}
एक messaging प्लेटफ़ॉर्म के लिए संदेश या वार्तालाप प्राप्त करें।
प्रत्येक सोशल नेटवर्क पर retrieval समय भिन्न होते हैं। Facebook, Instagram, और WhatsApp पर, संदेश Ayrshare के माध्यम से वास्तविक समय में उपलब्ध हैं। X/Twitter पर, नए संदेश अद्यतन देखने के लिए 3 मिनट तक की देरी होती है। यदि आपको वास्तविक-समय X/Twitter संदेश पहुँच की आवश्यकता है तो Enterprise Plan के बारे में अधिक जानने के लिए कृपया सहायता से संपर्क करें।
Response caching: Facebook और Instagram के लिए, responses को 60 सेकंड के लिए cache किया जाता है। X/Twitter के लिए, polling का बेहतर समर्थन करने के लिए responses को 15 सेकंड के लिए cache किया जाता है। WhatsApp Meta webhooks के माध्यम से पहले से प्राप्त संदेशों को पढ़ता है, इसलिए एक नया प्राप्त संदेश Ayrshare के उसके webhook को प्रोसेस करते ही दिखाई दे सकता है। Response में
lastUpdated और nextUpdate metadata अब भी शामिल है।Facebook और Instagram के लिए प्रारंभिक संदेश इतिहास पुनर्प्राप्ति पिछले 20 संदेशों तक सीमित है।
अधिक जानकारी के लिए कृपया Facebook और
Instagram के लिए संदेश इतिहास पुनर्प्राप्ति
अनुभाग देखें।
WhatsApp बातचीत को correspondent के फ़ोन नंबर द्वारा पहचाना जाता है (केवल अंक, शुरुआती
+ के बिना E.164)। एक संग्रहीत outbound संदेश में status मान
sent, delivered, read, या failed हो सकता है।Send Message के माध्यम से भेजे गए WhatsApp संदेश वर्तमान में Get Messages
इतिहास में नहीं जोड़े जाते। Webhooks के माध्यम से प्राप्त इनकमिंग WhatsApp संदेश यहाँ संग्रहीत और लौटाए जाते हैं।
Header Parameters
Path Parameters
string
आवश्यक
संदेश प्राप्त करने के लिए प्लेटफ़ॉर्म:
facebook, instagram, twitter, whatsappQuery Parameters
string
डिफ़ॉल्ट:"active"
आवश्यक
Active वार्तालाप या archived वार्तालाप लौटाएँ। मान:
active या
archived।string
केवल विशिष्ट वार्तालाप लौटाएँ।
boolean
डिफ़ॉल्ट:false
सभी वार्तालाप लौटाएँ। यदि
true है तो conversationId field को अनदेखा किया जाता है।जब
conversationsOnly=true है, तो वार्तालाप विवरण converstationsDetails में लौटाए जाते हैं।
यह वर्तनी वर्तमान API response का हिस्सा है।integer
केवल X/Twitter। प्रति अनुरोध लौटाए गए संदेशों की संख्या सीमित करें (1–100)। पूर्ण इतिहास सिंक के बिना कुशल polling सक्षम करता है। Pagination के लिए
next के साथ उपयोग करें। यदि छोड़ दिया गया, तो डिफ़ॉल्ट व्यवहार (पूर्ण संदेश पुनर्प्राप्ति) का उपयोग किया जाता है।string
केवल X/Twitter। पिछले अनुरोध के
meta.pagination.next field से लौटाया गया एन्क्रिप्टेड pagination cursor। परिणामों का अगला पृष्ठ प्राप्त करने के लिए limit के साथ उपयोग करें।curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://api.ayrshare.com/api/messages/facebook
const apiKey = 'API_KEY';
const url = 'https://api.ayrshare.com/api/messages/facebook';
const headers = {
'Authorization': `Bearer ${apiKey}`,
};
fetch(url, {
method: 'GET',
headers: headers,
})
.then(response => {
if (response.ok) {
return response.json();
} else {
throw new Error(`Request failed. Status code: ${response.status}`);
}
})
.then(data => {
console.log('Response:', data);
})
.catch(error => {
console.error('Error:', error.message);
});
import requests
api_key = 'API_KEY'
url = 'https://api.ayrshare.com/api/messages/facebook'
headers = {
'Authorization': f'Bearer {api_key}',
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = response.json()
print('Response:', data)
else:
print(f'Request failed. Status code: {response.status_code}')
<?php
$apiKey = 'API_KEY';
$url = 'https://api.ayrshare.com/api/messages/facebook';
$headers = [
'Authorization: Bearer ' . $apiKey,
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if ($response === false) {
$error = curl_error($ch);
echo 'Error: ' . $error;
} else {
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode === 200) {
$responseData = json_decode($response, true);
print_r($responseData);
} else {
echo 'Request failed. Status code: ' . $statusCode;
}
}
curl_close($ch);
?>
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Text.Json;
class Program
{
static async Task Main()
{
string apiKey = "API_KEY";
string url = "https://api.ayrshare.com/api/messages/facebook";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
try
{
var response = await client.GetAsync(url);
if (response.IsSuccessStatusCode)
{
var responseBody = await response.Content.ReadAsStringAsync();
var responseData = JsonSerializer.Deserialize<dynamic>(responseBody);
Console.WriteLine("Response:");
Console.WriteLine(responseData);
}
else
{
Console.WriteLine($"Request failed. Status code: {response.StatusCode}");
}
}
catch (HttpRequestException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String apiKey = "API_KEY";
String url = "https://api.ayrshare.com/api/messages/facebook";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.GET()
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
String responseBody = response.body();
System.out.println("Response:");
System.out.println(responseBody);
} else {
System.out.println("Request failed. Status code: " + response.statusCode());
}
} catch (IOException | InterruptedException e) {
System.out.println("Error: " + e.getMessage());
}
}
}
{
"status": "success",
"messages": [
{
"senderId": "106638148652444",
"senderDetails": {
"name": "Ayrshare"
},
"conversationId": "t_10161117434308444",
"created": "2024-06-06T00:54:32.455Z",
"action": "sent",
"recipientId": "7101149746568444",
"id": "m_JH6o-yS83JoxWmQaLrmgSaHwGtfTgQ",
"message": "Howdy!",
"platform": "facebook",
"reactions": {
"7101149746568522": "😆". // Reaction by the customer on the Howdy! message
}
},
{
"recipientDetails": {
"name": "Sara Smith",
"id": "736532028017333",
"picture": "https://img.ayrshare.com/333/messages/facebook-eTZzhE2b.jpeg"
},
"senderId": "106638148652329",
"attachments": [
{
"type": "image",
"url": "https://scontent.xx.fbcdn.net/v/t1.15752-9/490986808_1193328359195158"
}
],
"conversationId": "t_3567590438533",
"created": "2024-06-06T00:54:32.455Z",
"action": "sent",
"recipientId": "736532028017333",
"id": "m_WJlfgzopxfdRM1wFTKYHKv7zh75P",
"updated": "2024-06-06T00:54:32.455Z",
"platform": "facebook",
"senderDetails": {
"name": "Ayrshare"
}
},
{
"senderId": "7101149746568444",
"senderDetails": {
"name": "John Smith",
"profileImage": "https://platform-lookaside.fbsbx.com/platform/profilepic/"
},
"conversationId": "t_10161117434308444",
"created": "2024-06-06T00:54:28.102Z",
"action": "received",
"recipientId": "106638148652329",
"id": "m_HGbotYJUmf4AzyPlJ-2uZqHwGtfTgQihX",
"message": "Look up!",
"platform": "facebook"
},
{
"senderId": "7101149746568444",
"senderDetails": {
"name": "John Smith",
"profileImage": "https://platform-lookaside.fbsbx.com/platform/profilepic/"
},
"conversationId": "t_10161117434308444",
"created": "2024-06-06T00:49:11.679Z",
"action": "received",
"recipientId": "106638148652444",
"id": "m_jXoYQIwTXaq2u06PG6Z8vaHwGtfTgQ",
"message": "How is the weather?",
"platform": "facebook"
}
],
"lastUpdated": "2024-06-09T21:46:04.233Z",
"nextUpdate": "2024-06-09T21:47:04.233Z"
}
{
"status": "success",
"messages": [
{
"id": "1893410668991234567",
"conversationId": "1234567890-9876543210",
"senderId": "9876543210",
"created": "2024-06-09T21:30:00.000Z",
"message": "Hey, how are you?",
"action": "received",
"senderDetails": {
"name": "Jane Doe",
"username": "janedoe"
}
},
{
"id": "1893410668991234566",
"conversationId": "1234567890-9876543210",
"senderId": "1234567890",
"created": "2024-06-09T21:28:00.000Z",
"message": "Hello!",
"action": "sent",
"senderDetails": {
"name": "My Account",
"username": "myaccount"
}
}
],
"messagesCount": 2,
"lastUpdated": "2024-06-09T21:46:04.233Z",
"nextUpdate": "2024-06-09T21:46:19.233Z",
"meta": {
"pagination": {
"hasMore": true,
"limit": 5,
"next": "eyJwYWdpbmF0aW9uVG9rZW4iOiIxODkzNDEwNjY4OTkxMjM0NTY1In0="
}
}
}
{
"status": "success",
"messages": [
{
"id": "wamid.HBgLMTQxNTU1NTEyMzQVAgARGBI3MEM3Q0NDQjlGRTUzMjJBNEUA",
"conversationId": "14155551234",
"senderId": "14155551234",
"recipientId": "123456789012345",
"created": "2026-05-18T17:10:02.000Z",
"message": "When is my order shipping?",
"action": "received",
"platform": "whatsapp"
},
{
"id": "wamid.HBgLMTQxNTU1NTEyMzQVAgARGBI4OUYxRkExNzE0M0EwQTYwM0EA",
"conversationId": "14155551234",
"senderId": "14155551234",
"recipientId": "123456789012345",
"created": "2026-05-18T17:08:41.000Z",
"attachments": [
{
"type": "image",
"url": "https://img.ayrshare.com/abc123/whatsapp/whatsapp_image_x9aB2pK7.jpg"
}
],
"action": "received",
"platform": "whatsapp"
}
],
"lastUpdated": "2026-05-18T17:13:00.000Z",
"nextUpdate": "2026-05-18T17:14:00.000Z"
}
{
"status": "success",
"conversationIds": ["14155551234", "447700900123"],
"converstationsDetails": [
{
"id": "14155551234",
"participant": {
"id": "14155551234",
"name": "Jane Customer"
},
"status": "active",
"unread": 2
},
{
"id": "447700900123",
"participant": {
"id": "447700900123"
},
"status": "active",
"unread": 0
}
],
"lastUpdated": "2026-05-18T17:13:00.000Z",
"nextUpdate": "2026-05-18T17:14:00.000Z"
}
{
"status": "success",
"conversationIds": ["t_10161117434308444", "t_356759043857444"],
"converstationsDetails": [
{
"id": "t_10161117434308444",
"participant": {
"name": "John Smith",
"id": "7101149746568444",
"picture": "https://platform-lookaside.fbsbx.com/platform/profilepic/"
},
"status": "active",
"watermark": 1717889607444
},
{
"id": "t_356759043857444",
"participant": {
"name": "Sara Johnson",
"id": "7365320280173444",
"picture": "https://platform-lookaside.fbsbx.com/platform/profilepic/"
},
"status": "active"
}
],
"lastUpdated": "2024-06-09T21:46:04.233Z",
"nextUpdate": "2024-06-09T21:47:04.233Z"
}
{
"action": "messages",
"status": "error",
"code": 361,
"message": "Messaging is not enabled for this User Profile. Please subscribe to Messaging and activate Messaging for this User Profile."
}
{
"action": "messages",
"status": "error",
"code": 362,
"message": "Messaging तक पहुँचने के लिए सोशल नेटवर्क को relink करने की आवश्यकता है। कृपया unlink करें, relink करें, और पुनः प्रयास करें।",
"resolution": {
"relink": true,
"platform": "facebook"
}
}
⌘I