API Authentication

How to authenticate with the SipherMail API

Obtaining API Tokens

API tokens are obtained through NextAuth.js session tokens. For API access:

  1. Log in to your SipherMail account
  2. Go to Settings → API (if available) or use session-based authentication
  3. Generate an API token or use your session cookie
Example: cURL
curl -X POST https://api.siphermail.com/v1/send \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "recipient@example.com",
    "subject": "Hello",
    "body": "This is a test email"
  }'
Example: TypeScript
const response = await fetch('https://api.siphermail.com/v1/send', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    to: 'recipient@example.com',
    subject: 'Hello',
    body: 'This is a test email'
  })
});

const result = await response.json();