EditMessage#
Beta version
The functionality is in beta mode. Features are subject to change and may also work unstably. There may be additional charges for functionality in the future.
The method is editing the text message into a personal or a group chat.
Request#
To edit the text message, you have to execute a request at:
POST
{{apiUrl}}/waInstance{{idInstance}}/editMessage/{{apiTokenInstance}}
For apiUrl
, idInstance
and apiTokenInstance
request parameters, refer to Before you start section.
Request parameters#
Parameter | Type | Mandatory | Description |
---|---|---|---|
chatId | string | Yes | Chat Id |
idMessage | string | Yes | ID of the original message being edited |
message | string | Yes | Message text. Emoji 😃 characters supported. Requires UTF-8 encoding without BOM |
The maximum length of a text message is 20000 characters
Response body example#
Edit the message in personal chat:
{
"chatId": "11001234567@c.us",
"idMessage": "BAE5367237E13A87",
"message": "I use Green-API to send this message to you!"
}
Edit the message in group chat:
{
"chatId": "120363043968066561@g.us",
"idMessage": "BAE5367237E13A87",
"message": "I use Green-API to send this message to you!"
}
Response#
Response parameters#
Parameter | Type | Description |
---|---|---|
idMessage | string | ID of the editing message |
Response body example#
{
"idMessage": "3EB0C767D097B7C7C030"
}
EditMessage errors#
For a list of errors common to all methods, refer to Common errors section
HTTP code | Error identifier | Description |
---|---|---|
400 | Bad Request Validation failed | Validation error |
400 | Validation failed. Details: 'message' length must be less than or equal to 20000 characters long | The message text must be less than or equal to 20 000 characters |
500 | request entity too large | Json length exceeded (>100kb) |
Request examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/editMessage/{{apiTokenInstance}}"
payload = {
"chatId": "79123456789@c.us",
"idMessage": "BAE5367237E13A87",
"message": "I use Green-API to send this message to you!"
}
headers = {
'Content-Type': 'application/json'
}
response = requests.post(url, json=payload, headers=headers)
print(response.text.encode('utf8'))
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '/waInstance%7B%7BidInstance%7D%7D/editMessage/%7B%7BapiTokenInstance%7D%7D',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"chatId": "79123456789@c.us",
"idMessage": "BAE5367237E13A87",
"message": "I use Green-API to send this message to you!"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
curl --location -g --request POST '/waInstance{{idInstance}}/editMessage/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"chatId": "79123456789@c.us",
"idMessage": "BAE5367237E13A87",
"message": "I use Green-API to send this message to you!"
}'
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("/waInstance{{idInstance}}/editMessage/{{apiTokenInstance}}")
.header("Content-Type", "application/json")
.body("{\r\n \"chatId\": \"79123456789@c.us\",\r\n \"idMessage\": \"BAE5367237E13A87\",\r\n \"message\": \"I use Green-API to send this message to you!\"\r\n}")
.asString();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "/waInstance%7B%7BidInstance%7D%7D/editMessage/%7B%7BapiTokenInstance%7D%7D"
method := "POST"
payload := strings.NewReader(`{`+"
"+`
"chatId": "79123456789@c.us",`+"
"+`
"idMessage": "BAE5367237E13A87",`+"
"+`
"message": "I use Green-API to send this message to you!"`+"
"+`
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}