2022-07-21 00:01:06 +02:00
|
|
|
{generate_api_header(/messages:post)}
|
2017-12-22 02:31:40 +01:00
|
|
|
|
2017-12-22 02:24:30 +01:00
|
|
|
## Usage examples
|
2018-06-18 17:44:48 +02:00
|
|
|
|
2018-09-17 16:27:32 +02:00
|
|
|
{start_tabs}
|
2017-11-08 19:03:03 +01:00
|
|
|
|
2018-09-17 16:27:32 +02:00
|
|
|
{generate_code_example(python)|/messages:post|example}
|
|
|
|
|
2020-05-17 12:29:49 +02:00
|
|
|
{generate_code_example(javascript)|/messages:post|example}
|
2018-09-17 16:27:32 +02:00
|
|
|
|
|
|
|
{tab|curl}
|
2017-11-08 19:03:03 +01:00
|
|
|
|
2019-05-16 22:38:53 +02:00
|
|
|
``` curl
|
2018-06-18 17:44:48 +02:00
|
|
|
# For stream messages
|
2019-03-26 20:28:58 +01:00
|
|
|
curl -X POST {{ api_url }}/v1/messages \
|
2017-11-08 19:03:03 +01:00
|
|
|
-u BOT_EMAIL_ADDRESS:BOT_API_KEY \
|
2020-12-08 01:58:49 +01:00
|
|
|
--data-urlencode type=stream \
|
2022-09-13 08:39:44 +02:00
|
|
|
--data-urlencode 'to="Denmark"' \
|
2022-02-14 04:12:54 +01:00
|
|
|
--data-urlencode topic=Castle \
|
2020-12-08 01:58:49 +01:00
|
|
|
--data-urlencode 'content=I come not, friends, to steal away your hearts.'
|
2018-06-18 17:44:48 +02:00
|
|
|
|
2023-04-17 17:02:07 +02:00
|
|
|
# For direct messages
|
2019-03-26 20:28:58 +01:00
|
|
|
curl -X POST {{ api_url }}/v1/messages \
|
2018-06-18 17:44:48 +02:00
|
|
|
-u BOT_EMAIL_ADDRESS:BOT_API_KEY \
|
2023-04-17 17:02:07 +02:00
|
|
|
--data-urlencode type=direct \
|
2020-12-08 01:58:49 +01:00
|
|
|
--data-urlencode 'to=[9]' \
|
|
|
|
--data-urlencode 'content=With mirth and laughter let old wrinkles come.'
|
2017-11-08 19:03:03 +01:00
|
|
|
```
|
|
|
|
|
2018-09-17 16:27:32 +02:00
|
|
|
{tab|zulip-send}
|
2017-11-08 19:03:03 +01:00
|
|
|
|
2018-09-17 16:27:32 +02:00
|
|
|
You can use `zulip-send`
|
2017-11-08 19:03:03 +01:00
|
|
|
(available after you `pip install zulip`) to easily send Zulips from
|
|
|
|
the command-line, providing the message content via STDIN.
|
|
|
|
|
|
|
|
```bash
|
2018-06-18 17:44:48 +02:00
|
|
|
# For stream messages
|
2017-11-08 19:03:03 +01:00
|
|
|
zulip-send --stream Denmark --subject Castle \
|
|
|
|
--user othello-bot@example.com --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5
|
2018-06-18 17:44:48 +02:00
|
|
|
|
2023-04-17 17:02:07 +02:00
|
|
|
# For direct messages
|
2018-06-18 17:44:48 +02:00
|
|
|
zulip-send hamlet@example.com \
|
|
|
|
--user othello-bot@example.com --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5
|
2017-11-08 19:03:03 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
#### Passing in the message on the command-line
|
|
|
|
|
2018-06-18 17:44:48 +02:00
|
|
|
If you'd like, you can also provide the message on the command-line with the
|
|
|
|
`-m` or `--message` flag, as follows:
|
2017-11-08 19:03:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
zulip-send --stream Denmark --subject Castle \
|
2020-10-01 00:55:03 +02:00
|
|
|
--message 'I come not, friends, to steal away your hearts.' \
|
2017-11-08 19:03:03 +01:00
|
|
|
--user othello-bot@example.com --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5
|
|
|
|
```
|
|
|
|
|
2020-06-18 15:35:25 +02:00
|
|
|
You can omit the `user` and `api-key` parameters if you have a `~/.zuliprc`
|
2018-06-18 17:44:48 +02:00
|
|
|
file.
|
2017-11-08 19:03:03 +01:00
|
|
|
|
2018-09-17 16:27:32 +02:00
|
|
|
{end_tabs}
|
2017-12-22 02:31:40 +01:00
|
|
|
|
2020-06-18 15:35:25 +02:00
|
|
|
## Parameters
|
2018-01-20 22:03:05 +01:00
|
|
|
|
2018-06-18 18:15:08 +02:00
|
|
|
{generate_api_arguments_table|zulip.yaml|/messages:post}
|
2018-01-20 22:03:05 +01:00
|
|
|
|
2021-06-21 21:20:51 +02:00
|
|
|
{generate_parameter_description(/messages:post)}
|
|
|
|
|
2017-12-22 02:31:40 +01:00
|
|
|
## Response
|
|
|
|
|
2020-05-20 11:57:57 +02:00
|
|
|
{generate_return_values_table|zulip.yaml|/messages:post}
|
2017-12-22 02:31:40 +01:00
|
|
|
|
2021-06-21 21:39:57 +02:00
|
|
|
{generate_response_description(/messages:post)}
|
|
|
|
|
2022-11-07 20:35:08 +01:00
|
|
|
#### Example response(s)
|
2017-12-22 02:31:40 +01:00
|
|
|
|
2021-07-13 17:33:43 +02:00
|
|
|
{generate_code_example|/messages:post|fixture}
|