Skip to main content
DELETE
/
api
/
v1
/
emails
/
{id}
curl -X DELETE "https://api.jasni.ai/api/v1/emails/[email protected]&folder=INBOX" \
  -H "Authorization: Bearer jsk_your_api_key"
{
  "success": true,
  "message": "Email deleted successfully"
}

Request

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

Response

success
boolean
Indicates if the deletion was successful
message
string
Confirmation message
curl -X DELETE "https://api.jasni.ai/api/v1/emails/[email protected]&folder=INBOX" \
  -H "Authorization: Bearer jsk_your_api_key"
{
  "success": true,
  "message": "Email deleted successfully"
}

Webhook Event

When an email is deleted, an email.deleted webhook event is dispatched:
{
  "event": "email.deleted",
  "timestamp": "2024-01-15T10:30:00.000Z",
  "data": {
    "id": "12345",
    "account": "[email protected]"
  }
}

Behavior

Deleting an email is permanent and cannot be undone. The email is marked for deletion and expunged from the mailbox.
Depending on your email provider’s configuration, deleted emails may:
  • Be moved to a Trash folder
  • Be permanently deleted immediately

Use Cases

Cleanup Automation

Automatically delete processed emails:
async function cleanupProcessedEmails(processedIds) {
  for (const uid of processedIds) {
    await fetch(
      `https://api.jasni.ai/api/v1/emails/${uid}[email protected]`,
      {
        method: 'DELETE',
        headers: {
          'Authorization': 'Bearer jsk_your_api_key',
        },
      }
    );
  }
}

Spam Removal

Delete confirmed spam emails:
async function deleteSpam(email) {
  const isSpam = await spamDetector.check(email);
  
  if (isSpam.confidence > 0.95) {
    await fetch(
      `https://api.jasni.ai/api/v1/emails/${email.uid}[email protected]`,
      {
        method: 'DELETE',
        headers: {
          'Authorization': 'Bearer jsk_your_api_key',
        },
      }
    );
    
    console.log(`Deleted spam email: ${email.subject}`);
  }
}

Notes

  • The id must be a valid integer representing the email’s UID
  • The account parameter is required
  • Ensure you have the correct folder specified if the email is not in INBOX
  • Consider using the update endpoint to mark as read instead of deleting if you want to keep records