Email API SDKs

Send transactional email with Node.js or PHP.

Install an official SDK to send transactional email and manage contacts, events, fields, and suppressions directly from a TypeScript, JavaScript, or PHP backend.

Quick start

import { Leadpush } from '@leadpush/sdk-node'

const client = new Leadpush(process.env.LEADPUSH_API_KEY!)

const send = await client.emails().send({
  from: 'alerts@example.com',
  to: ['customer@example.com'],
  subject: 'Your verification code',
  html: '<p>Your code is 482910</p>',
})

console.log(send.messages[0]?.uuid)

FAQ

Email API SDK questions

Confirm supported languages, transactional email features, and direct API or SMTP alternatives before integrating.

SDK Directory

Choose your language.

Browse official SDKs for connecting backend applications to Leadpush, with more language options added as they become available.

Node.js Install

Installation & Setup

Get from install to your first Leadpush API call in just a few minutes.

1

Install the package

Add the Node.js SDK to the backend project that will call the Leadpush API.

# npm
npm install @leadpush/sdk-node

# pnpm
pnpm add @leadpush/sdk-node

# yarn
yarn add @leadpush/sdk-node
2

Set your API key

Store the key in your environment or secret manager so it never ships to browser code.

LEADPUSH_API_KEY=leadpush_api_key
3

Create the client

Create a shared Leadpush client from your Node.js application code on the server.

import { Leadpush } from '@leadpush/sdk-node'

export const leadpush = new Leadpush(process.env.LEADPUSH_API_KEY!)
4

Send the first transactional email

Queue an email from a verified workspace sender and keep the returned message identifier for delivery troubleshooting.

const send = await leadpush.emails().send({
  from: 'alerts@example.com',
  to: ['customer@example.com'],
  subject: 'Your verification code',
  html: '<p>Your code is 482910</p>',
})

console.log(send.messages[0]?.uuid)

SDK Coverage

SDK helpers for common tasks.

SDKs make common Leadpush API tasks easier to call from application code, pairing language helpers with direct API requests.

Transactional email

Send password resets, OTPs, receipts, account alerts, and product notifications from Node.js or PHP application code.

Fully Typed

Build against fully typed APIs with predictable request parameters, response models, and editor support.

Events

Capture and inspect customer activity with structured APIs that keep event data consistent across your app.

Fields

Work with workspace data definitions through clear SDK helpers for custom properties and metadata.

Suppressions

Keep opt-out and delivery exclusion logic close to your application with dedicated suppression helpers.

Pagination helpers

Move through large result sets with pagination utilities designed for server tasks.

Direct API requests

Reach newer or specialized API endpoints while keeping authentication and error handling inside the SDK.

Pagination

Handle large result sets with less boilerplate.

Use SDK pagination helpers to read one response at a time or stream records through server jobs, sync tasks, and reports.

// Stream individual records across every page.
for await (const contact of client.contacts().listAll({ per_page: 100 })) {
  console.log(contact.uuid)
}

// Iterate one paginated response at a time.
for await (const page of client.contacts().cursor({ per_page: 100 })) {
  console.log(page.meta.current_page, page.data.length)
}

Errors

Respond to API issues with predictable handling.

Use consistent SDK error handling to route authentication, validation, timeout, missing resource, and unsupported endpoint states through your application logic.

ApiErrorUnauthorizedErrorForbiddenErrorNotFoundErrorValidationErrorTimeoutErrorUnsupportedEndpointError
import { UnauthorizedError, ValidationError } from '@leadpush/sdk-node'

try {
  await client.contacts().list()
} catch (error) {
  if (error instanceof UnauthorizedError) {
    console.error('Invalid API key')
  }

  if (error instanceof ValidationError) {
    console.error(error.response)
  }
}

Start Building

Add Leadpush to your application.

Choose an SDK, create an API key, and connect Leadpush resources to your backend services.