1. Features
  2. Contacts
Contacts

Every address book, behind one contacts API.

Google People, Microsoft 365 and CardDAV contacts in one searchable index, written back to the provider, with an event for every change.

contacts.tscontacts.py
// 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"}],
)
What you get

Address books you can rely on.

The same contact model, calls and events on Google, Microsoft 365 and IMAP servers with CardDAV.

One contact model

Names, typed emails and phones, organization, job title, department, birthday, notes and photo.

Search from the index

Case-insensitive matches on any name, organization or email, in cursor pages that never wait on the provider.

Folders and address books

Microsoft 365 contact folders and CardDAV address books, to filter by and create in.

Read your writes

Creates, updates and deletes reach the provider and the index in the same call; null clears a field.

Contact photos

Fetched on first request, then cached encrypted until the photo changes.

An event for every change

One contacts.initialized after the first pass, then contact.* events.

Off until you turn it on

contactsEnabled per tenant or account; sign-ins ask for access only when it's on and your plan includes contacts.

Shared and organization mailboxes

Microsoft 365 shared mailboxes, app-only Microsoft accounts and Google Workspace delegation.

Efficient by design

Sync tokens, deltas and etags read only changes; an expired token re-reads and diffs.

Build it

Work with folders and address books.

Folders list with the default first; filter by one or create a contact in it.

  • Microsoft 365 folders include every subfolder of Contacts, read on every pass.
  • CardDAV address books are folders; one that refuses access or disappears is skipped for that pass.
  • Google has no contact folders; naming one on create answers provider_unsupported.
  • A new contact needs a name, organization, email or phone so it can be found again.
folders.tsfolders.py
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)
Build it

Mirror an address book into your app.

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.
  • Your own writes are in the index when the call returns.
  • Signed deliveries, filterable by event type and account, with replays and an ordered change feed.

Read the webhooks guide

contacts-webhook.tscontacts-webhook.py
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)
Build it

Photos without hammering the provider.

The photo route asks the provider only on a cache miss or after the photo changed.

  • Cached per contact after the first request, encrypted in object storage, and deleted with the contact or account; without object storage every request goes to the provider.
  • Safe to show: JPEG, PNG, GIF, WebP and BMP are served inline with a sandboxing Content-Security-Policy, anything else as application/octet-stream.
  • No photo answers 404 photo_not_found, so skip the call when hasPhotohas_photo is false.
photo.tsphoto.py
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"}],
)
Reference and FAQ

The details, when you need them.

Per-provider details
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.
Which accounts get contacts

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).
Contact events

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
Why do Google contact changes take longer to arrive?

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.

Are Google contact labels synced?

No. A contact belongs to at most one folder, and Google has none, so Google contacts carry a null folderId.

What happens when someone edits the same contact elsewhere?

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.

Does turning on contacts need a new sign-in?

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.

Bring every address book into your product.

Workwae is in early access. Tell us what you are building, and read the docs in the meantime.