<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ContactZapp</title>
    <description>The latest articles on DEV Community by ContactZapp (@contactzapp).</description>
    <link>https://dev.to/contactzapp</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4278500%2F42430da9-3fa1-445f-8014-eef56af979d7.png</url>
      <title>DEV Community: ContactZapp</title>
      <link>https://dev.to/contactzapp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/contactzapp"/>
    <language>en</language>
    <item>
      <title>Syncing contacts across Google, Microsoft, iCloud and CardDAV: what breaks</title>
      <dc:creator>ContactZapp</dc:creator>
      <pubDate>Wed, 02 Dec 2026 12:49:03 +0000</pubDate>
      <link>https://dev.to/contactzapp/syncing-contacts-across-google-microsoft-icloud-and-carddav-what-breaks-193i</link>
      <guid>https://dev.to/contactzapp/syncing-contacts-across-google-microsoft-icloud-and-carddav-what-breaks-193i</guid>
      <description>&lt;p&gt;If you read contacts from one service, the API is easy to learn. If you write the same contact to four services and keep them equal, the differences start to cost you time.&lt;/p&gt;

&lt;p&gt;We build ContactZapp, a web app that syncs contacts between Google, Microsoft, Apple and CardDAV. This post is a list of the behaviours that surprised us, in the order a sync meets them. Most of them are not in the documentation. We found them by running against live accounts. Nothing here needs our product, and you can use the list to check your own sync code.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short version
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Google (People API)&lt;/th&gt;
&lt;th&gt;Microsoft (Graph)&lt;/th&gt;
&lt;th&gt;iCloud&lt;/th&gt;
&lt;th&gt;Other CardDAV&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Sign-in&lt;/td&gt;
&lt;td&gt;OAuth&lt;/td&gt;
&lt;td&gt;OAuth&lt;/td&gt;
&lt;td&gt;App-specific password&lt;/td&gt;
&lt;td&gt;Server login (Basic auth in our case)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What changed?&lt;/td&gt;
&lt;td&gt;&lt;code&gt;syncToken&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;delta&lt;/code&gt; link&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sync-collection&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;sync-collection&lt;/code&gt;, or a full listing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Version check&lt;/td&gt;
&lt;td&gt;&lt;code&gt;etag&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;changeKey&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ETag&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ETag&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Batch writes&lt;/td&gt;
&lt;td&gt;Yes, all-or-nothing&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;$batch&lt;/code&gt;, failures per member&lt;/td&gt;
&lt;td&gt;One request per card&lt;/td&gt;
&lt;td&gt;One request per card&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Labels&lt;/td&gt;
&lt;td&gt;Contact groups&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;categories&lt;/code&gt; text&lt;/td&gt;
&lt;td&gt;Group cards&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;CATEGORIES&lt;/code&gt; on the card&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The rest of the post explains the cells that cost us the most.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. A change token expires, and each service says so differently
&lt;/h2&gt;

&lt;p&gt;All four services let you ask "what changed since last time". All four also stop honouring the token at some point, and you must handle that or the sync stops quietly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Google&lt;/strong&gt; returns HTTP 400, not 410, with status &lt;code&gt;FAILED_PRECONDITION&lt;/code&gt; and an error reason of &lt;code&gt;EXPIRED_SYNC_TOKEN&lt;/code&gt;. The token lives for about 300 hours. A client that only looks for 410 keeps sending the dead token, and the account stops syncing without an error you would notice. A garbled token gives a different 400, &lt;code&gt;INVALID_ARGUMENT&lt;/code&gt;, with no details. Treat the two differently: only the first one means "list everything again".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Microsoft&lt;/strong&gt; returns 410 when the stored &lt;code&gt;@odata.deltaLink&lt;/code&gt; is no longer valid. You then start a new delta and read every contact again. One more thing on delta: without the header &lt;code&gt;Prefer: odata.maxpagesize=512&lt;/code&gt;, Graph returns 10 contacts per page. With 573 contacts we measured 58 requests without the header and 2 with it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CardDAV&lt;/strong&gt; is defined by RFC 6578, which says a rejected token is a 403. A server we tested, Purelymail, sends a 400 with &lt;code&gt;valid-sync-token&lt;/code&gt; in the error body instead. Servers that do not advertise &lt;code&gt;sync-collection&lt;/code&gt; at all need a full listing, and your code needs that path anyway.&lt;/p&gt;

&lt;p&gt;In all three cases, the recovery is the same: drop the token and list everything. Decide which status codes mean that before you ship, and do not match on the error text.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Deleted contacts do not look like deleted contacts
&lt;/h2&gt;

&lt;p&gt;Microsoft marks a removed contact in the delta feed with &lt;code&gt;@removed&lt;/code&gt;. The entry has no data, and a GET on it returns 404, so you cannot look up what it was. Keep your own copy of the contact's ID and name if you need to show the person what was deleted.&lt;/p&gt;

&lt;p&gt;CardDAV reports a deleted card inside &lt;code&gt;sync-collection&lt;/code&gt; as a response entry with a 404 status and no &lt;code&gt;propstat&lt;/code&gt;. A client that only reads entries with properties skips it. We lost deletions this way until we read the 404 entries too.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Writes that check the version
&lt;/h2&gt;

&lt;p&gt;Every service gives you a version value so a write fails if someone changed the contact in between. They behave differently, and two of them move the version when you did not expect it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Google&lt;/strong&gt; takes the &lt;code&gt;etag&lt;/code&gt; in the PATCH body. A stale &lt;code&gt;etag&lt;/code&gt; gives 400 or 409. The surprise is &lt;code&gt;batchUpdateContacts&lt;/code&gt;: it is all-or-nothing. One stale &lt;code&gt;etag&lt;/code&gt; in a batch of 30 rejects all 30 with a 400 &lt;code&gt;FAILED_PRECONDITION&lt;/code&gt;. We now read the contacts again with &lt;code&gt;people:batchGet&lt;/code&gt; and send the ones that did not move. We also keep the batch at 30, below the API limit, so that one stale contact costs less.&lt;/p&gt;

&lt;p&gt;On Google, adding a contact to a group or setting its photo changes the &lt;code&gt;etag&lt;/code&gt; after your PATCH. The PATCH response then holds a stale value, so read the contact again before the next write.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Microsoft&lt;/strong&gt; takes &lt;code&gt;If-Match: &amp;lt;changeKey&amp;gt;&lt;/code&gt;. Inside &lt;code&gt;$batch&lt;/code&gt;, a stale &lt;code&gt;changeKey&lt;/code&gt; fails only that member, and the others apply. A photo &lt;code&gt;PUT&lt;/code&gt; changes the &lt;code&gt;changeKey&lt;/code&gt;, so the one in your PATCH response is already old. Before we added a read after each photo write, 13 of 24 members of a second delivery failed with 412.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CardDAV&lt;/strong&gt; honours &lt;code&gt;If-Match&lt;/code&gt; on &lt;code&gt;PUT&lt;/code&gt;, and a stale value gives 412. It does not on &lt;code&gt;DELETE&lt;/code&gt; for iCloud. A &lt;code&gt;DELETE&lt;/code&gt; with a stale &lt;code&gt;If-Match&lt;/code&gt; returns 2xx and removes a card that was edited elsewhere. If your sync deletes cards, read the card first and decide in your code. Purelymail answers a stale-&lt;code&gt;If-Match&lt;/code&gt; &lt;code&gt;DELETE&lt;/code&gt; of an already-removed card with 412, not 404, so treat both as "already gone".&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Identity: the ID is not enough
&lt;/h2&gt;

&lt;p&gt;Google gives each contact a &lt;code&gt;resourceName&lt;/code&gt; such as &lt;code&gt;people/c123&lt;/code&gt;. Microsoft gives an &lt;code&gt;id&lt;/code&gt;. CardDAV gives a URL and a &lt;code&gt;UID&lt;/code&gt; inside the vCard. To link the same person across services, you need your own marker on each copy.&lt;/p&gt;

&lt;p&gt;We store ours in a custom field on each service: &lt;code&gt;userDefined&lt;/code&gt; on Google, and a named extended property on Microsoft. Google's &lt;code&gt;userDefined&lt;/code&gt; list is replaced as a whole when you write it, so a push that does not read it first deletes the other entries.&lt;/p&gt;

&lt;p&gt;For CardDAV, make the card's URL a function of your own ID, and create it with &lt;code&gt;If-None-Match: *&lt;/code&gt;. If a create times out and you retry, a 412 tells you the first attempt landed. We used random file names at first. After a timeout, we then needed a listing of the whole address book to find the card, and on a book of about 40,000 cards that listing could not be answered in time.&lt;/p&gt;

&lt;p&gt;Keep the &lt;code&gt;UID&lt;/code&gt; of a card you did not create. When we rewrote a foreign card's &lt;code&gt;UID&lt;/code&gt; on iCloud, the server refused the write with a 403 and a &lt;code&gt;no-uid-conflict&lt;/code&gt; error.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Limits that are not in the documentation
&lt;/h2&gt;

&lt;p&gt;The numbers below are what we measured on live accounts in 2026. Check them again before you rely on them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Google.&lt;/strong&gt; The documented quota is 90 requests a minute per user. A write also uses some of the read quota, about 1.15 read units per update. A batch call costs about 7 units of each quota no matter how many contacts it holds, and a &lt;code&gt;batchDeleteContacts&lt;/code&gt; call costs about 10 write units for 50 names or for 500. Batch your deletes, and pace your updates below 90.&lt;/p&gt;

&lt;p&gt;A contact is refused whole if one value is too long, if it holds 500 or more values, or if it is over about 128 KB. A nickname of 1,025 characters failed and 1,024 worked. The status code is 429 with "FBS quota limit exceeded", which is also what you get when the account is full at 25,000 contacts. If you read every 429 on create as "the account is full", you will tell people the wrong thing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Microsoft.&lt;/strong&gt; Graph has a documented limit of 10,000 requests per 10 minutes per mailbox. It also limits the number of requests in flight to 4 per mailbox, and each &lt;code&gt;$batch&lt;/code&gt; member counts as one. The &lt;code&gt;$batch&lt;/code&gt; call takes at most 20 requests, and Graph throttles members of a batch one by one.&lt;/p&gt;

&lt;p&gt;Outlook contacts have caps the API does not say: 3 email addresses, 2 business phones, 3 IM addresses and 255 characters for a category name. Going over any of them gives a 400 for the whole write, not a trimmed value. If you sync from a service with more fields, you must decide what to drop before you send.&lt;/p&gt;

&lt;p&gt;The delta feed also cuts free-text fields to 255 characters with no flag. That includes notes, nickname, job title, company and every part of an address. The single-contact GET returns the full text, so read again before you decide that a note changed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;iCloud.&lt;/strong&gt; A card over 560,000 bytes is refused with a 403 and the text "Incoming vcard size is more than the expected size". A 403 looks like a login problem, so look at the text. At 50,000 cards, a create returns 507 "quota count exceeded", which reads like a full disk. We saw 503 responses at 60 writes a minute on some runs, and 360 a minute on others. We pace at 120 and halve the rate on a 429 or a 503.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Other CardDAV.&lt;/strong&gt; One server answered at over 2,000 writes a minute without an error. Another may need a slower start. Start slow, speed up while the server answers and halve the rate on a refusal. A &lt;code&gt;multiget&lt;/code&gt; report is also all-or-nothing, so keep it small. One of ours blocked a sync loop for 8.5 minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. The same field in four shapes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Labels.&lt;/strong&gt; Google uses contact groups, and you change membership with a separate call, not in the contact PATCH. Microsoft uses plain &lt;code&gt;categories&lt;/code&gt; strings on the contact, and you do not need to create the category first. Apple does not write &lt;code&gt;CATEGORIES&lt;/code&gt;. It stores a group as its own card, with &lt;code&gt;KIND:group&lt;/code&gt; and a list of member &lt;code&gt;UID&lt;/code&gt;s, and editing a group means an &lt;code&gt;If-Match&lt;/code&gt; PUT of that card. A server such as Purelymail uses &lt;code&gt;CATEGORIES&lt;/code&gt; on the card. A sync that moves labels has to translate between three models.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Photos.&lt;/strong&gt; Google has a separate &lt;code&gt;updateContactPhoto&lt;/code&gt; call and serves the photo from a public URL. It also returns a generated initials picture when a contact has none, which you have to filter out or you will copy it to the other services. Microsoft has a &lt;code&gt;/photo&lt;/code&gt; endpoint that you write with &lt;code&gt;PUT&lt;/code&gt;. CardDAV puts the photo inside the vCard.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;vCard versions.&lt;/strong&gt; On CardDAV, a &lt;code&gt;multiget&lt;/code&gt; without a version attribute can return vCard 3.0, which drops &lt;code&gt;KIND&lt;/code&gt; and &lt;code&gt;MEMBER&lt;/code&gt;. Ask for the version you need. Some servers also flatten address parts into one field when you write a card back, so compare what you read with what you wrote.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we would tell ourselves at the start
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;List the status codes that mean "token expired" for each service, and test them on a real account that is a few weeks old.&lt;/li&gt;
&lt;li&gt;Treat a version value as stale after you write a photo or a label.&lt;/li&gt;
&lt;li&gt;Do not trust a batch to fail one member at a time. Only Microsoft's does.&lt;/li&gt;
&lt;li&gt;Read the whole contact again before you compare free-text fields from Microsoft's delta.&lt;/li&gt;
&lt;li&gt;Put a limit table in your code, per service, and drop or shorten a field before the server refuses the whole contact.&lt;/li&gt;
&lt;li&gt;Keep your own ID on every copy, and make CardDAV URLs from it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We wrote this because each of these cost us days, and the documentation did not warn us. Have you hit one of these, or a different one, in your own sync? Leave a question or your own war story in the comments and we will answer.&lt;/p&gt;

&lt;p&gt;Disclosure: we make ContactZapp, and this post comes from that work. The list above holds for any contact sync you build. If you would rather not run it yourself, ContactZapp does it for your own accounts: &lt;a href="https://contactz.app" rel="noopener noreferrer"&gt;contactz.app&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>tutorial</category>
      <category>data</category>
    </item>
  </channel>
</rss>
