# Contacts

> Retrieve and update contact information

- Page: https://tbit.app/docs/api/contacts
- Base URL: `https://rest-api.tbit.app/v1`
- Authentication: `X-API-Key` header with your key on every request (the examples read it from the `TBIT_API_KEY` environment variable)

## Overview

Contacts represent the people who interact with your agent across channels such as WhatsApp, Instagram, and email. Each contact has a profile with name, channel identifiers, and optional metadata.

## Endpoints

| Method | Path | Description |
| --- | --- | --- |
| `GET` | `/v1/contacts` | List contacts |
| `GET` | `/v1/contacts/:id` | Get contact detail |
| `POST` | `/v1/contacts` | Create a new contact |
| `PATCH` | `/v1/contacts/:id` | Update contact |

## Query Parameters

The list endpoint supports the following query parameters:

| Parameter | Type | Description |
| --- | --- | --- |
| `limit` | `number` | Results per page (default: 20, max: 100) |
| `offset` | `number` | Number of results to skip (default: 0) |

## List Contacts

`GET /v1/contacts`

```bash
curl "https://rest-api.tbit.app/v1/contacts?limit=20&offset=0" \
  -H "X-API-Key: $TBIT_API_KEY"
```

## Get Contact Detail

`GET /v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1`

```bash
curl "https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1" \
  -H "X-API-Key: $TBIT_API_KEY"
```

## Update Contact

`PATCH /v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1`

```bash
curl -X PATCH "https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1" \
  -H "X-API-Key: $TBIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "profile_name": "Jane Doe",
    "email": "jane@example.com",
    "notes": "Preferred language: English"
  }'
```

## Create Contact

`POST /v1/contacts`

```bash
curl -X POST "https://rest-api.tbit.app/v1/contacts" \
  -H "X-API-Key: $TBIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "channel_id": "573009876543",
    "channel_type": "whatsapp",
    "profile_name": "Jane Doe",
    "custom_attributes": {
      "city": "Bogota",
      "plan": "premium"
    }
  }'
```

## Response Format

List endpoints return paginated results:

```json
{
  "data": [
    {
      "id": "64f1a2b3c4d5e6f7a8b9c0d1",
      "profile_name": "Jane Doe",
      "email": "jane@example.com",
      "notes": "Preferred language: English",
      "channels": [
        {
          "channel_id": "573001234567",
          "channel_type": "whatsapp"
        }
      ],
      "custom_attributes": {
        "city": "Bogota",
        "plan": "premium"
      },
      "created_at": "2024-09-01T12:00:00Z",
      "updated_at": "2024-09-01T14:30:00Z"
    }
  ],
  "pagination": {
    "total": 50,
    "limit": 20,
    "offset": 0,
    "has_more": true
  }
}
```
