Skip to content

Node.js (npm package)

Send emails from your Node.js app with less code using the Waypoint npm package. It wraps the API and adds typed helpers for each endpoint.

Terminal window
npm install @usewaypoint/client --save

Learn more about setting up API keys.

const { createClient } = require("@usewaypoint/client");
const client = createClient(API_KEY_USERNAME, API_KEY_PASSWORD);

Learn more about sending templated emails API.

await client.emailMessages.createTemplated({
templateId: // template id example: 'wptemplate_xxxxxxxxxxxxxxxx',
to: // email address of recipient,
variables: // variables expected by the template,
});
const { createClient } = require("@usewaypoint/client");
const client = createClient(API_KEY_USERNAME, API_KEY_PASSWORD);
client.emailMessages.createTemplated({
templateId: "wptemplate_ABc123XYZ",
to: 'Jordan Isip <jordan@usewaypoint.com>',
variables: {
"passcode": "1234510",
"expiresIn": "45 minutes"
}
});

Learn more about sending test emails API.

await client.sandboxEmailMessages.createTemplated({
templateId: // template id example: 'wptemplate_xxxxxxxxxxxxxxxx',
to: // email address of recipient,
variables: // variables expected by the template
});

Learn more about sending emails without a template API.

await client.emailMessages.createRaw({
to: // email address of recipient,
subject: 'Hello',
bodyHtml: '<h1>Hello world</h1>'
});

Learn more about sending test emails API.

await client.sandboxEmailMessages.createRaw({
to: // email address of recipient,
subject: 'Hello',
bodyHtml: '<h1>Hello world</h1>'
});

Learn more about downloading templates API.

await client.templates.previewHtml(
'wptemplate_RXL7zGTGsvkXzAP3',
{
"passcode": "1234510",
"expiresIn": "45 minutes"
}
);