daimon.email
Api referenceDrafts

List Drafts

Retrieve all drafts for an inbox

Overview

List all email drafts for a specific inbox. Includes both unsent drafts and scheduled drafts.

Authentication

Authorizationstringpathrequired

Inbox API Key

Path Parameters

idstringpathrequired

The inbox ID (e.g., inb_abc123)

Query Parameters

limitnumberquery

Maximum number of drafts to return (1-100)

offsetnumberquery

Number of drafts to skip for pagination

labelstringquery

Filter drafts by label (e.g., customer-service, newsletter)

Request

curl -X GET https://api.daimon.email/v1/inboxes/inb_abc123/drafts?limit=20 \
  -H "Authorization: Bearer dm_free_7d8a9b0c1d2e3f4g5h6i7j8k9l0m1n2o"
import { DaimonClient } from 'daimon-email';

const client = new DaimonClient({
  apiKey: 'dm_free_7d8a9b0c1d2e3f4g5h6i7j8k9l0m1n2o'
});

const drafts = await client.inboxes.drafts.list('inb_abc123', {
  limit: 20,
  label: 'customer-service'
});

console.log(`Total drafts: ${drafts.total}`);

drafts.drafts.forEach(draft => {
  console.log(`To: ${draft.to}`);
  console.log(`Subject: ${draft.subject}`);
  if (draft.send_at) {
    console.log(`Scheduled: ${draft.send_at}`);
  }
});
from daimon_email import DaimonClient

client = DaimonClient(
    api_key='dm_free_7d8a9b0c1d2e3f4g5h6i7j8k9l0m1n2o'
)

drafts = client.inboxes.drafts.list('inb_abc123', {
    'limit': 20,
    'label': 'customer-service'
})

print(f"Total drafts: {drafts['total']}")

for draft in drafts['drafts']:
    print(f"To: {draft['to']}")
    print(f"Subject: {draft['subject']}")
    if draft['send_at']:
        print(f"Scheduled: {draft['send_at']}")

Response

{
  "result": {
    "drafts": [
      {
        "id": "dft_abc123",
        "inbox_id": "inb_abc123",
        "to": "customer@example.com",
        "cc": [],
        "bcc": [],
        "subject": "Your order is ready",
        "body_text": "Hi there,\n\nYour order #12345 has been processed...",
        "body_html": null,
        "send_at": null,
        "thread_id": null,
        "labels": ["customer-service", "order"],
        "created_at": "2024-03-11T14:23:45Z",
        "updated_at": "2024-03-11T14:23:45Z"
      },
      {
        "id": "dft_def456",
        "inbox_id": "inb_abc123",
        "to": "newsletter@example.com",
        "cc": [],
        "bcc": [],
        "subject": "Weekly Update",
        "body_text": "Here are this week's highlights...",
        "body_html": "<html><body>Here are this week's highlights...</body></html>",
        "send_at": "2024-03-12T09:00:00Z",
        "thread_id": null,
        "labels": ["newsletter"],
        "created_at": "2024-03-11T15:30:00Z",
        "updated_at": "2024-03-11T15:30:00Z"
      }
    ],
    "total": 12,
    "limit": 20,
    "offset": 0
  },
  "next_steps": [
    "Use GET /v1/inboxes/{id}/drafts/{draftId} to view full draft details",
    "Use POST /v1/inboxes/{id}/drafts/{draftId}/send to send a draft",
    "Use PATCH /v1/inboxes/{id}/drafts/{draftId} to edit a draft before sending"
  ]
}

Response Fields

result.draftsarray

Array of draft objects

Draft object
idstring

Unique draft identifier (e.g., dft_abc123)

inbox_idstring

The inbox this draft belongs to

tostring

Recipient email address

ccarray

Array of CC email addresses

bccarray

Array of BCC email addresses

subjectstring

Email subject line

body_textstring

Plain text email body

body_htmlstring

HTML email body (may be null)

send_atstring

ISO 8601 timestamp for scheduled sending (null if not scheduled)

thread_idstring

Thread ID this draft is attached to (null if not part of a thread)

labelsarray

Array of label strings applied to this draft

created_atstring

ISO 8601 timestamp when draft was created

updated_atstring

ISO 8601 timestamp when draft was last updated

result.totalnumber

Total number of drafts matching the filter criteria

result.limitnumber

Maximum number of drafts returned in this request

result.offsetnumber

Number of drafts skipped

next_stepsarray

Suggested actions the agent can take next

Filtering Scheduled Drafts

You can identify scheduled drafts by checking if send_at is not null:

const drafts = await client.inboxes.drafts.list('inb_abc123');

const scheduled = drafts.drafts.filter(d => d.send_at !== null);
const unsent = drafts.drafts.filter(d => d.send_at === null);

console.log(`Scheduled: ${scheduled.length}`);
console.log(`Unsent: ${unsent.length}`);