Testing Emails

Before sending real emails to your users, test them using Notify’s sandbox environment and test API endpoints. Test emails don’t count against your usage limits but are logged in your Email Logs so you can preview them.

Testing via the Dashboard

Notify provides a built-in sandbox for testing emails visually. Access it at:
👉 notify.cx/dashboard/sandbox

Available Test Tools

  1. Email Testing Tab

    • Send test emails and preview the output
    • Validate rendering and formatting
  2. Template Testing Tab

    • Test templates with dynamic variables
    • Preview how variable replacement works
  3. Payload Testing Tab

    • Validate API request structure
    • Check JSON formatting before sending

How to Run a Test

  1. Open the Sandbox
  2. Select the type of test (basic email, template, or payload)
  3. Enter sample data
  4. Preview the output
  5. Click "Send Test Email"
  6. Review the result in your Email Logs

Testing via the Notify SDK/API

You can test emails programmatically using either the Notify SDK or direct API calls. Test emails use the same parameters as live emails but are sent to /api/test/... endpoints instead.

1. Install the Notify NPM Package

npm install notifycx

2. Initialize Notify

import Notify from 'notifycx';

const notify = new Notify('<your_api_key>');

3. Test Basic Emails (Without a Template)

async function testBasicEmail() {
  try {
    const response = await notify.sendTestEmail({
      to: 'test@example.com',
      subject: 'Test Email',
      name: 'Test User',
      message: 'Test content'
    });
  } catch (error) {
    console.error('Failed to test email:', error);
  }
}

testBasicEmail();

4. Test Template Emails (With Variables)

async function testTemplateEmail() {
  try {
    const response = await notify.sendTestEmailFromTemplate({
      to: 'test@example.com',
      from: 'noreply@notify.cx', // optional
      templateId: '<your_template_id>',
      variables: {
        name: 'Test User',
        order_id: 'TEST-123'
      }
    });
  } catch (error) {
    console.error('Failed to test template email:', error);
  }
}

testTemplateEmail();

5. Testing Without the SDK (Direct API Calls)

If you prefer raw HTTP requests, use the /api/test/... endpoints:

Test a Basic Email

await fetch('https://notify.cx/api/test/send-email', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': '<your_api_key>'
  },
  body: JSON.stringify({
    to: 'test@example.com',
    subject: 'Test Email',
    name: 'Test User',
    message: 'Test content'
  })
});

Test a Template Email

await fetch('https://notify.cx/api/test/send-email-from-template', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': '<your_api_key>'
  },
  body: JSON.stringify({
    to: 'test@example.com',
    templateId: '<your_template_id>',
    variables: {
      name: 'Test User',
      order_id: 'TEST-123'
    }
  })
});

Where to See Test Results?

Test emails don’t get sent to real recipients but are still logged for viewing: View Email Logs

Error Handling

Notify’s test endpoints return an object with both data and error properties:

const response = await notify.sendTestEmail({
  to: 'test@example.com',
  subject: 'Test Email',
  name: 'Test User',
  message: 'Test content'
});

if (error) {
  console.error('Test email failed:', error);
  return;
}

console.log('Test email logged:', response.data);

Common Errors:

  • Invalid API key
  • Invalid email format
  • Missing required parameters
  • Template not found
  • Undefined template variables

Next Steps