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, list, update, count, and delete contacts with the MailGlyph Node.js SDK.
import MailGlyph from 'mailglyph'; const client = new MailGlyph(process.env.MAILGLYPH_SECRET_KEY as string);
contacts.list
const page1 = await client.contacts.list({ limit: 50, subscribed: true, search: 'john' }); console.log(page1.data.length, page1.hasMore, page1.cursor);
cursor
if (page1.hasMore && page1.cursor) { const page2 = await client.contacts.list({ limit: 50, cursor: page1.cursor }); console.log(page2.data.length); }
contacts.create
const created = await client.contacts.create({ email: '[email protected]', subscribed: true, data: { firstName: 'John', plan: 'premium' } }); console.log(created.id, created._meta?.isNew, created._meta?.isUpdate);
contacts.get
const contact = await client.contacts.get(created.id); console.log(contact.email, contact.subscribed);
contacts.update
const updated = await client.contacts.update(created.id, { subscribed: false, data: { plan: 'pro' } }); console.log(updated.subscribed, updated.data);
contacts.count
const subscribedCount = await client.contacts.count({ subscribed: true }); console.log(subscribedCount);
contacts.delete
await client.contacts.delete(created.id);