Create drafts
POST https://osdc.zulipchat.com/api/v1/drafts
Create one or more drafts on the server. These drafts will be automatically
synchronized to other clients via drafts
events.
Usage examples
curl -sSX POST https://osdc.zulipchat.com/api/v1/drafts \
-u BOT_EMAIL_ADDRESS:BOT_API_KEY \
--data-urlencode 'drafts=[{"content": "What are the contribution guidelines for this project?", "timestamp": 1595479019, "to": [1], "topic": "questions", "type": "stream"}]'
Parameters
drafts (object)[] optional
Example: [{"type": "stream", "to": [1], "topic": "questions", "content": "What are the contribution guidelines for this project?", "timestamp": 1595479019}]
A JSON-encoded list of containing new draft objects.
drafts object details:
-
id
: integer optional The unique ID of the draft. It will only used whenever the drafts are
fetched. This field should not be specified when the draft is being
created or edited.
-
type
: string required The type of the draft. Either unaddressed (empty string), "stream"
,
or "private"
(for one-on-one and group direct messages).
Must be one of: ""
, "stream"
, "private"
.
-
to
: (integer)[] required An array of the tentative target audience IDs. For channel
messages, this should contain exactly 1 ID, the ID of the
target channel. For direct messages, this should be an array
of target user IDs. For unaddressed drafts, this is ignored,
and clients should send an empty array.
-
topic
: string required For channel message drafts, the tentative topic name. For direct
or unaddressed messages, this will be ignored and should ideally
be the empty string. Should not contain null bytes.
-
content
: string required The body of the draft. Should not contain null bytes.
-
timestamp
: integer optional A Unix timestamp (seconds only) representing when the draft was
last edited. When creating a draft, this key need not be present
and it will be filled in automatically by the server.
Example: 1595479019
Response
Return values
Example response(s)
Changes: As of Zulip 7.0 (feature level 167), if any
parameters sent in the request are not supported by this
endpoint, a successful JSON response will include an
ignored_parameters_unsupported
array.
A typical successful JSON response may look like:
{
"ids": [
1,
2,
3
],
"msg": "",
"result": "success"
}
JSON response for when a draft targeted towards a channel does not specify
exactly one channel ID:
{
"code": "BAD_REQUEST",
"msg": "Must specify exactly 1 channel ID for channel messages",
"result": "error"
}