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.
from mailglyph import MailGlyph
client = MailGlyph("sk_your_secret_key")
Use cursor pagination for large lists:
page1 = client.contacts.list(
limit=50,
subscribed=True,
search="john",
)
print(len(page1.data), page1.has_more, page1.cursor)
Fetch the next page with cursor:
if page1.has_more and page1.cursor:
page2 = client.contacts.list(
limit=50,
cursor=page1.cursor,
)
print(len(page2.data))
created = client.contacts.create(
email="user@example.com",
subscribed=True,
data={"firstName": "John", "plan": "premium"},
)
print(created.id, created.meta.is_new if created.meta else None)
contact = client.contacts.get(created.id)
print(contact.email, contact.subscribed)
updated = client.contacts.update(
created.id,
subscribed=False,
data={"plan": "pro"},
)
print(updated.subscribed, updated.data)
subscribed_count = client.contacts.count(subscribed=True)
search_count = client.contacts.count(search="john")
print(subscribed_count, search_count)
client.contacts.delete(created.id)
Async equivalents
from mailglyph import AsyncMailGlyph
async def run() -> None:
async with AsyncMailGlyph("sk_your_secret_key") as client:
page = await client.contacts.list(limit=20)
created = await client.contacts.create(email="new@example.com", data={"source": "sdk"})
fetched = await client.contacts.get(created.id)
updated = await client.contacts.update(fetched.id, subscribed=False)
total = await client.contacts.count(subscribed=False)
await client.contacts.delete(updated.id)
print(total)
See full details in the Contacts API reference.