npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-mailwizz

v2.1.0

Published

MailWizz implementation

Readme

NPM version

Node.JS Integration for Mailwizz

Harness the power of MailWizz, the full-featured, self-hosted email marketing software that's been battle-tested since 2013. With top-notch support, extensive documentation, and a developer-friendly environment, MailWizz integrates seamlessly with a plethora of third-party services like Sendgrid, Amazon SES, and Mailgun.

🔗 MailWizz Official Website

Acknowledgments

A huge shoutout to the brilliant minds behind the evolution of this library:

  • ntlzz93: For crafting the original library that started it all.
  • chgonzalez9: For helping with the migration to TypeScript, enhancing the developer experience.
  • kodjunkie: For contributing the unsubscribe method, a crucial feature for email marketing.

Your contributions have been instrumental in shaping node-mailwizz into the tool it is today!

Getting Started

Installation

Install node-mailwizz via npm to jumpstart your email marketing campaigns:

npm install node-mailwizz --save

🔥 Got an idea or facing an issue? Jump right in with a pull request or spark a discussion with an issue.

📂 For a sneak peek at the available APIs and their parameters, take a dive into the src directory, some of them are available but not documented yet.

Table of Contents


Config Object

The config object is required to initialize the API classes. It contains the following properties:

const config = {
	publicKey: "yourPublicKey",
	secret: "yourSecretKey",
	baseUrl: "yourMailwizzApiUrl"
};

Campaigns API

Get All Campaigns

import { Campaigns } from "node-mailwizz";

const campaigns = new Campaigns(config);

campaigns
	.getCampaigns({ page: 1, per_page: 10 })
	.then(result => console.log("Campaigns:", result))
	.catch(err => console.error("Error:", err));

Get a Campaign

campaigns
	.getCampaign({ campaignUid: "CAMPAIGN-UID" })
	.then(result => console.log("Campaign:", result))
	.catch(err => console.error("Error:", err));

Create a Campaign

import { Campaigns, CreateCampaignType } from "node-mailwizz";

const campaigns = new Campaigns(config);

campaigns
	.create({
		name: "Campaign Name",
		type: CreateCampaignType.REGULAR,
		fromName: "Mikel Calvo",
		fromEmail: "[email protected]",
		subject: "Hi!",
		replyTo: "[email protected]",
		sendAt: "2021-01-01 00:00:00",
		listId: "YOUR-LIST-ID",
		segmentId: "YOUR-SEGMENT-ID",
		urlTracking: "yes",
		templateId: "YOUR-TEMPLATE-ID"
	})
	.then(result => console.log("Campaign created:", result))
	.catch(err => console.error("Error:", err));

Update a Campaign

campaigns
	.update({
		campaignUid: "CAMPAIGN-UID",
		name: "Updated Name",
		subject: "Updated Subject"
	})
	.then(result => console.log("Campaign updated:", result))
	.catch(err => console.error("Error:", err));

Copy a Campaign

campaigns
	.copy({ campaignUid: "CAMPAIGN-UID" })
	.then(result => console.log("Campaign copied:", result))
	.catch(err => console.error("Error:", err));

Pause/Unpause a Campaign

campaigns
	.pauseUnpause({ campaignUid: "CAMPAIGN-UID" })
	.then(result => console.log("Campaign toggled:", result))
	.catch(err => console.error("Error:", err));

Mark Campaign as Sent

campaigns
	.markSent({ campaignUid: "CAMPAIGN-UID" })
	.then(result => console.log("Campaign marked as sent:", result))
	.catch(err => console.error("Error:", err));

Delete a Campaign

campaigns
	.delete({ campaignUid: "CAMPAIGN-UID" })
	.then(result => console.log("Campaign deleted:", result))
	.catch(err => console.error("Error:", err));

Get Campaign Stats

campaigns
	.getStats({ campaignUid: "CAMPAIGN-UID" })
	.then(result => console.log("Campaign stats:", result))
	.catch(err => console.error("Error:", err));
// getCampaigns response
GetCampaignsResponse {
	status: string;
	data: {
		count: string;
		total_pages: number;
		current_page: number;
		next_page: number;
		prev_page: number;
		records: CampaignRecord[];
	};
}

// getStats response
CampaignStats {
	campaign_status: string;
	subscribers_count: number;
	processed_count: number;
	delivery_success_count: number;
	delivery_success_rate: string;
	opens_count: number;
	opens_rate: string;
	unique_opens_count: number;
	clicks_count: number;
	clicks_rate: string;
	unsubscribes_count: number;
	bounces_count: number;
	hard_bounces_count: number;
	soft_bounces_count: number;
}

Campaign Bounces API

Get Campaign Bounces

import { CampaignBounces } from "node-mailwizz";

const bounces = new CampaignBounces(config);

bounces
	.getBounces({ campaignUid: "CAMPAIGN-UID", page: 1, per_page: 10 })
	.then(result => console.log("Bounces:", result))
	.catch(err => console.error("Error:", err));

Create a Campaign Bounce

import { CampaignBounces, BounceType } from "node-mailwizz";

const bounces = new CampaignBounces(config);

bounces
	.createBounce({
		campaignUid: "CAMPAIGN-UID",
		subscriberUid: "SUBSCRIBER-UID",
		bounceType: BounceType.HARD,
		message: "Mailbox not found"
	})
	.then(result => console.log("Bounce created:", result))
	.catch(err => console.error("Error:", err));

Templates API

Get All Templates

import { Templates } from "node-mailwizz";

const templates = new Templates(config);

templates
	.getTemplates({
		page: 1,
		per_page: 10
	})
	.then(result => console.log("Templates:", result))
	.catch(err => console.error("Error:", err));
GetAllTemplatesResponse {
	status: string;
	data: {
		records: GetAllTemplatesResponseRecord[];
	};
}

GetAllTemplatesResponseRecord {
	template_uid: string;
	name: string;
	screenshot: string;
}

Get a Specific Template

import { Templates } from "node-mailwizz";

const templates = new Templates(config);

templates
	.getTemplate({
		templateUid: "YOUR-TEMPLATE-UID"
	})
	.then(result => console.log("Template details:", result))
	.catch(err => console.error("Error:", err));
GetTemplateResponse {
	status: string;
	data: {
		record: GetTemplateResponseRecord;
	};
}

GetTemplateResponseRecord {
    template_uid: string;
    name: string;
    screenshot: string;
}

Search Templates

import { Templates } from "node-mailwizz";

const templates = new Templates(config);

templates
	.search({
		page: 1,
		per_page: 10,
		name: "newsletter"
	})
	.then(result => console.log("Templates found:", result))
	.catch(err => console.error("Error:", err));

Create a Template

import { Templates } from "node-mailwizz";

const templates = new Templates(config);

templates
	.create({
		name: "My Template",
		content: "<html><body>Hello [FNAME]!</body></html>",
		inlineCss: "yes",
		minify: "yes"
	})
	.then(result => console.log("Template created:", result))
	.catch(err => console.error("Error:", err));
CreateTemplateResponse {
	status: string;
	template_uid: string;
}

Update a Template

import { Templates } from "node-mailwizz";

const templates = new Templates(config);

templates
	.update({
		templateUid: "YOUR-TEMPLATE-UID",
		name: "Updated Template Name",
		content: "<html><body>Updated content!</body></html>"
	})
	.then(result => console.log("Template updated:", result))
	.catch(err => console.error("Error:", err));
UpdateTemplateResponse {
	status: string;
}

Delete a Template

import { Templates } from "node-mailwizz";

const templates = new Templates(config);

templates
	.delete({
		templateUid: "YOUR-TEMPLATE-UID"
	})
	.then(result => console.log("Template deleted:", result))
	.catch(err => console.error("Error:", err));
DeleteTemplateResponse {
	status: string;
}

Subscriber API

Create a Subscriber

import { ListSubscribers } from "node-mailwizz";

const subscribers = new ListSubscribers(config);

let userInfo: CreateSubscriberParamsData = {
	//Replace the values with your user info
	EMAIL: "[email protected]",
	FNAME: "Mikel",
	LNAME: "Calvo",
	CUSTOM: "yourCustomField"
};

subscribers
	.create({
        listUid: "YOUR-LIST-ID",
        data: userInfo,
    })
	.then(result => console.log("Subscriber created:", result))
	.catch(err => console.error("Error:", err));
CreateSubscriberResponse {
	status: string;
	data: CreateSubscriberResponseData;
}

CreateSubscriberResponseData {
	record: CreateSubscriberResponseRecord;
}

CreateSubscriberResponseRecord {
	subscriber_uid: string;
	email: string;
	ip_address: string;
	source: string;
	date_added: CreateSubscriberResponseRecordDateAdded;
}

CreateSubscriberResponseRecordDateAdded {
	expression: string;
	params: any;
}

Create Subscribers in Bulk

import { ListSubscribers } from "node-mailwizz";

const subscribers = new ListSubscribers(config);

subscribers
	.bulk({
		listUid: "YOUR-LIST-ID",
		subscribers: [
			{ EMAIL: "[email protected]", FNAME: "User", LNAME: "One" },
			{ EMAIL: "[email protected]", FNAME: "User", LNAME: "Two" },
			{ EMAIL: "[email protected]", FNAME: "User", LNAME: "Three" }
		]
	})
	.then(result => console.log("Bulk operation result:", result))
	.catch(err => console.error("Error:", err));
BulkSubscribersResponse {
	status: string;
	data: {
		records: BulkSubscriberRecord[];
	};
}

BulkSubscriberRecord {
	data: {
		subscriber_uid?: string;
		email: string;
		status?: string;
	};
}

Create or Update a Subscriber

Creates a new subscriber if the email doesn't exist, or updates the existing subscriber if it does (upsert operation).

import { ListSubscribers } from "node-mailwizz";

const subscribers = new ListSubscribers(config);

subscribers
	.createOrUpdate({
		listUid: "YOUR-LIST-ID",
		data: {
			EMAIL: "[email protected]",
			FNAME: "Mikel",
			LNAME: "Calvo"
		}
	})
	.then(result => console.log("Subscriber created/updated:", result))
	.catch(err => console.error("Error:", err));
CreateOrUpdateSubscriberResponse {
	status: string;
	data: {
		record: {
			subscriber_uid: string;
			email: string;
			ip_address: string;
			source: string;
			date_added: object;
		};
	};
}

Update a Subscriber

import { ListSubscribers } from "node-mailwizz";

const subscribers = new ListSubscribers(config);
// Similar to creating a subscriber, but with updated info

let updatedUserInfo: UpdateSubscriberParamsData = {
	//Replace the values with your user info
	EMAIL: "[email protected]",
	FNAME: "Mikel",
	LNAME: "Calvo",
	CUSTOM: "yourCustomField"
};

subscribers
	.update({
        listUid: "YOUR-LIST-ID",
        subscriberUid: "SUBSCRIBER-ID",
        data: updatedUserInfo,
    })
	.then(result => console.log("Subscriber updated:", result))
	.catch(err => console.error("Error:", err));
UpdateSubscriberResponse {
	status: string;
	data: UpdateSubscriberResponseData;
}

UpdateSubscriberResponseData {
    record: UpdateSubscriberResponseRecord;
}

UpdateSubscriberResponseRecord {
    subscriber_uid: string;
    email: string;
    ip_address: string;
    source: string;
    date_added: UpdateSubscriberResponseRecordDateAdded;
}

UpdateSubscriberResponseRecordDateAdded {
    expression: string;
    params: any;
}

Delete a Subscriber

import { ListSubscribers } from "node-mailwizz";

const subscribers = new ListSubscribers(config);

subscribers
	.delete({
		listUid: "YOUR-LIST-ID",
		subscriberUid: "SUBSCRIBER-ID"
	})
	.then(result => console.log("Subscriber deleted:", result))
	.catch(err => console.error("Error:", err));
DeleteSubscriberResponse {
	status: string;
}

Unsubscribe a Subscriber

import { ListSubscribers } from "node-mailwizz";

const subscribers = new ListSubscribers(config);

subscribers
	.unsubscribe({
		listUid: "YOUR-LIST-ID",
		subscriberUid: "SUBSCRIBER-ID"
	})
	.then(result => console.log("Subscriber unsubscribed:", result))
	.catch(err => console.error("Error:", err));
UnsubscribeSubscriberResponse {
    status: string;
}

Delete a Subscriber by Email

import { ListSubscribers } from "node-mailwizz";

const subscribers = new ListSubscribers(config);

subscribers
	.deleteByEmail({
		listUid: "YOUR-LIST-ID",
		email: "[email protected]"
	})
	.then(result => console.log("Subscriber deleted:", result))
	.catch(err => console.error("Error:", err));
DeleteByEmailResponse {
    status: string;
}

Unsubscribe by Email

import { ListSubscribers } from "node-mailwizz";

const subscribers = new ListSubscribers(config);

subscribers
	.unsubscribeByEmail({
		listUid: "YOUR-LIST-ID",
		email: "[email protected]"
	})
	.then(result => console.log("Subscriber unsubscribed:", result))
	.catch(err => console.error("Error:", err));
UnsubscribeByEmailResponse {
    status: string;
}

Unsubscribe from All Lists

import { ListSubscribers } from "node-mailwizz";

const subscribers = new ListSubscribers(config);

subscribers
	.unsubscribeByEmailFromAllLists({
		email: "[email protected]"
	})
	.then(result => console.log("Unsubscribed from all lists:", result))
	.catch(err => console.error("Error:", err));
UnsubscribeByEmailFromAllListsResponse {
    status: string;
}

Retrieve Subscribers

import { ListSubscribers } from "node-mailwizz";

const subscribers = new ListSubscribers(config);
// Get a paginated list of subscribers
subscribers
	.getSubscribers({
		listUid: "YOUR-LIST-ID",
		page: 1,
		per_page: 10
	})
	.then(result => console.log("Subscribers:", result))
	.catch(err => console.error("Error:", err));
GetSubscribersResponse {
	status: string;
	data: {
		count: string;
		total_pages: number;
		current_page: number;
		next_page: number;
		prev_page: number;
		records: GetSubscribersResponseRecord[];
	};
}

GetSubscribersResponseRecord {
	subscriber_uid: string;
	EMAIL: string;
	FNAME: string;
	LNAME: string;
	status: string;
	source: string;
	ip_address: string;
	date_added: string;
    [key: string]: any;
}

Fetch a Subscriber by ID

import { ListSubscribers } from "node-mailwizz";

const subscribers = new ListSubscribers(config);

subscribers
	.getSubscriber({
		listUid: "YOUR-LIST-ID",
		subscriberUid: "SUBSCRIBER-ID"
	})
	.then(result => console.log("Subscriber details:", result))
	.catch(err => console.error("Error:", err));
GetSubscriberResponse {
	status: string;
	data: GetSubscriberResponseData;
}

GetSubscriberResponseData {
	subscriber_uid: string;
	EMAIL: string;
	FNAME: string;
	LNAME: string;
	status: string;
	source: string;
	ip_address: string;
	date_added: string;
	[key: string]: any;
}

Find a Subscriber by Email

import { ListSubscribers } from "node-mailwizz";

const subscribers = new ListSubscribers(config);

subscribers
	.emailSearch({
		listUid: "YOUR-LIST-ID",
		subscriberEmail: "[email protected]"
	})
	.then(result => console.log("Subscriber found:", result))
	.catch(err => console.error("Error:", err));
EmailSearchResponse {
	status: string;
	data: EmailSearchResponseData;
}

EmailSearchResponseData {
	subscriber_uid: string;
	status: string;
	date_added: string;
}

Search by Email in All Lists

import { ListSubscribers } from "node-mailwizz";

const subscribers = new ListSubscribers(config);

subscribers
	.searchByEmailInAllLists({
		email: "[email protected]"
	})
	.then(result => console.log("Subscriber found in lists:", result))
	.catch(err => console.error("Error:", err));
SearchByEmailInAllListsResponse {
	status: string;
	data: {
		records: SearchByEmailInAllListsRecord[];
	};
}

SearchByEmailInAllListsRecord {
	subscriber_uid: string;
	list_uid: string;
	status: string;
	date_added: string;
}

Search by Custom Fields

import { ListSubscribers } from "node-mailwizz";

const subscribers = new ListSubscribers(config);

subscribers
	.searchByCustomFields({
		listUid: "YOUR-LIST-ID",
		fields: {
			FNAME: "Mikel",
			LNAME: "Calvo"
		}
	})
	.then(result => console.log("Subscribers found:", result))
	.catch(err => console.error("Error:", err));
SearchByCustomFieldsResponse {
	status: string;
	data: {
		records: SearchByCustomFieldsRecord[];
	};
}

SearchByCustomFieldsRecord {
	subscriber_uid: string;
	EMAIL: string;
	FNAME: string;
	LNAME: string;
	status: string;
	source: string;
	ip_address: string;
	date_added: string;
	[key: string]: any;
}

List API

Get Lists

import { Lists } from "node-mailwizz";

const lists = new Lists(config);

// Retrieve your lists with pagination
lists
	.getLists({
		page: 1,
		per_page: 10
	})
	.then(result => console.log("Lists:", result))
	.catch(err => console.error("Error:", err));
GetAllListsResponse {
	status: string;
	data: {
		count: string;
		total_pages: number;
		current_page: number;
		next_page: number;
		prev_page: number;
		records: GetAllListsResponseRecord[];
	};
}

GetAllListsResponseRecord {
	general: GetAllListsResponseRecordGeneral;
	defaults: GetAllListsResponseRecordDefaults;
	notifications: GetAllListsResponseRecordNotifications;
	company: GetAllListsResponseRecordCompany;
}

GetAllListsResponseRecordGeneral {
	list_uid: string;
	name: string;
	display_name: string;
	description: string;
}

GetAllListsResponseRecordDefaults {
	from_name: string;
	reply_to: string;
	subject: string;
}

GetAllListsResponseRecordNotifications {
	subscribe: string;
	unsubscribe: string;
	subscribe_to: string;
	unsubscribe_to: string;
}

GetAllListsResponseRecordCompany {
	name: string;
	address_1: string;
	address_2: string;
	zone_name: string;
	city: string;
	zip_code: string;
	phone: string;
	address_format: string;
	country: GetAllListsResponseRecordCompanyCountry;
}

GetAllListsResponseRecordCompanyCountry {
	country_id: string;
	name: string;
	code: string;
}

Get a Specific List

import { Lists } from "node-mailwizz";

const lists = new Lists(config);

lists
	.getList({
		listID: "YOUR-LIST-ID"
	})
	.then(result => console.log("List details:", result))
	.catch(err => console.error("Error:", err));
GetListResponse {
	status: string;
	data: {
		record: GetListResponseRecord;
	};
}

GetListResponseRecord {
	general: GetListResponseRecordGeneral;
	defaults: GetListResponseRecordDefaults;
	notifications: GetListResponseRecordNotifications;
	company: GetListResponseRecordCompany;
}

GetListResponseRecordGeneral {
	list_uid: string;
	name: string;
	display_name: string;
	description: string;
}

GetListResponseRecordDefaults {
	from_name: string;
	reply_to: string;
	subject: string;
}

GetListResponseRecordNotifications {
	subscribe: string;
	unsubscribe: string;
	subscribe_to: string;
	unsubscribe_to: string;
}

GetListResponseRecordCompany {
	name: string;
	address_1: string;
	address_2: string;
	zone_name: string;
	city: string;
	zip_code: string;
	phone: string;
	address_format: string;
	country: GetListResponseRecordCompanyCountry;
}

GetListResponseRecordCompanyCountry {
	country_id: string;
	name: string;
	code: string;
}

Create a New List

import { Lists } from "node-mailwizz";

const lists = new Lists(config);

lists
	.create({
		//Replace the values with your list info
		name: "Main List", //Required
		description: "This is a test list", //Required
		fromName: "Mikel Calvo", //Required
		fromEmail: "[email protected]", //Required
		replyTo: "[email protected]", //Required
		subject: "Hi!",
		//notification when new subscriber added
		notificationSubscribe: "yes", //yes or no
		notificationUnsubscribe: "yes", //yes or no
		//where to send the notification
		notificationSubscribeTo: "[email protected]",
		notificationUnsubscribeTo: "[email protected]",
		//This is optional, if not set customer company data will be used:
		companyName: "Mikel Calvo SL", //required
		companyCountry: "Spain", //required
		companyZone: "Basque Country", //required
		companyAddress1: "Some street address", //required
		companyAddress2: "",
		companyZoneName: "", //when country doesn't have required zone
		companyCity: "",
		companyZipCode: ""
	})
	.then(result => console.log("List created:", result))
	.catch(err => console.error("Error:", err));
CreateListResponse {
	status: string;
	list_uid: string;
}

Copy a List

import { Lists } from "node-mailwizz";

const lists = new Lists(config);

lists
	.copy({
		listID: "YOUR-LIST-ID"
	})
	.then(result => console.log("List copied:", result))
	.catch(err => console.error("Error:", err));
CopyListResponse {
    status: string;
    list_uid: string;
}

Remove a List

import { Lists } from "node-mailwizz";

const lists = new Lists(config);

lists
	.delete({
		listID: "YOUR-LIST-ID"
	})
	.then(result => console.log("List removed:", result))
	.catch(err => console.error("Error:", err));
DeleteListResponse {
	status: string;
}

Update a List

// Similar to creating a list, but with updated info
import { Lists } from "node-mailwizz";

const lists = new Lists(config);

lists
	.update({
        listID: "YOUR-LIST-ID",
        name: "Main List", //Required
        description: "This is a test list", //Required
        fromName: "Mikel Calvo", //Required
        fromEmail: "[email protected]", //Required
        replyTo: "[email protected]", //Required
        subject: "Hi!",
        //notification when new subscriber added
        notificationSubscribe: "yes", //yes or no
        notificationUnsubscribe: "yes", //yes or no
        //where to send the notification
        notificationSubscribeTo: "
        notificationUnsubscribeTo: "
        //This is optional, if not set customer company data will be used:
        companyName: "Mikel Calvo SL", //required
        companyCountry: "Spain", //required
        companyZone: "Basque Country", //required
        companyAddress1: "Some street address", //required
        companyAddress2: "",
        companyZoneName: "", //when country doesn't have required zone
        companyCity: "",
        companyZipCode: ""
    })
	.then(result => console.log("List updated:", result))
	.catch(err => console.error("Error:", err));
UpdateListResponse {
	status: string;
}

List Fields API

Get All Fields

import { ListFields } from "node-mailwizz";

const fields = new ListFields(config);

fields
	.getFields({
		listUid: "YOUR-LIST-ID"
	})
	.then(result => console.log("Fields:", result))
	.catch(err => console.error("Error:", err));
GetFieldsResponse {
	status: string;
	data: {
		records: FieldRecord[];
	};
}

FieldRecord {
	field_id: string;
	tag: string;
	label: string;
	type: string;
	required: string;
	visibility: string;
	sort_order: string;
}

Get a Field

import { ListFields } from "node-mailwizz";

const fields = new ListFields(config);

fields
	.getField({
		listUid: "YOUR-LIST-ID",
		fieldUid: "FIELD-UID"
	})
	.then(result => console.log("Field:", result))
	.catch(err => console.error("Error:", err));

Create a Field

import { ListFields } from "node-mailwizz";

const fields = new ListFields(config);

fields
	.create({
		listUid: "YOUR-LIST-ID",
		type: "text",
		label: "Company Name",
		tag: "COMPANY",
		required: "no",
		visibility: "visible",
		sortOrder: 0
	})
	.then(result => console.log("Field created:", result))
	.catch(err => console.error("Error:", err));
CreateFieldResponse {
	status: string;
	data: {
		record: FieldRecord;
	};
}

Update a Field

import { ListFields } from "node-mailwizz";

const fields = new ListFields(config);

fields
	.update({
		listUid: "YOUR-LIST-ID",
		fieldUid: "FIELD-UID",
		label: "Updated Company Name"
	})
	.then(result => console.log("Field updated:", result))
	.catch(err => console.error("Error:", err));

Delete a Field

import { ListFields } from "node-mailwizz";

const fields = new ListFields(config);

fields
	.delete({
		listUid: "YOUR-LIST-ID",
		fieldUid: "FIELD-UID"
	})
	.then(result => console.log("Field deleted:", result))
	.catch(err => console.error("Error:", err));

Get Field Types

import { ListFields } from "node-mailwizz";

const fields = new ListFields(config);

fields
	.getFieldTypes()
	.then(result => console.log("Field types:", result))
	.catch(err => console.error("Error:", err));
GetFieldTypesResponse {
	status: string;
	data: {
		records: string[];  // e.g., ["text", "dropdown", "multiselect", "date", "datetime", "textarea", "country", "state", "checkbox", "consent_checkbox", "radiolist", "checkboxlist", "phonenumber", "email", "url", "rating", "years_range", "captcha", "geocity"]
	};
}

List Segments API

Get All Segments

import { ListSegments } from "node-mailwizz";

const segments = new ListSegments(config);

segments
	.getSegments({
		listUid: "YOUR-LIST-ID",
		page: 1,
		per_page: 10
	})
	.then(result => console.log("Segments:", result))
	.catch(err => console.error("Error:", err));
GetSegmentsResponse {
	status: string;
	data: {
		count: string;
		total_pages: number;
		current_page: number;
		next_page: number;
		prev_page: number;
		records: SegmentRecord[];
	};
}

SegmentRecord {
	segment_uid: string;
	name: string;
	subscribers_count: number;
}

Get a Segment

import { ListSegments } from "node-mailwizz";

const segments = new ListSegments(config);

segments
	.getSegment({
		listUid: "YOUR-LIST-ID",
		segmentUid: "SEGMENT-UID"
	})
	.then(result => console.log("Segment:", result))
	.catch(err => console.error("Error:", err));

Get Segment Subscribers

import { ListSegments } from "node-mailwizz";

const segments = new ListSegments(config);

segments
	.getSubscribers({
		listUid: "YOUR-LIST-ID",
		segmentUid: "SEGMENT-UID",
		page: 1,
		per_page: 10
	})
	.then(result => console.log("Segment subscribers:", result))
	.catch(err => console.error("Error:", err));

Create a Segment

import { ListSegments } from "node-mailwizz";

const segments = new ListSegments(config);

segments
	.create({
		listUid: "YOUR-LIST-ID",
		name: "Active Users",
		operatorMatch: "all",
		conditions: [
			{
				field_id: "EMAIL",
				operator_id: "contains",
				value: "@gmail.com"
			}
		]
	})
	.then(result => console.log("Segment created:", result))
	.catch(err => console.error("Error:", err));
CreateSegmentResponse {
	status: string;
	data: {
		record: SegmentRecord;
	};
}

Update a Segment

import { ListSegments } from "node-mailwizz";

const segments = new ListSegments(config);

segments
	.update({
		listUid: "YOUR-LIST-ID",
		segmentUid: "SEGMENT-UID",
		name: "Updated Segment Name"
	})
	.then(result => console.log("Segment updated:", result))
	.catch(err => console.error("Error:", err));

Delete a Segment

import { ListSegments } from "node-mailwizz";

const segments = new ListSegments(config);

segments
	.delete({
		listUid: "YOUR-LIST-ID",
		segmentUid: "SEGMENT-UID"
	})
	.then(result => console.log("Segment deleted:", result))
	.catch(err => console.error("Error:", err));

Get Condition Operators

import { ListSegments } from "node-mailwizz";

const segments = new ListSegments(config);

segments
	.getConditionOperators()
	.then(result => console.log("Condition operators:", result))
	.catch(err => console.error("Error:", err));
GetConditionOperatorsResponse {
	status: string;
	data: {
		records: string[];  // e.g., ["is", "is_not", "contains", "not_contains", "starts_with", "ends_with", "greater_than", "less_than", "is_empty", "is_not_empty"]
	};
}

Transactional Emails API

Get All Transactional Emails

import { TransactionEmail } from "node-mailwizz";

const transactional = new TransactionEmail(config);

transactional
	.getAll({
		page: 1,
		per_page: 10
	})
	.then(result => console.log("Transactional emails:", result))
	.catch(err => console.error("Error:", err));
GetAllTransactionalEmailsResponse {
	status: string;
	data: {
		count: string;
		total_pages: number;
		current_page: number;
		next_page: number;
		prev_page: number;
		records: TransactionalEmailRecord[];
	};
}

TransactionalEmailRecord {
	email_uid: string;
	to_name: string;
	to_email: string;
	from_name: string;
	subject: string;
	status: string;
	date_added: string;
}

Get a Transactional Email

import { TransactionEmail } from "node-mailwizz";

const transactional = new TransactionEmail(config);

transactional
	.getOne({
		emailUid: "EMAIL-UID"
	})
	.then(result => console.log("Transactional email:", result))
	.catch(err => console.error("Error:", err));

Create a Transactional Email

import { TransactionEmail } from "node-mailwizz";

const transactional = new TransactionEmail(config);

transactional
	.create({
		toName: "Mikel Calvo",
		toEmail: "[email protected]",
		fromName: "My App",
		subject: "Welcome!",
		body: "<html><body><h1>Welcome to our service!</h1></body></html>",
		plainText: "Welcome to our service!",
		sendAt: "2024-01-01 10:00:00"
	})
	.then(result => console.log("Email queued:", result))
	.catch(err => console.error("Error:", err));
CreateTransactionalEmailResponse {
	status: string;
	email_uid: string;
}

Delete a Transactional Email

import { TransactionEmail } from "node-mailwizz";

const transactional = new TransactionEmail(config);

transactional
	.delete({
		emailUid: "EMAIL-UID"
	})
	.then(result => console.log("Email deleted:", result))
	.catch(err => console.error("Error:", err));

Countries API

Get All Countries

import { Countries } from "node-mailwizz";

const countriesClass = new Countries(config);

countriesClass
	.getAll({
		page: 1,
		per_page: 10
	})
	.then(countries => console.log("Countries:", countries))
	.catch(err => console.error("Error:", err));
GetAllCountriesResponse {
	status: string;
	data: {
		count: string;
		total_pages: number;
		current_page: number;
		next_page: number;
		prev_page: number;
		records: GetAllCountriesResponseRecord[];
	};
}

GetAllCountriesResponseRecord {
	country_id: string;
	name: string;
	code: string;
}

Get Zones of a Country

import { Countries } from "node-mailwizz";

const countriesClass = new Countries(config);

countriesClass
	.getAllZones({
		countryID: "ES",
		page: 1,
		per_page: 10
	})
	.then(zones => console.log("Zones:", zones))
	.catch(err => console.error("Error:", err));
GetAllZonesResponse {
	status: string;
	data: {
		count: string;
		total_pages: number;
		current_page: number;
		next_page: number;
		prev_page: number;
		records: GetAllZonesResponseRecord[];
	};
}

GetAllZonesResponseRecord {
    zone_id: string;
    name: string;
    code: string;
}

Customers API

Create a Customer

import { Customers } from "node-mailwizz";

const customers = new Customers(config);

customers
	.create({
		firstName: "Mikel",
		lastName: "Calvo",
		email: "[email protected]",
		password: "yourPassword123",
		timezone: "Europe/Madrid"
	})
	.then(result => console.log("Customer created:", result))
	.catch(err => console.error("Error:", err));
CreateCustomerResponse {
	status: string;
	customer_uid: string;
}

License

This project is licensed under the ISC License - see the LICENSE.md file for details