Edit a message
Edit/update the content or topic of a message.
PATCH https://we.comake.online/api/v1/messages/{msg_id}
{msg_id}
in the above URL should be replaced with the ID of the
message you wish you update.
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://we.comake.online/api/v1/messages/42 \
-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
Permissions
You only have permission to edit a message if:
- You sent it, OR:
- This is a topic-only edit for a (no topic) message, OR:
- This is a topic-only edit and you are an admin, OR:
- This is a topic-only edit and your realm allows users to edit topics.
Parameters
message_id integer required in path
Example: 42
topic string optional
Example: "Castle"
The topic of the message. Only required for stream messages
(type="stream"
), ignored otherwise.
Maximum length of 60 characters.
Changes: New in Zulip 2.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: just the one indicated in
message_id
, messages in the same topic that had been sent after this
one, or all of them.
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 breadcrumb message to the old thread to
notify users where the messages were moved to.
Changes: New in Zulip 3.0 (feature level 9).
Defaults to true
.
send_notification_to_new_thread boolean optional
Example: true
Whether to send a notification message to the new thread to
notify users where the messages came from.
Changes: New in Zulip 3.0 (feature level 9).
Defaults to true
.
content string optional
Example: "Hello"
The content of the message. Maximum message size of 10000 bytes.
stream_id integer optional
Example: 42
The ID of the stream to access.
Response
Example response
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"
}