> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ryzeapi.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Edit message

> Changes the content of a message you sent

**Auth:** `TokenAccount` or `TokenInstance` • **Rate-limit:** `Global` (100/min) • **Idempotent:** no

Edits the content of a message **you sent**. Only text messages are supported.

<Warning>
  **Edit window: \~15 minutes** after sending (limit imposed by WhatsApp). Older messages fail with `too old to edit`.
</Warning>

## Example

Send the new content in the `content` field. The original message must have been sent by the instance itself and be within the 15-minute window.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/chat/edit/$Instance_Name" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{
      "messageId": "3EB08FCF27E532F1B0F5",
      "content": "Sorry, I meant 6 PM"
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch(`https://ryzeapi.cloud/api/chat/edit/${process.env.Instance_Name}`, {
    method: "POST",
    headers: {
      "token":        process.env.Token_Instance,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      messageId: "3EB08FCF27E532F1B0F5",
      content:   "Sorry, I meant 6 PM"
    })
  });
  ```

  ```python Python theme={null}
  import os, requests

  requests.post(
      f"https://ryzeapi.cloud/api/chat/edit/{os.environ['Instance_Name']}",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "messageId": "3EB08FCF27E532F1B0F5",
          "content":   "Sorry, I meant 6 PM"
      }
  )
  ```

  ```go Go theme={null}
  package main

  import (
      "net/http"
      "os"
      "strings"
  )

  func main() {
      body := strings.NewReader(`{
          "messageId": "3EB08FCF27E532F1B0F5",
          "content": "Sorry, I meant 6 PM"
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/chat/edit/"+os.Getenv("Instance_Name"), body)
      req.Header.Set("token", os.Getenv("Token_Instance"))
      req.Header.Set("Content-Type", "application/json")
      http.DefaultClient.Do(req)
  }
  ```
</CodeGroup>

## Success response

```json 200 OK theme={null}
{
  "success": true,
  "message": "Message edited successfully",
  "messageId": "3EB08FCF27E532F1B0F5",
  "chatJid": "5511999999999@s.whatsapp.net",
  "oldContent": "Sorry, I meant 5 PM",
  "newContent": "Sorry, I meant 6 PM"
}
```

## Path parameters

<ParamField path="instance" type="string" required>
  Instance name.
</ParamField>

## Headers

<ParamField header="token" type="string" required>
  TokenAccount or TokenInstance.
</ParamField>

## Request body

<ParamField body="messageId" type="string" required>
  ID of the message to edit. It must exist and have been sent by you.
</ParamField>

<ParamField body="content" type="string" required>
  New message content.
</ParamField>

## Notes

<Note>
  * The recipient sees the new text with the "Edited" tag.
  * The edit emits a `message.exchange` event on the webhook/WebSocket with `type: "message_edit"` and `isEdit: true`.
  * Editing a media caption (image/video/document) is not reliably supported, use only on plain text messages.
</Note>

## Error responses

| HTTP | `error.message`                                       | When                                              |
| ---- | ----------------------------------------------------- | ------------------------------------------------- |
| 400  | `Invalid request body`                                | Malformed JSON.                                   |
| 400  | `messageId is required`                               | Missing field.                                    |
| 400  | `content is required`                                 | Missing `content` field.                          |
| 400  | message contains `too old to edit` or `can only edit` | Outside the 15-minute window or non-text message. |
| 401  | `Invalid token`                                       | ,                                                 |
| 404  | `Instance not found` or `message not found`           | ,                                                 |
| 503  | `Instance is not connected to WhatsApp`               | No active session.                                |
