> For the complete documentation index, see [llms.txt](https://docs.taptalk.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-server-api/contact.md).

# Contact

{% hint style="warning" %}
**IMPORTANT!**

**Server Key ID** and **Server Key Secret** will be used to construct a request and add as a **HTTP Header**.\
To construct a request, please format your generated **Server Key ID** and **Server Key Secret** and wrap it to **Base64**, so the format will be like this:

**encodeToBase64(SERVER\_KEY\_ID:SERVER\_KEY\_SECRET)**\
\*don't forget to add colon (:) between Server Key ID and Server Key Secret

Then, put the base64 string on your **HTTP Header Field** with **key “Server-Key”** and then construct URL request and parameter for the request.
{% endhint %}

### Sync Contacts

Update and/or delete contacts.

Note that contact works one-way. A user may add another user to his/her contact list without requiring the added user to do the same in return. It works just like how a contact/phone book should.

{% hint style="warning" %}
**IMPORTANT!**

Contact deletion always run the last. If the contact list contains duplicate owner-contact pairs with one's isDeleted set to true, then that record will always be deleted.
{% endhint %}

{% tabs %}
{% tab title="POST" %}

```php
BASE_URL/v1/server/contact/sync

example:
https://taptalk.io/v1/server/contact/sync
```

{% endtab %}
{% endtabs %}

### Request

| **Field**       | **Type** | **Description**                                                |
| --------------- | -------- | -------------------------------------------------------------- |
| contacts        | string   | (101) The list of contacts to be synced.                       |
| ownerXCUserID   | string   | (102) The XC user ID who owns the contact.                     |
| contactXCUserID | string   | (103) The contact's XC user ID.                                |
| isDeleted       | string   | (104) If the contact is to be deleted, may be omited if false. |

{% tabs %}
{% tab title="Request Example" %}

```javascript
{
    "contacts": [
        {
            "ownerXCUserID": "1",
            "contactXCUserID": "2"
        },
        {
            "ownerXCUserID": "1",
            "contactXCUserID": "6",
            "isDeleted": false
        },
        {
            "ownerXCUserID": "1",
            "contactXCUserID": "9",
            "isDeleted": true
        },
        {
            "ownerXCUserID": "6",
            "contactXCUserID": "1",
            "isDeleted": false
        }
    ]
}
```

{% endtab %}
{% endtabs %}

### Success 200

| **Field**     | **Type** | **Description**                  |
| ------------- | -------- | -------------------------------- |
| countInserted | long     | Number of contact rows inserted. |
| countDeleted  | long     | Number of contact rows deleted.  |

{% tabs %}
{% tab title="Success Response" %}

```javascript
{
  "status": 200,
  "error": {
    "code": "",
    "message": "",
    "field": ""
  },
  "data": {
    "countInserted": 3,
    "countDeleted": 1
  }
}
```

{% endtab %}
{% endtabs %}

### Error 4xx

| **Name**               | **Description**                       |
| ---------------------- | ------------------------------------- |
| ParamValidationFailed  | The parameter validation failed.      |
| HeaderValidationFailed | The request header validation failed. |

{% tabs %}
{% tab title="ParamValidationFailed" %}

```javascript
{
  "status": 400,
  "error": {
    "code": "40002",
    "message": "Param 'contacts' cannot be empty",
    "field": "101"
  },
  "data": {}
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="HeaderValidationFailed" %}

```javascript
{
  "status": 400,
  "error": {
    "code": "40001",
    "message": "Request headers are required (Server-Key)",
    "field": ""
  },
  "data": {}
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-server-api/contact.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
