Set webhook url

Send a text message message

post
sendMessage

https://api.mercury.chat/sdk/v1/whatsapp/sendMessage?api_token=tokenAPI&instance=instance_number
Sets the URL for receiving webhook notifications of new messages and message delivery events (ack).
Request
Response
Query Parameters
api_token
required
string
The API token
Body Parameters
is_webhook_enable
required
number
true if you wish to enable the receipt of notifications on the url indicated in webhook_url
webhook_url
required
string
if is_webhook_enable is true. It is the Http or https URL for receiving notifications. For testing, we recommend using https://webhook.site
200: OK
In "data" there is a object with this field: - "is_webhook_enable" : boolean, if true the webhook is setting - "webhook_url" : string, url for receiving webhook notifications of new messages and message delivery events (ack).
{
"is_webhook_enable":true,
"webhook_url":"https://webhook.site/20bf0fed-dc7a-4a39-b8bf-9b48cfbc819d"
}
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/webhook?api_token=tokenAPI' \
-H 'Content-Type: application/json' \
-d '{
"is_webhook_enable":true,
"webhook_url":"https://webhook.site/0d45ed30-17f3-4768-8548-6c5493bd029e"
}'
var client = new RestClient("https://api.mercury.chat/sdk/v1/whatsapp/webhook?api_token=tokenAPI");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", "{\n\t\"is_webhook_enable\":true,\n\t\"webhook_url\":\"https://webhook.site/0d45ed30-17f3-4768-8548-6c5493bd029e\"\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/webhook?api_token=tokenAPI"
payload := strings.NewReader("{\n\t\"is_webhook_enable\":true,\n\t\"webhook_url\":\"https://webhook.site/0d45ed30-17f3-4768-8548-6c5493bd029e\"\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\"is_webhook_enable\":true,\n\t\"webhook_url\":\"https://webhook.site/0d45ed30-17f3-4768-8548-6c5493bd029e\"\n}");
Request request = new Request.Builder()
.url("https://api.mercury.chat/sdk/v1/whatsapp/webhook?api_token=tokenAPI")
.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/webhook',
qs: { api_token: 'tokenAPI' },
headers: { 'Content-Type': 'application/json' },
body:
{ is_webhook_enable: true,
webhook_url: 'https://webhook.site/0d45ed30-17f3-4768-8548-6c5493bd029e' },
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('https://api.mercury.chat/sdk/v1/whatsapp/webhook');
$request->setMethod(HTTP_METH_POST);
$request->setQueryData(array(
'api_token' => 'tokenAPI'
));
$request->setHeaders(array(
'Content-Type' => 'application/json'
));
$request->setBody('{
"is_webhook_enable":true,
"webhook_url":"https://webhook.site/0d45ed30-17f3-4768-8548-6c5493bd029e"
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
import requests
url = "https://api.mercury.chat/sdk/v1/whatsapp/webhook"
querystring = {"api_token":"tokenAPI"}
payload = "{\n\t\"is_webhook_enable\":true,\n\t\"webhook_url\":\"https://webhook.site/0d45ed30-17f3-4768-8548-6c5493bd029e\"\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/webhook?api_token=tokenAPI")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n\t\"is_webhook_enable\":true,\n\t\"webhook_url\":\"https://webhook.site/0d45ed30-17f3-4768-8548-6c5493bd029e\"\n}"
response = http.request(request)
puts response.read_body