Overview

SendLayer makes it easy to send transactional and marketing emails via a simple API. This guide walks you through sending your first email using the SendLayer API, with examples for popular programming languages.

Prerequisites

Sending an Email

After setting up your domain and API key, you can send emails using the SDK or directly via HTTP requests.
import { SendLayer } from 'sendlayer';

const sendlayer = new SendLayer('your-api-key');

const params = {
  from: 'sender@example.com',
  to: 'recipient@example.com', // or array of recipients
  subject: 'Test Email',
  text: 'This is a test email sent using SendLayer Node.js SDK',
};

const response = await sendlayer.Emails.send(params);
Replace <apiKey> with your actual SendLayer API key in the request header.
You can also send to multiple recipients, add CC/BCC, and attach files. SendLayer API also let’s you send HTML emails. This can be useful if you’d like to use a template to send welcome emails to new users. To send HTML emails, simply update the params variable to include the html object. Then enter your HTML email as a string.
const params = {
  from: 'sender@example.com',
  to: 'recipient@example.com', // or array of recipients
  subject: 'Test Email',
  html: '<html><body><p>This is a test email sent with the <a href=\"https://sendlayer.com\">SendLayer</a> API!</p></body></html>',
};

FAQ