Delete list of outbound messages queue

post
clearMessagesQueue

https://api.mercury.chat/sdk/v1/whatsapp/sendFile?api_token=tokenAPI&instance=instance_number
Delete list of outbound messages queue.
Request
Response
Query Parameters
instance
required
string
the instance number
api_token
required
string
the api token (see the "Authentication" section)
200: OK
In "data" there is a object with 2 fields: - message: string, description of delete operation - messageTextsExample: array of deleted messages
{
"object": "messagesQueue",
"data": {
"message": "Cleared 1 messages",
"messageTextsExample": ["text message"]
},
"has_more": false,
"count_api": 1,
"reset_count_api": 60
}
400: Bad Request
GENERIC ERROR

Examples of API calls in your preferred language:

cURL
C#
Go
Java
NodeJs
Objective-C
PHP
Python
Ruby
Swift
curl -X POST \
'https://api.mercury.chat/sdk/v1/whatsapp/clearMessagesQueue?api_token=tokenAPI&instance=instance_number' \
-H 'Content-Type: application/json' \
-d '{
"chatId":"445675757555@c.us",
"messageId":"true_445554433222@c.us_3EB0141C9B6DB5C27C1F"
}'
var client = new RestClient("https://api.mercury.chat/sdk/v1/whatsapp/clearMessagesQueue?api_token=tokenAPI&instance=instance_number");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", "{\n\t\"chatId\":\"445675757555@c.us\",\n\t\"messageId\":\"true_445554433222@c.us_3EB0141C9B6DB5C27C1F\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.mercury.chat/sdk/v1/whatsapp/clearMessagesQueue?api_token=tokenAPI&instance=instance_number"
payload := strings.NewReader("{\n\t\"chatId\":\"445675757555@c.us\",\n\t\"messageId\":\"true_445554433222@c.us_3EB0141C9B6DB5C27C1F\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"chatId\":\"445675757555@c.us\",\n\t\"messageId\":\"true_445554433222@c.us_3EB0141C9B6DB5C27C1F\"\n}");
Request request = new Request.Builder()
.url("https://api.mercury.chat/sdk/v1/whatsapp/clearMessagesQueue?api_token=tokenAPI&instance=instance_number")
.post(body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var request = require("request");
var options = { method: 'POST',
url: 'https://api.mercury.chat/sdk/v1/whatsapp/clearMessagesQueue',
qs: { api_token: 'tokenAPI', instance: 'instance_number' },
headers: { 'Content-Type': 'application/json' },
body:
{ chatId: '445675757555@c.us',
messageId: 'true_445554433222@c.us_3EB0141C9B6DB5C27C1F' },
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Content-Type": @"application/json" };
NSDictionary *parameters = @{ @"chatId": @"445675757555@c.us",
@"messageId": @"true_445554433222@c.us_3EB0141C9B6DB5C27C1F" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.mercury.chat/sdk/v1/whatsapp/clearMessagesQueue?api_token=tokenAPI&instance=instance_number"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
<?php
$request = new HttpRequest();
$request->setUrl('https://api.mercury.chat/sdk/v1/whatsapp/clearMessagesQueue');
$request->setMethod(HTTP_METH_POST);
$request->setQueryData(array(
'api_token' => 'tokenAPI',
'instance' => 'instance_number'
));
$request->setHeaders(array(
'Content-Type' => 'application/json'
));
$request->setBody('{
"chatId":"445675757555@c.us",
"messageId":"true_445554433222@c.us_3EB0141C9B6DB5C27C1F"
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
import requests
url = "https://api.mercury.chat/sdk/v1/whatsapp/clearMessagesQueue"
querystring = {"api_token":"tokenAPI","instance":"instance_number"}
payload = "{\n\t\"chatId\":\"445675757555@c.us\",\n\t\"messageId\":\"true_445554433222@c.us_3EB0141C9B6DB5C27C1F\"\n}"
headers = {'Content-Type': 'application/json'}
response = requests.request("POST", url, data=payload, headers=headers, params=querystring)
print(response.text)
require 'uri'
require 'net/http'
url = URI("https://api.mercury.chat/sdk/v1/whatsapp/clearMessagesQueue?api_token=tokenAPI&instance=instance_number")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n\t\"chatId\":\"445675757555@c.us\",\n\t\"messageId\":\"true_445554433222@c.us_3EB0141C9B6DB5C27C1F\"\n}"
response = http.request(request)
puts response.read_body
import Foundation
let headers = ["Content-Type": "application/json"]
let parameters = [
"chatId": "445675757555@c.us",
"messageId": "true_445554433222@c.us_3EB0141C9B6DB5C27C1F"
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercury.chat/sdk/v1/whatsapp/clearMessagesQueue?api_token=tokenAPI&instance=instance_number")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()