Prerequisites

Using SDK

1

Install SDK

npm install usesend-js
2

Initialize SDK

Get the API key from the useSend dashboard and initialize the SDK
import { UseSend } from "usesend-js";

const usesend = new UseSend("us_12345");
If you are running a self-hosted version of useSend, pass the base URL as the second argument:
const usesend = new UseSend("us_12345", "https://app.usesend.com");
3

Send Email

usesend.emails.send({
  to: "[email protected]",
  from: "[email protected]",
  subject: "useSend email",
  html: "<p>useSend is the best open source product to send emails</p>",
  text: "useSend is the best open source product to send emails",
});

Adding contacts programatically

1

Get the contact book id

Get the contact book id from the useSend dashboard. Copy the contact book id
2

Add contacts

usesend.contacts
  .create("clzeydgeygff", {
    email: "[email protected]",
    firstName: "Koushik",
    lastName: "KM",
  })
3

Update contact

usesend.contacts.update("clzeydgeygff", contactId, {
  firstName: "Koushik",
  lastName: "KM",
});