Get a message's edit history

Fetch the message edit history of a previously edited message.

GET https://team.webramz.com/api/v1/messages/{message_id}/history

Note that edit history may be disabled in some organizations; see the Zulip Help Center documentation on editing messages.

Usage examples

#!/usr/bin/env python3

import zulip

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

# Get the edit history for message with ID "message_id"
result = client.get_message_history(message_id)
print(result)

curl -sSX GET -G https://team.webramz.com/api/v1/messages/42/history \
    -u BOT_EMAIL_ADDRESS:BOT_API_KEY

Parameters

message_id integer required in path

Example: 42

The target message's ID.


Response

Return values

  • message_history: (object)[] A chronologically sorted array of snapshot objects, each one with the values of the message after the edit.

    • topic: string the topic for the message.

    • prev_topic: string the topic for the message before being edited.

    • content: string the body of the message.

    • rendered_content: string the already rendered, HTML version of content.

    • prev_content: string the body of the message before being edited.

    • prev_rendered_content: string the already rendered, HTML version of prev_content.

    • user_id: integer the ID of the user that made the edit.

    • content_html_diff: string an HTML diff between this version of the message and the previous one.

    • timestamp: integer the UNIX timestamp for this edit.

Please note that the original message's snapshot only contains the fields topic, content, rendered_content, timestamp and user_id. This snapshot will be the only one present if the message has never been edited.

Also note that if a message's content was edited (but not the topic) or the topic was edited (but not the content), the snapshot object will only contain data for the modified fields (e.g. if only the topic was edited, prev_content, prev_rendered_content, and content_html_diff will not appear).

Example response

A typical successful JSON response may look like:

{
    "message_history": [
        {
            "content": "Hello!",
            "rendered_content": "<p>Hello!</p>",
            "timestamp": 1530129122,
            "topic": "party at my houz",
            "user_id": 5
        },
        {
            "content": "Howdy!",
            "content_html_diff": "<div><p><span class=\"highlight_text_inserted\">Howdy!</span></p> <p><span class=\"highlight_text_deleted\">Hello!</span></p></div>",
            "prev_content": "Hello!",
            "prev_rendered_content": "<p>Hello!</p>",
            "prev_topic": "party at my houz",
            "rendered_content": "<p>Howdy!</p>",
            "timestamp": 1530129134,
            "topic": "party at my house",
            "user_id": 5
        }
    ],
    "msg": "",
    "result": "success"
}

An example JSON response for when the specified message does not exist:

{
    "code": "BAD_REQUEST",
    "msg": "Invalid message(s)",
    "result": "error"
}