Create drafts
Create one or more drafts on the server. These drafts will be automatically
synchronized to other clients via drafts
events.
POST https://zulip.pr.business/api/v1/drafts
Usage examples
curl -sSX POST https://zulip.pr.business/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 PMs and private group messages).
Must be one of: ""
, "stream"
, "private"
.
-
to
: (integer)[] required An array of the tentative target audience IDs. For "stream"
messages, this should contain exactly 1 ID, the ID of the
target stream. For private 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 stream message drafts, the tentative topic name. For private
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
: number 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
When all of the drafts in the request are valid, this endpoint will return
an array of the IDs for the drafts that were just created in the same
order as they were requested. If any of the drafts failed the validation
step, then none of the drafts will be created and we would not get this
status code. The typical JSON response in such a case is:
{
"ids": [
1,
2,
3
],
"msg": "",
"result": "success"
}
JSON response for when a draft targeted towards a stream does not specify
exactly one stream ID:
{
"code": "BAD_REQUEST",
"msg": "Must specify exactly 1 stream ID for stream messages",
"result": "error"
}