Skip to content

EditMessage#

Test Postman

The method is intended for editing a text message.

The method uses limits on the request rate per second.

Request#

To edit a message, you need to execute a request at:

POST
{{apiUrl}}/waInstance{{idInstance}}/editMessage/{{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 original message
message string Yes Message text. The new text (up to 4069 characters)

Limitations

When editing a message, the Telegram messenger imposes the following limitations:

  1. Only outgoing text messages can be edited.
  2. The editing period is usually limited to 48 hours after sending.
  3. When a message is edited, no new notification is triggered for the recipient.

Request body example#

Editing a message in a personal chat#

{
    "chatId": "10000000",
    "idMessage": "1763115112345",
    "message": "I use GREEN-API to send this message!"
}

Editing a message in a group chat#

{
    "chatId": "-10000000000000",
    "idMessage": "1763115112345",
    "message": "I use GREEN-API to send this message!"
}

Response#

Response fields#

Field Type Description
idMessage string Identifier of the edited message

Response body example#

{
    "idMessage": "1763115112345"
}

Errors#

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

HTTP code Error identifier Description
400 Bad Request
Validation failed
Validation error
400 Message editing time expired The time available for editing has expired
500 This message type cannot be edited An attempt to edit an incoming or non-text message

Code examples#

import requests

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

payload = {
    "chatId": "10000000",
    "message": "I use GREEN-API to send this message!",
    "idMessage": "1763115112345"
}
headers = {
    'Content-Type': 'application/json'
}

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

print(response.text.encode('utf8'))
curl --location -g --request POST '/waInstance{{idInstance}}/editMessage/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "chatId": "10000000",
    "message": "I use GREEN-API to send this message!",
    "idMessage": "1763115112345"
}'
package main
import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "{{apiUrl}}/waInstance{{idInstance}}/editMessage/{{apiTokenInstance}}"
method := "POST"

payload := strings.NewReader(`{`+"
"+`
    "chatId": "10000000",`+"
"+`
    "message": "I use GREEN-API to send this message!",`+"
"+`
    "idMessage": "1763115112345"`+"
"+`
}`)

client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)

if err != nil {
    fmt.Println(err)
    return
}
res, err := client.Do(req)
if err != nil {
    fmt.Println(err)
    return
}
defer res.Body.Close()

body, err := io.ReadAll(res.Body)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(string(body))
}
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("{{apiUrl}}/waInstance{{idInstance}}/editMessage/{{apiTokenInstance}}")
.body("{\r\n\t\"chatId\": \"10000000\",\r\n\t\"message\": \"I use GREEN-API to send this message!\",\r\n    \"idMessage\": \"1763115112345\"\r\n}")
.asString();