Documentation Index
Fetch the complete documentation index at: https://docs.mailglyph.com/llms.txt
Use this file to discover all available pages before exploring further.
Use a secret key client for contacts methods.
import MailGlyph from 'mailglyph';
const client = new MailGlyph(process.env.MAILGLYPH_SECRET_KEY as string);
Use cursor pagination for large lists:
const page1 = await client.contacts.list({
limit: 50,
subscribed: true,
search: 'john'
});
console.log(page1.data.length, page1.hasMore, page1.cursor);
Fetch the next page with cursor:
if (page1.hasMore && page1.cursor) {
const page2 = await client.contacts.list({
limit: 50,
cursor: page1.cursor
});
console.log(page2.data.length);
}
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);
const contact = await client.contacts.get(created.id);
console.log(contact.email, contact.subscribed);
const updated = await client.contacts.update(created.id, {
subscribed: false,
data: {
plan: 'pro'
}
});
console.log(updated.subscribed, updated.data);
const subscribedCount = await client.contacts.count({ subscribed: true });
console.log(subscribedCount);
await client.contacts.delete(created.id);
See full details in the Contacts API reference.