API Documentation

Welcome to the SendTrue API documentation. This guide will help you integrate our email sending capabilities into your applications.

Authentication

All API requests require authentication using your API key. You can obtain an API key from your dashboard.

// Include in HTTP header
api-key: YOUR_API_KEY
mtp-id: YOUR_SMTP_ID

API Key Security

Client-Side Usage

⚠️ Warning: Never expose your main API key in client-side code. Use restricted client keys for frontend applications.

For client-side applications (browser/frontend):

  • Use client-specific restricted API keys with limited permissions
  • Set appropriate CORS and rate limiting
  • Consider implementing a proxy service for sensitive operations

Server-Side Usage

✓ Recommended: Use your main API key only in server-side applications.

For server-side applications:

  • Store API keys in secure environment variables
  • Use the full-access API key for complete control
  • Implement proper error handling and logging

Endpoints

POSThttps://api.sendtrue.io/v1/smtp/email

Send Email

Send a single email using SMTP configuration.

Request Body

{
  "from": "[email protected]",
  "to": "[email protected]",
  "subject": "Welcome to Our Service",
  "html": "<p>Welcome aboard!</p>",
  "text": "Welcome aboard!" // Optional plain text version
}

Response

{
  "success": true,
  "message": "Email sent successfully",
  "data": {
    "messageId": "123456789"
  }
}

Error Codes

CodeDescription
400Invalid request parameters
401Invalid or missing API key
429Rate limit exceeded
500Server error

SDKs & Libraries

Our official SDK is available on npm. Visit our npm package page for the latest version and detailed documentation.

Node.js

npm install sendtrue
// CommonJS Usage
const SendTrue = require("sendtrue");

// Or ES Modules Usage
import SendTrue from "sendtrue";

const sendTrue = new SendTrue({
  apiKey: "YOUR_API_KEY",
  smtpId: "YOUR_SMTP_ID",
});

sendTrue.sendEmail({
  from: "[email protected]",
  to: "[email protected]",
  subject: "Hello",
  text: "Hello World!",
});

React.js

import SendTrue from "sendtrue";

function EmailComponent() {
  const sendEmail = async () => {
    const sendTrue = new SendTrue({
      apiKey: "YOUR_API_KEY",
      smtpId: "YOUR_SMTP_ID",
    });

    try {
      await sendTrue.sendEmail({
        from: "[email protected]",
        to: "[email protected]",
        subject: "Hello",
        text: "Hello World!",
      });
    } catch (error) {
      console.error(error);
    }
  };

  return <button onClick={sendEmail}>
    Send Email
  </button>;
}

SMTP Configuration

Here's how to use SendTrue with configure SMTP settings in your application.

SMTP ID Configuration

// Option 1: In constructor
const sendTrue = new SendTrue({
  apiKey: "your-api-key",
  smtpId: "your-smtp-id",
});

// Option 2: Using use() method
const sendTrue = new SendTrue({
  apiKey: "your-api-key",
});

sendTrue.smtp.use({
  smtpId: "your-smtp-id",
});

// Send email with the specified SMTP ID
await sendTrue.sendEmail({
  from: "[email protected]",
  to: "[email protected]",
  subject: "Hello from SendTrue",
  text: "This is a test email",
  html: "<p>This is a test email</p>",
});

API Reference

Constructor

new SendTrue(options);

Options

  • apiKey (string, required): Your SendTrue API key
  • smtpId (string, required): Your SMTP ID

Methods

sendEmail(options)

Sends an email using SendTrue's API.

Options

  • from (string, optional): Sender email address
  • to (string, required): Recipient email address
  • subject (string, required): Email subject
  • text (string, optional): Plain text version of the email
  • html (string, optional): HTML version of the email

Returns

Promise that resolves with the API response

Support

If you need help or have any questions, you can:

Video Tutorials

Getting Started with SendTrue
1:18

Getting Started with SendTrue

API Key Management
1:23

API Key Management

NPM Package Installations
1:14

NPM Package Installations