2018-07-03 18:17:23 +02:00
|
|
|
# Update a message's flags
|
|
|
|
|
|
|
|
Add or remove flags in a list of messages.
|
|
|
|
|
|
|
|
`POST {{ api_url }}/v1/messages/flags`
|
|
|
|
|
|
|
|
For updating the `read` flag on common collections of messages, see also
|
|
|
|
the
|
2018-10-16 22:03:59 +02:00
|
|
|
[special endpoints for marking message as read in bulk](/api/mark-as-read-bulk).
|
2018-07-03 18:17:23 +02:00
|
|
|
|
|
|
|
## Usage examples
|
|
|
|
|
2018-10-18 00:14:30 +02:00
|
|
|
{start_tabs}
|
|
|
|
{tab|python}
|
2018-07-03 18:17:23 +02:00
|
|
|
|
|
|
|
{generate_code_example(python)|/messages/flags:post|example}
|
|
|
|
|
2018-10-18 00:14:30 +02:00
|
|
|
{tab|js}
|
2018-07-03 18:17:23 +02:00
|
|
|
|
|
|
|
More examples and documentation can be found [here](https://github.com/zulip/zulip-js).
|
|
|
|
```js
|
|
|
|
const zulip = require('zulip-js');
|
|
|
|
|
|
|
|
// Download zuliprc-dev from your dev server
|
|
|
|
const config = {
|
|
|
|
zuliprc: 'zuliprc-dev',
|
|
|
|
};
|
|
|
|
|
|
|
|
const flagParams = {
|
|
|
|
messages: [4, 8, 15],
|
|
|
|
flag: 'read',
|
|
|
|
};
|
|
|
|
|
|
|
|
zulip(config).then((client) => {
|
|
|
|
// Add the "read" flag to messages with IDs 4, 8 and 15
|
|
|
|
client.messages.flags.add(flagParams)
|
|
|
|
.then(console.log)
|
|
|
|
|
|
|
|
// Remove the "read" flag from said messages
|
|
|
|
client.messages.flags.remove(flagParams)
|
|
|
|
.then(console.log);
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2018-10-18 00:14:30 +02:00
|
|
|
{tab|curl}
|
|
|
|
|
|
|
|
```
|
|
|
|
curl -X POST {{ api_url }}/v1/messages/flags \
|
|
|
|
-u BOT_EMAIL_ADDRESS:BOT_API_KEY \
|
|
|
|
-d "messages=[4,8,15]" \
|
|
|
|
-d "op=add" \
|
|
|
|
-d "flag=starred"
|
|
|
|
```
|
2018-07-03 18:17:23 +02:00
|
|
|
|
2018-10-18 00:14:30 +02:00
|
|
|
{end_tabs}
|
2018-07-03 18:17:23 +02:00
|
|
|
|
|
|
|
## Arguments
|
|
|
|
|
|
|
|
{generate_api_arguments_table|zulip.yaml|/messages/flags:post}
|
|
|
|
|
|
|
|
## Response
|
|
|
|
|
|
|
|
#### Return values
|
|
|
|
|
|
|
|
* `messages`: An array with the IDs of the modified messages.
|
|
|
|
|
|
|
|
#### Example response
|
|
|
|
|
|
|
|
A typical successful JSON response may look like:
|
|
|
|
|
|
|
|
{generate_code_example|/messages/flags:post|fixture(200)}
|