Skip to content

Node.js (npm package)

Send emails with even less code from your Node.js application by using the Waypoint npm package. In addition to being a helpful API wrapper, this npm package provides alias functions that enforce typescript payloads.

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"
}
);