2018-01-04 23:49:11 +01:00
|
|
|
# Update a message
|
|
|
|
|
|
|
|
Edit/update the content or topic of a message.
|
|
|
|
|
2019-07-11 12:45:26 +02:00
|
|
|
`PATCH {{ api_url }}/v1/messages/{msg_id}`
|
2018-01-04 23:49:11 +01:00
|
|
|
|
2019-07-11 12:45:26 +02:00
|
|
|
`{msg_id}` in the above URL should be replaced with the ID of the
|
2018-01-04 23:49:11 +01:00
|
|
|
message you wish you update.
|
|
|
|
|
|
|
|
## Usage examples
|
|
|
|
|
2018-09-17 16:27:32 +02:00
|
|
|
{start_tabs}
|
|
|
|
{tab|python}
|
2018-01-19 17:43:26 +01:00
|
|
|
|
2018-05-15 19:28:42 +02:00
|
|
|
{generate_code_example(python)|/messages/{message_id}:patch|example}
|
2018-01-19 17:43:26 +01:00
|
|
|
|
2018-09-17 16:27:32 +02:00
|
|
|
{tab|js}
|
2018-01-04 23:49:11 +01:00
|
|
|
|
2018-01-13 22:40:16 +01:00
|
|
|
More examples and documentation can be found [here](https://github.com/zulip/zulip-js).
|
|
|
|
```js
|
|
|
|
const zulip = require('zulip-js');
|
|
|
|
|
2019-01-07 14:27:58 +01:00
|
|
|
// Pass the path to your zuliprc file here.
|
2018-01-13 22:40:16 +01:00
|
|
|
const config = {
|
2019-01-07 14:27:58 +01:00
|
|
|
zuliprc: 'zuliprc',
|
2018-01-13 22:40:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
zulip(config).then((client) => {
|
|
|
|
// Update a message
|
|
|
|
const params = {
|
|
|
|
message_id: 131,
|
|
|
|
content: 'New Content',
|
|
|
|
}
|
|
|
|
|
|
|
|
client.messages.update(params).then(console.log);
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2018-09-17 16:27:32 +02:00
|
|
|
{tab|curl}
|
|
|
|
|
2019-05-16 22:38:53 +02:00
|
|
|
``` curl
|
2019-07-11 12:45:26 +02:00
|
|
|
curl -X "PATCH" {{ api_url }}/v1/messages/{msg_id} \
|
2018-09-17 16:27:32 +02:00
|
|
|
-u BOT_EMAIL_ADDRESS:BOT_API_KEY \
|
2018-10-17 23:54:18 +02:00
|
|
|
-d $"content=New content"
|
2018-09-17 16:27:32 +02:00
|
|
|
```
|
2018-01-04 23:49:11 +01:00
|
|
|
|
2018-09-17 16:27:32 +02:00
|
|
|
{end_tabs}
|
2018-01-04 23:49:11 +01:00
|
|
|
|
2018-01-20 22:03:05 +01:00
|
|
|
## Permissions
|
|
|
|
|
|
|
|
You only have permission to edit a message if:
|
|
|
|
|
|
|
|
1. You sent it, **OR**:
|
|
|
|
2. This is a topic-only edit for a (no topic) message, **OR**:
|
|
|
|
3. This is a topic-only edit and you are an admin.
|
|
|
|
|
|
|
|
## Arguments
|
|
|
|
|
2018-05-15 19:28:42 +02:00
|
|
|
{generate_api_arguments_table|zulip.yaml|/messages/{message_id}:patch}
|
2018-01-20 22:03:05 +01:00
|
|
|
|
2018-01-04 23:49:11 +01:00
|
|
|
## Response
|
|
|
|
|
|
|
|
#### Example response
|
|
|
|
|
|
|
|
A typical successful JSON response may look like:
|
|
|
|
|
2018-05-15 19:28:42 +02:00
|
|
|
{generate_code_example|/messages/{message_id}:patch|fixture(200)}
|
2018-01-04 23:49:11 +01:00
|
|
|
|
|
|
|
A typical JSON response for when one doesn't have the permission to
|
|
|
|
edit a particular message:
|
|
|
|
|
2018-05-15 19:28:42 +02:00
|
|
|
{generate_code_example|/messages/{message_id}:patch|fixture(400)}
|