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
AuthorizationstringpathrequiredInbox API Key
Path Parameters
idstringpathrequiredThe inbox ID (e.g., inb_abc123)
Query Parameters
limitnumberqueryMaximum number of drafts to return (1-100)
offsetnumberqueryNumber of drafts to skip for pagination
labelstringqueryFilter 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.draftsarrayArray of draft objects
Draft object
idstringUnique draft identifier (e.g., dft_abc123)
inbox_idstringThe inbox this draft belongs to
tostringRecipient email address
ccarrayArray of CC email addresses
bccarrayArray of BCC email addresses
subjectstringEmail subject line
body_textstringPlain text email body
body_htmlstringHTML email body (may be null)
send_atstringISO 8601 timestamp for scheduled sending (null if not scheduled)
thread_idstringThread ID this draft is attached to (null if not part of a thread)
labelsarrayArray of label strings applied to this draft
created_atstringISO 8601 timestamp when draft was created
updated_atstringISO 8601 timestamp when draft was last updated
result.totalnumberTotal number of drafts matching the filter criteria
result.limitnumberMaximum number of drafts returned in this request
result.offsetnumberNumber of drafts skipped
next_stepsarraySuggested 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}`);