/api/qmail/db/drafts/create

GET POST

Save a new draft email. The server generates a fresh 16-byte email_id (returned as 32-char hex) and inserts the row into the local drafts table.

GET http://localhost:8081/api/qmail/db/drafts/create?subject=Quick%20note&body=See%20you%20tomorrow.&to=8189,9001

Description

All draft fields are optional; passing nothing yields a blank draft you can later populate via drafts/update. Body size is capped at 64 KB. Recipients are passed as comma-separated serial numbers.

Body — JSON or form

The handler accepts either a JSON body or form/query parameters. JSON wins when both are present.

Parameters

ParamTypeRequiredDescription
subjectstringNoSubject line.
bodystringNoUp to 64 KB.
tostring (CSV of SN)NoPrimary recipients, e.g. "8189,9001,9002".
ccstring (CSV of SN)NoCarbon-copy recipients.

Response — 201 Created

{
  "command": "drafts-create",
  "success": true,
  "message": "Draft created successfully",
  "email_id": "0c4f8e2a91b34d57a76e1d2c3b4a5968",
  "id": "0c4f8e2a91b34d57a76e1d2c3b4a5968",
  "timestamp": 1714083600
}

Errors

HTTPMessage
500Out of memory
500Failed to save draft

Example

# Save a draft (GET — easy browser/devtool testing)
curl "http://localhost:8081/api/qmail/db/drafts/create?subject=Quick%20note&body=See%20you%20tomorrow.&to=8189,9001"

# Save a draft (canonical POST)
curl -X POST "http://localhost:8081/api/qmail/db/drafts/create" \
  -d "subject=Quick note" \
  -d "body=See you tomorrow." \
  -d "to=8189,9001"

Related