> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sahut.id/llms.txt
> Use this file to discover all available pages before exploring further.

# Contacts API — Create, Update, and Sync Customer Profiles

> REST API endpoints to create, retrieve, update, and search contact profiles in Sahut. Use to sync customer data from your CRM or external systems.

The Contacts API lets you manage customer profiles in Sahut. Use it to sync contacts from your CRM, update contact details when customers change their info, or search for contacts before creating a new conversation.

## List contacts

```
GET /contacts
```

### Query parameters

<ParamField query="q" type="string">
  Search query. Matches against name, phone number, and email.
</ParamField>

<ParamField query="tag" type="string">
  Filter contacts by tag name.
</ParamField>

<ParamField query="page" type="integer">
  Page number. Default: `1`.
</ParamField>

<ParamField query="per_page" type="integer">
  Results per page. Default: `25`. Max: `100`.
</ParamField>

### Example request

```bash theme={null}
curl "https://api.sahut.id/v1/contacts?q=budi&per_page=5" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

### Example response

```json theme={null}
{
  "data": [
    {
      "id": "ct_01HX3C0L4N6P8Q",
      "name": "Budi Santoso",
      "email": "budi@example.com",
      "phone": "+628123456789",
      "company": "PT Contoh Indonesia",
      "tags": ["vip", "reseller"],
      "created_at": "2024-01-10T10:00:00Z"
    }
  ],
  "meta": {
    "total": 1,
    "page": 1,
    "per_page": 5,
    "total_pages": 1
  }
}
```

## Get a contact

```
GET /contacts/{id}
```

<ParamField path="id" type="string" required>
  Contact ID.
</ParamField>

## Create a contact

```
POST /contacts
```

### Request body

<ParamField body="name" type="string" required>
  Contact's full name.
</ParamField>

<ParamField body="phone" type="string">
  Phone number in E.164 format (e.g., `+628123456789`).
</ParamField>

<ParamField body="email" type="string">
  Email address.
</ParamField>

<ParamField body="company" type="string">
  Company name.
</ParamField>

<ParamField body="tags" type="array">
  Array of tag strings to apply (e.g., `["vip", "prospect"]`).
</ParamField>

<ParamField body="custom_attributes" type="object">
  Key-value pairs for any custom attributes defined in your workspace.
</ParamField>

### Example request

```bash theme={null}
curl -X POST https://api.sahut.id/v1/contacts \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Siti Rahma",
    "phone": "+628987654321",
    "email": "siti@example.com",
    "tags": ["prospect"],
    "custom_attributes": {
      "customer_tier": "silver"
    }
  }'
```

### Example response

```json theme={null}
{
  "data": {
    "id": "ct_01HX4D1M5O7Q9R",
    "name": "Siti Rahma",
    "phone": "+628987654321",
    "email": "siti@example.com",
    "company": null,
    "tags": ["prospect"],
    "custom_attributes": {
      "customer_tier": "silver"
    },
    "created_at": "2024-03-15T10:00:00Z"
  }
}
```

## Update a contact

```
PUT /contacts/{id}
```

<ParamField path="id" type="string" required>
  Contact ID to update.
</ParamField>

The request body accepts the same fields as `POST /contacts`. Only include the fields you want to update — omitted fields remain unchanged.

### Example request

```bash theme={null}
curl -X PUT https://api.sahut.id/v1/contacts/ct_01HX3C0L4N6P8Q \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "company": "PT Baru Indonesia",
    "tags": ["vip", "reseller", "platinum"]
  }'
```
