Skip to main content
PATCH
/
api
/
v1
/
emails
/
{id}
curl -X PATCH "https://api.jasni.ai/api/v1/emails/[email protected]" \
  -H "Authorization: Bearer jsk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "read"
  }'
{
  "success": true,
  "message": "Email marked as read"
}

Request

id
integer
required
Email UID to update
account
string
required
Email account the email belongs to
folder
string
default:"INBOX"
Folder where the email is located

Body

action
string
required
Action to perform. Must be either read or unread.

Response

success
boolean
Indicates if the update was successful
message
string
Confirmation message
curl -X PATCH "https://api.jasni.ai/api/v1/emails/[email protected]" \
  -H "Authorization: Bearer jsk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "read"
  }'
{
  "success": true,
  "message": "Email marked as read"
}

Actions

ActionDescriptionIMAP Flag
readMark the email as readSets \Seen flag
unreadMark the email as unreadRemoves \Seen flag

Use Cases

Batch Processing

Mark multiple emails as read after processing:
async function processInbox(emails) {
  for (const email of emails) {
    // Process the email
    await processEmail(email);
    
    // Mark as read
    await fetch(
      `https://api.jasni.ai/api/v1/emails/${email.uid}[email protected]`,
      {
        method: 'PATCH',
        headers: {
          'Authorization': 'Bearer jsk_your_api_key',
          'Content-Type': 'application/json',
        },
        body: JSON.stringify({ action: 'read' }),
      }
    );
  }
}

AI Agent Workflow

An AI agent might mark emails as unread if they need human review:
async function handleEmail(email) {
  const classification = await aiAgent.classify(email);
  
  if (classification.confidence < 0.8) {
    // Low confidence - mark as unread for human review
    await markAsUnread(email.uid);
    await notifyHuman(email, classification);
  } else {
    // High confidence - process and mark as read
    await aiAgent.respond(email);
    await markAsRead(email.uid);
  }
}

Notes

  • Only read and unread actions are currently supported
  • The operation modifies the IMAP \Seen flag on the email
  • Changes are immediately reflected in the mailbox