Edit a message

PATCH https://chat.dpt.gba.gob.ar/api/v1/messages/{message_id}

Edit/update the content, topic, or stream of a message.

{msg_id} in the above URL should be replaced with the ID of the message you wish you update.

You can resolve topics by editing the topic to ✔ {original_topic}.

Note: See configuring message editing for detailed documentation on when users are allowed to edit topics.

Usage examples

#!/usr/bin/env python3

import zulip

# Pass the path to your zuliprc file here.
client = zulip.Client(config_file="~/zuliprc")

# Edit a message
# (make sure that message_id below is set to the ID of the
# message you wish to update)
request = {
    "message_id": message_id,
    "content": "New content",
}
result = client.update_message(request)
print(result)

More examples and documentation can be found here.

const zulipInit = require("zulip-js");

// Pass the path to your zuliprc file here.
const config = { zuliprc: "zuliprc" };

(async () => {
    const client = await zulipInit(config);

    // Update a message with the given "message_id"
    const params = {
        message_id,
        content: "New Content",
    };

    console.log(await client.messages.update(params));
})();

curl -sSX PATCH https://chat.dpt.gba.gob.ar/api/v1/messages/43 \
    -u BOT_EMAIL_ADDRESS:BOT_API_KEY \
    --data-urlencode topic=Castle \
    --data-urlencode propagate_mode=change_all \
    --data-urlencode send_notification_to_old_thread=true \
    --data-urlencode send_notification_to_new_thread=true \
    --data-urlencode content=Hello

Parameters

message_id integer required in path

Example: 43

The target message's ID.


topic string optional

Example: "Castle"

The topic to move the message(s) to, to request changing the topic. Maximum length of 60 characters.

Should only be sent when changing the topic, and will throw an error if the target message is not a stream message.

Changes: New in Zulip 2.0.0. Previous Zulip releases encoded this as subject, which is currently a deprecated alias.


propagate_mode string optional

Example: "change_all"

Which message(s) should be edited:

  • "change_later": The target message and all following messages.
  • "change_one": Only the target message.
  • "change_all": All messages in this topic.

Only the default value of "change_one" is valid when editing only the content of a message.

This parameter determines both which messages get moved and also whether clients that are currently narrowed to the topic containing the message should navigate or adjust their compose box recipient to point to the post-edit stream/topic.

Must be one of: "change_one", "change_later", "change_all". Defaults to "change_one".


send_notification_to_old_thread boolean optional

Example: true

Whether to send an automated message to the old topic to notify users where the messages were moved to.

Changes: Before Zulip 6.0 (feature level 152), this parameter had a default of true and was ignored unless the stream was changed.

New in Zulip 3.0 (feature level 9).

Defaults to false.


send_notification_to_new_thread boolean optional

Example: true

Whether to send an automated message to the new topic to notify users where the messages came from.

If the move is just resolving/unresolving a topic, this parameter will not trigger an additional notification.

Changes: Before Zulip 6.0 (feature level 152), this parameter was ignored unless the stream was changed.

New in Zulip 3.0 (feature level 9).

Defaults to true.


content string optional

Example: "Hello"

The updated content of the target message. Maximum message size of 10000 bytes.

Note that a message's content and stream cannot be changed at the same time, so sending both content and stream_id parameters will throw an error.


stream_id integer optional

Example: 43

The stream ID to move the message(s) to, to request moving messages to another stream.

Should only be sent when changing the stream, and will throw an error if the target message is not a stream message.

Note that a message's content and stream cannot be changed at the same time, so sending both content and stream_id parameters will throw an error.


Response

Example response(s)

A typical successful JSON response may look like:

{
    "msg": "",
    "result": "success"
}

A typical JSON response for when one doesn't have the permission to edit a particular message:

{
    "code": "BAD_REQUEST",
    "msg": "You don't have permission to edit this message",
    "result": "error"
}