Skip to content

SendReaction#

Test Postman Apidog

The method is intended for sending a reaction to a message to a chat.

Request#

To send a reaction to a message, you need to execute a request at:

POST
{{apiUrl}}/waInstance{{idInstance}}/sendReaction/{{apiTokenInstance}}

To get the apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.

Request parameters#

Parameter Type Required Description
chatId string Yes Chat identifier
idMessage string Yes ID of the message to which the reaction will be set
reaction string Yes Reaction in the format of emoji characters or in unicode format (for example "\uD83D\uDC4F")Read more in our FAQ

Request body example#

Reaction in the format of emoji characters

{
    "chatId": "79876543210@c.us",
    "idMessage": "BAE550673B9C0497",
    "reaction": "❤️"
}

Reaction in the format of characters in unicode format

{
    "chatId": "79876543210@c.us",
    "idMessage": "BAE550673B9C0497",
    "reaction": "\\uD83D\\uDC4F"
}

Response#

Response fields#

Field Type Description
idMessage string Identifier of the sent message

Response body example#

{
    "idMessage": "BAE550673B9C0497"
}

SendReaction errors#

For the list of errors common to all methods, see the Common errors section

Code examples#

import requests

url = "{{apiUrl}}/waInstance{{idInstance}}/sendReaction/{{apiTokenInstance}}"

payload = {
    "chatId": "10000000",
    "idMessage": "BAE550673B9C0497",
    "reaction": "\\uD83D\\uDC4F"
}
headers = {
'Content-Type': 'application/json'
}

response = requests.post(url, json=payload, headers=headers)

print(response.text.encode('utf8'))
<?php
//The apiUrl, idInstance and apiTokenInstance values are available in console, double brackets must be removed
$url = '{{apiUrl}}/waInstance{{idInstance}}/sendReaction/{{apiTokenInstance}}';

//chatId is the number to send the message to (@c.us for private chats, @g.us for group chats)
$data = array(
    'chatId' => '10000000',
    'idMessage' => 'BAE550673B9C0497',
    'reaction' => '\\uD83D\\uDC4F'
);

$options = array(
    'http' => array(
        'header' => "Content-Type: application/json\r\n",
        'method' => 'POST',
        'content' => json_encode($data)
    )
);

$context = stream_context_create($options);

$response = file_get_contents($url, false, $context);

echo $response;
?>
curl --location '{{apiUrl}}/waInstance{{idInstance}}/sendReaction/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "chatId": "10000000",
    "idMessage": "BAE550673B9C0497",
    "reaction": "\\uD83D\\uDC4F"
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/sendReaction/")
    .append({{apiTokenInstance}});

var headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);

var jsonBody = "{\r\n\t\"chatId\": \"79876543210@c.us\",\r\n\t\"idMessage\": \"BAE550673B9C0497\",\r\n\t\"reaction\": \"\\uD83D\\uDC4F\"}";

var requestEntity = new HttpEntity<>(jsonBody, headers);

var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.POST, requestEntity, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/sendReaction/")
    .append({{apiTokenInstance}});

var response = Unirest.post(requestUrl.toString())
    .header("Content-Type", "application/json")
    .body("{\r\n\t\"chatId\": \"79876543210@c.us\",\r\n\t\"idMessage\": \"BAE550673B9C0497\",\r\n\t\"reaction\": \"\\uD83D\\uDC4F\"}")
    .asString();

System.out.println(response);
Sub SendReaction()
Dim URL As String
Dim RequestBody As String
Dim http As Object

' The apiUrl, idInstance and apiTokenInstance values are available in console, double brackets must be removed
URL = "{{apiUrl}}/waInstance{{idInstance}}/sendReaction/{{apiTokenInstance}}"

' chatId is the number to send the message to (@c.us for private chats, - for group chats)
RequestBody = "{""chatId"":""79876543210@c.us"",""idMessage"":""BAE550673B9C0497"", ""reaction"":""\\uD83D\\uDC4F""}"

Set http = CreateObject("MSXML2.XMLHTTP")

With http
    .Open "POST", URL, False
    .setRequestHeader "Content-Type", "application/json"
    .send RequestBody
End With

Set http = Nothing

End Sub
program sendReaction;

{$APPTYPE CONSOLE}

uses
System.SysUtils,
System.Classes, System.Net.HttpClient, System.Net.URLClient, System.Net.HttpClientComponent;

var
HttpClient: TNetHTTPClient;
RequestBody: TStringStream;
RequestHeaders: TNetHeaders;
Response: IHTTPResponse;
EndpointURL, ID_INSTANCE, API_TOKEN_INSTANCE: string;

begin
ID_INSTANCE := '110100001';
API_TOKEN_INSTANCE := 'd75b3a66374942c5b3c019c698abc2067e151558acbd451234';

EndpointURL := 'https://api.green-api.com/waInstance' + ID_INSTANCE + '/sendReaction/' + API_TOKEN_INSTANCE;

HttpClient := TNetHTTPClient.Create(nil);
RequestBody := TStringStream.Create('{ "chatId":"79876543210@c.us","idMessage":"BAE550673B9C0497", "reaction":"\\uD83D\\uDC4F"}', TEncoding.UTF8);
RequestHeaders := [
    TNetHeader.Create('Content-Type', 'application/json')
];

try
    Response := HTTPClient.Post(EndpointURL, RequestBody, nil, RequestHeaders);

    if Response.StatusCode = 200 then
    Writeln('[Response]: ' + Response.ContentAsString)
    else
    Writeln('[ERROR ' + IntToStr(Response.StatusCode) + ']:' + Response.StatusText + '' + Response.ContentAsString);

    readln;
except
    on E: Exception do
    Writeln(E.ClassName, ': ', E.Message);
end;

HttpClient.Free;
RequestBody.Free;

end.