# Kontakte

> Kontaktinformationen abfragen und aktualisieren

- Seite: https://tbit.app/de/docs/api/contacts
- Basis-URL: `https://rest-api.tbit.app/v1`
- Authentifizierung: Header `X-API-Key` mit deinem Schlüssel in jeder Anfrage (die Beispiele lesen ihn aus der Umgebungsvariable `TBIT_API_KEY`)

## Überblick

Kontakte sind die Personen, die über Kanäle wie WhatsApp, Instagram und E-Mail mit deinem Agenten interagieren. Jeder Kontakt hat ein Profil mit Namen, Kanal-Kennungen und optionalen Metadaten.

## Endpoints

| Methode | Pfad | Beschreibung |
| --- | --- | --- |
| `GET` | `/v1/contacts` | Kontakte auflisten |
| `GET` | `/v1/contacts/:id` | Kontakt im Detail abrufen |
| `POST` | `/v1/contacts` | Neuen Kontakt erstellen |
| `PATCH` | `/v1/contacts/:id` | Kontakt aktualisieren |

## Query-Parameter

Der Listen-Endpoint unterstützt die folgenden Query-Parameter:

| Parameter | Typ | Beschreibung |
| --- | --- | --- |
| `limit` | `number` | Ergebnisse pro Seite (Standard: 20, max.: 100) |
| `offset` | `number` | Anzahl zu überspringender Ergebnisse (Standard: 0) |

## Kontakte auflisten

`GET /v1/contacts`

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

## Kontakt im Detail abrufen

`GET /v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1`

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

## Kontakt aktualisieren

`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"
  }'
```

## Kontakt erstellen

`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"
    }
  }'
```

## Antwortformat

Listen-Endpoints liefern paginierte Ergebnisse:

```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
  }
}
```
