Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Create, send, test, and analyze campaigns with the MailGlyph Node.js SDK.
import MailGlyph from 'mailglyph'; const client = new MailGlyph(process.env.MAILGLYPH_SECRET_KEY as string);
campaigns.list
const page = await client.campaigns.list({ page: 1, pageSize: 20, status: 'DRAFT' }); console.log(page.total, page.totalPages, page.data.length);
campaigns.create
const campaignAll = await client.campaigns.create({ name: 'Launch campaign', subject: 'Introducing our new feature', body: '<h1>Big news</h1><p>Check out what is new.</p>', from: '[email protected]', audienceType: 'ALL' }); console.log(campaignAll.id, campaignAll.status);
const campaignFiltered = await client.campaigns.create({ name: 'Subscribed users campaign', subject: 'Feature update', body: '<p>Only subscribed users receive this.</p>', from: '[email protected]', audienceType: 'FILTERED', audienceCondition: { logic: 'AND', groups: [ { filters: [{ field: 'subscribed', operator: 'equals', value: true }] } ] } }); console.log(campaignFiltered.id);
const campaignSegment = await client.campaigns.create({ name: 'Segment campaign', subject: 'Offer for premium users', body: '<p>This goes to one saved segment.</p>', from: '[email protected]', audienceType: 'SEGMENT', segmentId: 'seg_123' }); console.log(campaignSegment.id);
campaigns.get
const campaign = await client.campaigns.get(campaignAll.id); console.log(campaign.name, campaign.status);
campaigns.update
const updated = await client.campaigns.update(campaignAll.id, { subject: 'Updated subject line', replyTo: '[email protected]' }); console.log(updated.subject, updated.replyTo);
campaigns.send
const sendResult = await client.campaigns.send(campaignAll.id); console.log(sendResult.success, sendResult.message);
scheduledFor
const scheduledResult = await client.campaigns.send(campaignAll.id, { scheduledFor: '2026-03-01T10:00:00Z' }); console.log(scheduledResult.success, scheduledResult.message);
campaigns.test
const testResult = await client.campaigns.test(campaignAll.id, '[email protected]'); console.log(testResult.success, testResult.message);
campaigns.stats
const stats = await client.campaigns.stats(campaignAll.id); console.log(stats.success, stats.data);
campaigns.cancel
const cancelled = await client.campaigns.cancel(campaignAll.id); console.log(cancelled.success, cancelled.message);