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 Python SDK.
from mailglyph import MailGlyph client = MailGlyph("sk_your_secret_key")
contacts.list
page1 = client.contacts.list( limit=50, subscribed=True, search="john", ) print(len(page1.data), page1.has_more, page1.cursor)
cursor
if page1.has_more and page1.cursor: page2 = client.contacts.list( limit=50, cursor=page1.cursor, ) print(len(page2.data))
contacts.create
created = client.contacts.create( email="[email protected]", subscribed=True, data={"firstName": "John", "plan": "premium"}, ) print(created.id, created.meta.is_new if created.meta else None)
contacts.get
contact = client.contacts.get(created.id) print(contact.email, contact.subscribed)
contacts.update
updated = client.contacts.update( created.id, subscribed=False, data={"plan": "pro"}, ) print(updated.subscribed, updated.data)
contacts.count
subscribed_count = client.contacts.count(subscribed=True) search_count = client.contacts.count(search="john") print(subscribed_count, search_count)
contacts.delete
client.contacts.delete(created.id)
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="[email protected]", 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)