This endpoint triggers the sending of welcome emails to new users who have recently registered for the service. It can be used to send a single test email or to process all eligible new users.
Authentication
This endpoint requires API key authentication.
Query Parameters
Optional. If provided, sends a test welcome email to this address instead of to actual users.
Response
Indicates whether the operation was successful
Indicates if the endpoint was run in test mode
Status message about the operation
200 OK (Test Mode)
{
"success": true,
"count": 1,
"testMode": true,
"message": "Welcome email successfully sent to test address [email protected]"
}
200 OK (Production Mode)
{
"success": true,
"count": 15,
"testMode": false,
"message": "Welcome emails successfully sent to 15 new users"
}
400 Bad Request
{
"success": false,
"message": "Invalid email format",
"error": "The provided test email address is not valid"
}
401 Unauthorized
{
"success": false,
"message": "Unauthorized. Invalid or missing API key."
}
Example Usage
// Send a test welcome email
const testWelcomeEmail = async () => {
const apiKey = "YOUR_API_KEY";
const response = await fetch('http://localhost:3000/api/cron/[email protected]', {
method: 'GET',
headers: {
'Authorization': `Bearer ${apiKey}`
}
});
const data = await response.json();
console.log(data);
};
// Trigger the actual job for sending welcome emails to all eligible users
const sendWelcomeEmails = async () => {
const apiKey = "YOUR_API_KEY";
const response = await fetch('http://localhost:3000/api/cron/send-welcome-email', {
method: 'GET',
headers: {
'Authorization': `Bearer ${apiKey}`
}
});
const data = await response.json();
console.log(data);
};
Email Template
The welcome email is designed to introduce new users to the OnlyAutomator platform. It includes:
- Personalized greeting with the user’s first name
- Brief introduction to the platform’s key features
- Information about the Chrome extension and its benefits
- Direct download link to the Chrome extension
- Quick getting started steps
- Support contact information
Implementation Notes
- This endpoint is designed to be called by a scheduled task (cron job)
- When called without a
testEmail parameter, it will find all users who registered within the last 24 hours
- The endpoint is rate limited to prevent accidental mass emails
- In production, authentication via API key is required
- Email sending is logged for audit purposes
Standard user JWT token for authentication.
Test email address to which the email will be sent
Example:"Welcome email successfully sent to test address"