Skip to main content

Authentication

Initiate Authorization

GET /auth/email
Initiate email integration authorization

Parameters

userId
string
required
The ID of the user

Response

Redirects to email provider’s OAuth page

Authorization Callback

GET /email/callback
Callback endpoint for email authorization

Parameters

code
string
required
OAuth authorization code
state
string
required
State parameter for security verification

Response

Redirects to success or error page with status

Account Management

List Accounts

GET /email/accounts
Get connected email accounts

Parameters

userId
string
required
The ID of the user

Response

accounts
array
List of connected email accounts
{
  "accounts": [
    {
      "id": "account123",
      "email": "[email protected]",
      "provider": "gmail",
      "connected": true,
      "lastSync": "2024-03-14T12:00:00Z"
    }
  ]
}

Disconnect Account

DELETE /email/accounts/:accountId
Disconnect an email account

Parameters

accountId
string
required
ID of the email account to disconnect
userId
string
required
The ID of the user

Response

{
  "message": "Account disconnected successfully",
  "accountId": "account123"
}

Refresh Token

POST /email/accounts/:accountId/refresh
Refresh token for an email account

Parameters

accountId
string
required
ID of the email account
userId
string
required
The ID of the user

Response

{
  "message": "Token refreshed successfully",
  "expiresAt": "2024-04-14T12:00:00Z"
}

Email Operations

Send Email

POST /email/accounts/:accountId/send
Send an email through a connected account

Parameters

accountId
string
required
ID of the email account to send from
userId
string
required
The ID of the user

Request Body

{
  "to": ["[email protected]"],
  "cc": ["[email protected]"],
  "bcc": ["[email protected]"],
  "subject": "Email Subject",
  "body": {
    "text": "Plain text version",
    "html": "<p>HTML version</p>"
  },
  "attachments": [
    {
      "filename": "document.pdf",
      "content": "base64_encoded_content"
    }
  ]
}

Response

{
  "message": "Email sent successfully",
  "messageId": "msg123",
  "timestamp": "2024-03-14T12:00:00Z"
}