Skip to main content
PUT
/
api
/
drafts
/
[threadId]
Update Draft
curl --request PUT \
  --url 'https://api.example.com/api/drafts/[threadId]' \
  --header 'Content-Type: application/json' \
  --data '
{
  "content": "<string>",
  "subject": "<string>",
  "translation": "<string>",
  "status": {}
}
'
{
  "ok": true,
  "error": "<string>"
}

Authentication

Requires a valid session. Returns 401 if unauthorized.

Path Parameters

threadId
string
required
The unique identifier of the email thread

Request Body

All fields are optional. Only provided fields will be updated.
content
string
Draft email body in HTML format. Use semantic HTML tags like <p>, <strong>, <em>, <ol>, <ul>, <li>, <a>
subject
string
Email subject line
translation
string
Korean translation of the draft (plain text)
status
enum
Draft status. One of:
  • pending - Draft generation in progress
  • ready - Draft is ready to send
  • sent - Draft has been sent
  • skipped - Draft was skipped

Behavior

  • If no draft exists for the thread, a new one is created with ID draft-{threadId}
  • If a draft already exists, only the provided fields are updated
  • The updatedAt timestamp is automatically set to the current time
  • Omitted fields retain their existing values

Response

ok
boolean
Always returns true on success

Example Request

curl -X PUT https://api.delightbridge.com/api/drafts/thread-123 \
  -H "Content-Type: application/json" \
  -H "Cookie: session=your-session-token" \
  -d '{
    "content": "<p>Hi John,</p><p>Thank you for your patience...</p>",
    "subject": "Re: Order status inquiry",
    "status": "ready"
  }'

Example Response

{
  "ok": true
}

Partial Update Example

You can update just the status without touching other fields:
await fetch('/api/drafts/thread-123', {
  method: 'PUT',
  credentials: 'include',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ status: 'sent' })
});

Creating a New Draft

If no draft exists, all fields will use their defaults:
{
  "content": "",
  "subject": "",
  "translation": "",
  "status": "ready"
}

Error Responses

error
string
Error message describing what went wrong

401 Unauthorized

{
  "error": "Unauthorized"
}
Returned when the session is invalid or expired.

400 Bad Request

{
  "error": "Invalid request body"
}
Returned when the request body is malformed or contains invalid data.

Build docs developers (and LLMs) love