# Personal Contacts Synchronization

The process for synchronizing personal contacts is as follows:

1. Client gets a sync token from the server by sending a POST request to /api/user/contacts/sync\_tokens.
2. Server reports token 001.
3. Some time passes.
4. Client performs a sync operation by sending a POST request to /api/user/contacts/sync\_tokens/{token}, supplying token 001.
5. Server returns contacts that have been created, updated, or deleted and returns token 002.

#### Getting the First Sync Token

Initially, request a sync token for contacts:

```shell
curl -X POST 'https://HOSTNAME:PORT/api/user/contacts/sync_tokens'
```

This would return something like the following:

```json
{
  "token": "001"
}
```

#### Receiving Changes

After a sync token has been obtained, the client can request all changes since the token was issued. This is done with a request that may look like this:

```shell
curl -X POST 'https://HOSTNAME:PORT/api/user/contacts/sync_tokens/001'
```

This would return something like the following:

```json
{
  "token": "002",
  "items": [
    {
      "id": "CREATED-ITEM-ID",
      "name": "...",
      "email": "...",
      "company": "...",
      "title": "...",
      "business": "...",
      "business2": "...",
      "mobile_phone": "...",
      "mobile_phone2": "...",
      "home_phone": "...",
      "home_phone2": "...",
      "other": "...",
      "business_fax": "...",
      "home_fax": "...",
      "address": "...",
      "notes": "...",
      "favorite": "...",
      "change_type": "CREATED"
    },
    {
      "id": "UPDATED-ITEM-ID",
      "name": "...",
      "email": "...",
      "company": "...",
      "title": "...",
      "business": "...",
      "business2": "...",
      "mobile_phone": "...",
      "mobile_phone2": "...",
      "home_phone": "...",
      "home_phone2": "...",
      "other": "...",
      "business_fax": "...",
      "home_fax": "...",
      "address": "...",
      "notes": "...",
      "favorite": "...",
      "change_type": "UPDATED"
    },
    {
      "id": "DELETED-ITEM-ID",
      "name": "...",
      "email": "...",
      "company": "...",
      "title": "...",
      "business": "...",
      "business2": "...",
      "mobile_phone": "...",
      "mobile_phone2": "...",
      "home_phone": "...",
      "home_phone2": "...",
      "other": "...",
      "business_fax": "...",
      "home_fax": "...",
      "address": "...",
      "notes": "...",
      "favorite": "...",
      "change_type": "DELETED"
    }
  ]
}
```
