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

Authorizing your domain proves ownership and improves email deliverability by reducing the likelihood of your emails being marked as spam.
You can create or retrieve your API key from your SendLayer dashboard under the Settings » API Keys section.
Yes, you can provide an array of email addresses in the to field or see our guide for more details.
See our attachments guide for instructions on sending emails with attachments.
Check your domain authorization, verify your API key, and review the response from the API for any error messages. You can also consult the SendLayer dashboard for delivery status and logs.