Skip to main content

Overview

Drafts allow you to save email messages before sending them. This is useful for composing emails over time, scheduling sends, or building approval workflows.

Draft Structure

A draft has the same structure as a message, stored in the Drafts folder:
FieldTypeDescription
uidintegerUnique identifier within the mailbox
fromstringSender email address
tostring[]Recipient email addresses
ccstring[]CC recipients
bccstring[]BCC recipients
subjectstringEmail subject line
textstringPlain text body
htmlstringHTML body
attachmentsobject[]List of attachments

Operations

Create a Draft

Save a new draft:
POST /api/v1/emails/drafts
{
  "account": "[email protected]",
  "to": ["[email protected]"],
  "subject": "Work in progress",
  "text": "This is a draft I'm working on...",
  "html": "<p>This is a draft I'm working on...</p>"
}

List Drafts

Retrieve all drafts:
GET /api/v1/[email protected]&folder=Drafts

Update a Draft

Modify an existing draft:
PUT /api/v1/emails/drafts/123
{
  "account": "[email protected]",
  "to": ["[email protected]", "[email protected]"],
  "subject": "Updated subject",
  "text": "Updated content..."
}

Send a Draft

Convert a draft into a sent email:
POST /api/v1/emails/drafts/123/send
{
  "account": "[email protected]"
}
When you send a draft, it is automatically moved from the Drafts folder to Sent.

Delete a Draft

Remove a draft without sending:
DELETE /api/v1/emails/drafts/[email protected]

Use Cases

Create drafts and send them later at a scheduled time using your application logic.
Save emails as drafts, send them through an approval process, then send once approved.
Let AI agents compose draft responses for human review before sending.
Store commonly used email templates as drafts for quick access.

AI Agent Workflow Example

A common pattern for AI email agents:
async function handleIncomingEmail(email) {
  // 1. AI generates a response
  const aiResponse = await generateAIResponse(email);
  
  // 2. Save as draft for human review
  const draft = await jasni.drafts.create({
    account: '[email protected]',
    to: [email.from],
    subject: `Re: ${email.subject}`,
    text: aiResponse.text,
    html: aiResponse.html
  });
  
  // 3. Notify team for review
  await notifyTeam({
    message: 'New AI draft ready for review',
    draftId: draft.uid,
    originalEmail: email.subject
  });
  
  // 4. Team reviews and either edits or approves
  // 5. Send the draft when approved
}

Best Practices

If building a compose UI, auto-save drafts every few seconds to prevent data loss.
Periodically review and delete old drafts that are no longer needed.
For sensitive communications, use drafts to enable human review before sending.