Request on-demand message history
curl --request POST \
--url https://api.wsapi.chat/chats/{chatId}/messages \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--header 'X-Instance-Id: <x-instance-id>' \
--data '
{
"lastMessageId": "3EB0A0B0C1D2E3F4",
"lastMessageSenderId": "1234567890",
"count": 50
}
'import requests
url = "https://api.wsapi.chat/chats/{chatId}/messages"
payload = {
"lastMessageId": "3EB0A0B0C1D2E3F4",
"lastMessageSenderId": "1234567890",
"count": 50
}
headers = {
"X-Instance-Id": "<x-instance-id>",
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Instance-Id': '<x-instance-id>',
'X-Api-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
lastMessageId: '3EB0A0B0C1D2E3F4',
lastMessageSenderId: '1234567890',
count: 50
})
};
fetch('https://api.wsapi.chat/chats/{chatId}/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));using RestSharp;
var options = new RestClientOptions("https://api.wsapi.chat/chats/{chatId}/messages");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("X-Instance-Id", "<x-instance-id>");
request.AddHeader("X-Api-Key", "<api-key>");
request.AddJsonBody("{\n \"lastMessageId\": \"3EB0A0B0C1D2E3F4\",\n \"lastMessageSenderId\": \"1234567890\",\n \"count\": 50\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
{
"status": "ok"
}{
"status": 400,
"detail": "invalid request body"
}{
"status": 401,
"detail": "unauthorized"
}{
"status": 403,
"detail": "device not paired"
}{
"status": 503,
"detail": "instance not available"
}Chats
Request on-demand message history
Triggers an on-demand history sync request for the given chat. The response arrives
asynchronously as a message_history_sync event via the configured publisher.
POST
/
chats
/
{chatId}
/
messages
Request on-demand message history
curl --request POST \
--url https://api.wsapi.chat/chats/{chatId}/messages \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--header 'X-Instance-Id: <x-instance-id>' \
--data '
{
"lastMessageId": "3EB0A0B0C1D2E3F4",
"lastMessageSenderId": "1234567890",
"count": 50
}
'import requests
url = "https://api.wsapi.chat/chats/{chatId}/messages"
payload = {
"lastMessageId": "3EB0A0B0C1D2E3F4",
"lastMessageSenderId": "1234567890",
"count": 50
}
headers = {
"X-Instance-Id": "<x-instance-id>",
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Instance-Id': '<x-instance-id>',
'X-Api-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
lastMessageId: '3EB0A0B0C1D2E3F4',
lastMessageSenderId: '1234567890',
count: 50
})
};
fetch('https://api.wsapi.chat/chats/{chatId}/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));using RestSharp;
var options = new RestClientOptions("https://api.wsapi.chat/chats/{chatId}/messages");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("X-Instance-Id", "<x-instance-id>");
request.AddHeader("X-Api-Key", "<api-key>");
request.AddJsonBody("{\n \"lastMessageId\": \"3EB0A0B0C1D2E3F4\",\n \"lastMessageSenderId\": \"1234567890\",\n \"count\": 50\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
{
"status": "ok"
}{
"status": 400,
"detail": "invalid request body"
}{
"status": 401,
"detail": "unauthorized"
}{
"status": 403,
"detail": "device not paired"
}{
"status": 503,
"detail": "instance not available"
}Authorizations
Instance or customer-level API key. Either the instance's own API key or the customer's API key is accepted. Must be paired with the X-Instance-Id header to identify the target instance.
Headers
The ID of the WhatsApp instance to use
Path Parameters
Chat JID (user or group)
Body
application/json
Response
History sync request accepted
Example:
"ok"
⌘I