Prerequisites

Using SDK

1

Install SDK

2

Initialize SDK

Get the API key from the Unsend dashboard and initialize the SDK

import { Unsend } from "unsend";

const unsend = new Unsend({ apiKey: "us_12345" });
3

Send Email

unsend.emails.send({
  to: "[email protected]",
  from: "[email protected]",
  subject: "Unsend email",
  html: "<p>Unsend is the best open source product to send emails</p>",
  text: "Unsend 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 Unsend dashboard. Copy the contact book id

2

Add contacts

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

Update contact

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