One contact model
Names, typed emails and phones, organization, job title, department, birthday, notes and photo.
Google People, Microsoft 365 and CardDAV contacts in one searchable index, written back to the provider, with an event for every change.
// Opt-in: for the tenant, or for one account
await workwae.accounts.update({
accountId,
settings: { contactsEnabled: true },
});
// Part of a name, organization or address
const { items } = await workwae.contacts.list({
accountId,
q: "acme",
});
// Written to the provider, then listed at once
await workwae.contacts.update({
accountId,
contactId: items[0].id,
jobTitle: "VP Operations",
phones: [{ number: "+1 713 555 0142" }],
});# Opt-in: for the tenant, or for one account
workwae.accounts.update(
account_id=account_id,
settings={"contacts_enabled": True},
)
# Part of a name, organization or address
items = workwae.contacts.list(
account_id=account_id,
q="acme",
).items
# Written to the provider, then listed at once
workwae.contacts.update(
account_id=account_id,
contact_id=items[0].id,
job_title="VP Operations",
phones=[{"number": "+1 713 555 0142"}],
)The same contact model, calls and events on Google, Microsoft 365 and IMAP servers with CardDAV.
Names, typed emails and phones, organization, job title, department, birthday, notes and photo.
Case-insensitive matches on any name, organization or email, in cursor pages that never wait on the provider.
Microsoft 365 contact folders and CardDAV address books, to filter by and create in.
Creates, updates and deletes reach the provider and the index in the same call; null clears a field.
Fetched on first request, then cached encrypted until the photo changes.
One contacts.initialized after the first pass, then contact.* events.
contactsEnabled per tenant or account; sign-ins ask for access only when it's on and your plan includes contacts.
Microsoft 365 shared mailboxes, app-only Microsoft accounts and Google Workspace delegation.
Sync tokens, deltas and etags read only changes; an expired token re-reads and diffs.
Folders list with the default first; filter by one or create a contact in it.
provider_unsupported.
import { paginate } from "@workwae/sdk";
const { items } = await workwae.contactFolders.list({ accountId });
const vendors = items.find((f) => f.name === "Vendors");
// Into that folder, or the default one when folderId is omitted
const contact = await workwae.contacts.create({
accountId,
folderId: vendors?.id,
givenName: "Sam",
familyName: "Okafor",
emails: [{ address: "sam@globex.example", type: "work" }],
organization: "Globex",
birthday: "--04-17",
});
// Every contact in one folder, page by page
for await (const c of paginate(workwae.contacts.list, {
accountId,
folderId: vendors?.id,
})) {
console.log(c.displayName, c.emails, c.phones);
}from workwae import paginate
folders = workwae.contact_folders.list(account_id=account_id).items
vendors = next(f for f in folders if f.name == "Vendors")
# Into that folder, or the default one when folder_id is omitted
contact = workwae.contacts.create(
account_id=account_id,
folder_id=vendors.id,
given_name="Sam",
family_name="Okafor",
emails=[{"address": "sam@globex.example", "type": "work"}],
organization="Globex",
birthday="--04-17",
)
# Every contact in one folder, page by page
for c in paginate(
workwae.contacts.list,
account_id=account_id,
folder_id=vendors.id,
):
print(c.display_name, c.emails, c.phones)
Load everything after contacts.initialized, then apply each
contact.* event, which carries the whole contact.
contact.updated lists changed fields in changes,
including photo when only the picture changed.
contact.deleted carries the contactIdcontact_id and its
folder.
import { paginate, parseWebhook } from "@workwae/sdk";
const event = await parseWebhook(secret, request.headers, body);
if (!event.known) return;
switch (event.type) {
case "contacts.initialized":
// data.contacts is a count: page through the contacts
for await (const c of paginate(workwae.contacts.list, {
accountId: event.accountId,
})) {
await upsertPerson(event.accountId, c);
}
break;
case "contact.created":
case "contact.updated":
await upsertPerson(event.accountId, event.data.contact);
if (
event.type === "contact.updated" &&
event.data.changes.includes("photo")
) {
await refreshAvatar(event.data.contact.id);
}
break;
case "contact.deleted":
await removePerson(event.accountId, event.data.contactId);
break;
}from workwae import UnknownEvent, paginate, parse_webhook
event = parse_webhook(secret, request.headers, body)
if isinstance(event, UnknownEvent):
return
if event.type == "contacts.initialized":
# data.contacts is a count: page through the contacts
for c in paginate(workwae.contacts.list, account_id=event.account_id):
upsert_person(event.account_id, c)
elif event.type == "contact.created" or event.type == "contact.updated":
upsert_person(event.account_id, event.data.contact)
if event.type == "contact.updated" and "photo" in event.data.changes:
refresh_avatar(event.data.contact.id)
elif event.type == "contact.deleted":
remove_person(event.account_id, event.data.contact_id)The photo route asks the provider only on a cache miss or after the photo changed.
application/octet-stream.
photo_not_found, so skip the call when
hasPhotohas_photo is false.
const ref = { accountId, contactId };
const contact = await workwae.contacts.get(ref);
// null on Microsoft 365: Graph only says by serving it
if (contact.hasPhoto !== false) {
const photo = await workwae.contacts.photo(ref);
const data = await photo.arrayBuffer();
await saveAvatar(contactId, photo.type, data);
}
// null clears a field; emails and phones replace the whole list
await workwae.contacts.update({
accountId,
contactId,
nickname: null,
emails: [{ address: "sam.okafor@globex.example" }],
});contact = workwae.contacts.get(account_id=account_id, contact_id=contact_id)
# None on Microsoft 365: Graph only says by serving it
if contact.has_photo is not False:
photo = workwae.contacts.photo(account_id=account_id, contact_id=contact_id)
save_avatar(contact_id, photo.content_type, photo.content)
# None clears a field; emails and phones replace the whole list
workwae.contacts.update(
account_id=account_id,
contact_id=contact_id,
nickname=None,
emails=[{"address": "sam.okafor@globex.example"}],
)| Aspect | Google People | Microsoft 365 | CardDAV |
|---|---|---|---|
| What syncs | The account's contacts (people/me/connections). | The default Contacts folder and every folder below it. | Every address book in the home set, found from the provider table, /.well-known/carddav or DNS SRV. |
| Finding changes | connections.list with a sync token; an expired one (about a week) re-reads and diffs. | A delta per folder; a move between folders is one update. | sync-collection (RFC 6578) or ctag and etag; 50 changed cards per read. |
| Push | None; Google has no contacts push. | A Graph subscription on the mailbox's contacts. | None; CardDAV has no push. |
| Polling | Daily, since People requests are billed, plus a pass after every API write. | A backstop every 10 minutes with push, every minute without. | Every 15 minutes, plus a pass after every API write. |
| Folders | None; folderId is null. | The folder tree; new contacts go to the default unless you name one. | Address books; the default is the first in URL order and stays so as books are added. |
| Limits and quirks | Birthdays may lack a year (--MM-DD). | At most 3 emails, one mobile and no "other" number, else provider_unsupported; email types are null. | Writes change only named fields with If-Match; another client's edit is merged up to three times before a 409. |
| Photos | hasPhoto from the sync; Google's placeholders don't count. | hasPhoto is null; Graph only says by serving the photo. | From the vCard's PHOTO. |
| Access needed | https://www.googleapis.com/auth/contacts | Contacts.ReadWrite, or Contacts.ReadWrite.Shared for shared mailboxes. | The IMAP password or a separate DAV password. |
Contacts follow the account however it was connected; a grant without contacts access reports a contacts sync error while mail keeps syncing.
| Personal sign-ins | Google and Microsoft accounts through hosted or headless OAuth, with contacts on for the account at sign-in. |
|---|---|
| Microsoft 365 shared mailboxes | Contacts when the user's grant carries Contacts.ReadWrite.Shared; otherwise created with contacts off. |
| Microsoft admin consent | Organization connections need the application permission Contacts.ReadWrite; the contacts error says when it's missing. |
| Google Workspace delegation | Off until you turn contacts on and the Workspace admin authorizes the contacts scope for the key. |
| IMAP with CardDAV | DAV settings, added or found by hosted connect, turn contacts on unless account settings say otherwise; no DAV settings, no contacts. |
| Refusals | Contacts off: contacts_disabled (409). Contacts module turned off for the workspace: plan_module_unavailable (403). |
Signed webhooks and change feed items, in the same envelope as every other event.
| Event | When | Data |
|---|---|---|
contacts.initialized | The first contacts sync finished; nothing before it is announced contact by contact. | contacts: how many were indexed |
contact.created | A contact appeared, at the provider or through the API. | contact |
contact.updated | A contact changed or moved folder. | contact, changes |
contact.deleted | A contact went away. | contactId, folderId |
Google has no contacts push and bills People API requests, so Workwae reads Google contacts daily. Your own writes are indexed at once and also trigger a pass.
No. A contact belongs to at most one folder, and Google has none, so Google contacts carry a
null folderId.
On CardDAV, Workwae reapplies your named fields to the newer version up to three times
before answering with a conflict. Either way, the next sync brings the other edit in as a
contact.updated.
Yes, unless contacts were on when the user connected; until they reconnect, the account reports a contacts sync error while mail keeps working. CardDAV uses the stored login, so IMAP accounts need nothing more.
People records in step with reps' address books.
Candidate threads and interviews in your ATS.
Who someone is, before the agent drafts a reply.
Sync, search and send from the same accounts.
Calendars, recurring series and free/busy.
Whole domains and shared mailboxes without a sign-in per user.
Workwae is in early access. Tell us what you are building, and read the docs in the meantime.