GET
/
api
/
cron
/
send-account-setup-email
Send Account Setup Email
curl --request GET \
  --url https://onlyautomator.com/api/cron/send-account-setup-email
{
  "success": true,
  "count": 1,
  "testMode": true,
  "message": "Account setup email successfully sent to test address"
}
This endpoint triggers the sending of account setup emails to users who have not yet completed their account setup. It can be used to send either initial setup reminders (7-day) or monthly follow-up reminders.

Authentication

This endpoint requires API key authentication.

Query Parameters

testEmail
string
Optional. If provided, sends a test email to this address instead of to actual users
type
string
default:"initial"
Type of account setup email to send. Options: initial (7-day reminder) or monthly (monthly reminder)

Response

success
boolean
Indicates whether the operation was successful
count
number
Number of emails sent
testMode
boolean
Indicates if the endpoint was run in test mode
message
string
Status message about the operation

200 OK (Test Mode)

{
  "success": true,
  "count": 1,
  "testMode": true,
  "message": "Account setup email (initial) successfully sent to test address azzhh@indigobook.com"
}

200 OK (Production Mode)

{
  "success": true,
  "count": 12,
  "testMode": false,
  "message": "Account setup emails (initial) successfully sent to 12 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 initial setup email (7-day reminder)
const testInitialSetupEmail = async () => {
  const apiKey = "YOUR_API_KEY";
  const response = await fetch('http://localhost:3000/api/cron/send-account-setup-email?type=initial&testEmail=azzhh@indigobook.com', {
    method: 'GET',
    headers: {
      'Authorization': `Bearer ${apiKey}`
    }
  });
  
  const data = await response.json();
  console.log(data);
};

// Send a test monthly reminder
const testMonthlySetupEmail = async () => {
  const apiKey = "YOUR_API_KEY";
  const response = await fetch('http://localhost:3000/api/cron/send-account-setup-email?type=monthly&testEmail=azzhh@indigobook.com', {
    method: 'GET',
    headers: {
      'Authorization': `Bearer ${apiKey}`
    }
  });
  
  const data = await response.json();
  console.log(data);
};

// Trigger the actual job for sending initial setup emails
const sendInitialSetupEmails = async () => {
  const apiKey = "YOUR_API_KEY";
  const response = await fetch('http://localhost:3000/api/cron/send-account-setup-email?type=initial', {
    method: 'GET',
    headers: {
      'Authorization': `Bearer ${apiKey}`
    }
  });
  
  const data = await response.json();
  console.log(data);
};

// Trigger the actual job for sending monthly reminder emails
const sendMonthlySetupEmails = async () => {
  const apiKey = "YOUR_API_KEY";
  const response = await fetch('http://localhost:3000/api/cron/send-account-setup-email?type=monthly', {
    method: 'GET',
    headers: {
      'Authorization': `Bearer ${apiKey}`
    }
  });
  
  const data = await response.json();
  console.log(data);
};

Email Templates

This endpoint uses two different email templates based on the type parameter:

Initial Setup Email (7-day)

This email template is sent to users who registered 7 days ago but haven’t completed their account setup. It includes:
  • Personalized greeting
  • Reminder about incomplete setup
  • Step-by-step instructions on completing the setup
  • Direct link to the setup page
  • Contact information for support

Monthly Reminder Email

This email template is sent as a monthly reminder to users who haven’t completed their account setup after the initial reminder. It includes:
  • Personalized greeting
  • Stronger reminder about the benefits they’re missing
  • Updated instructions on completing the setup
  • Direct link to the setup page
  • Special offer or incentive (if applicable)
  • Contact information for support

Implementation Notes

  • This endpoint is designed to be called by a scheduled task (cron job)
  • When called without a testEmail parameter, it will find and email all applicable users
  • 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

Query Parameters

testEmail
string

Test email address to which the email will be sent

type
enum<string>

Type of account setup email to send (initial or monthly reminder)

Available options:
initial,
monthly

Response

Operation successful

success
boolean
Example:

true

count
integer
Example:

1

testMode
boolean
Example:

true

message
string
Example:

"Account setup email successfully sent to test address"