Sync API

and proper tests