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

# Etiketler

> Sohbetlerinizi ve kişilerinizi düzenlemek için WhatsApp Business etiketleri oluşturun ve yönetin.

# Etiketler

Etiketler, sohbetlerinizi kategorize etmenize ve d\u00fczenlemenize olanak tan\u0131yan bir WhatsApp Business \u00f6zelli\u011fidir. Wappfy API \u00fczerinden \u00f6zel etiketler olu\u015fturabilir, sohbetlere atayabilir ve etikete g\u00f6re sohbetleri alabilirsiniz.

<Note>
  Etiketler yaln\u0131zca WhatsApp Business hesaplar\u0131nda kullan\u0131labilir. Ki\u015fisel WhatsApp hesaplar\u0131 etiketleri desteklemez.
</Note>

T\u00fcm etiket ucu noktalar\u0131 belirli bir \u00f6rnekle s\u0131n\u0131rl\u0131d\u0131r:

```
/api/instances/{instanceId}/labels/...
```

***

## Etiket Olu\u015fturma

\u0130sim ve renk ile yeni bir etiket olu\u015fturun.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.io/api/instances/inst_abc123/labels \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "VIP Customer",
      "color": 1
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/labels",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        name: "VIP Customer",
        color: 1,
      }),
    }
  );

  const label = await response.json();
  console.log(label.data.id);
  ```
</CodeGroup>

**Yan\u0131t:**

```json theme={null}
{
  "data": {
    "id": "1",
    "name": "VIP Customer",
    "color": 1
  }
}
```

### Etiket Renkleri

WhatsApp Business, numara ile tan\u0131mlanan sabit bir etiket renk seti destekler:

| Renk Kimli\u011fi | Renk                         |
| ----------------- | ---------------------------- |
| `0`               | A\u00e7\u0131k gri           |
| `1`               | Ye\u015fil                   |
| `2`               | Mavi                         |
| `3`               | Sar\u0131                    |
| `4`               | Pembe/K\u0131rm\u0131z\u0131 |

***

## Etiketleri Listeleme

\u00d6rne\u011fin t\u00fcm etiketlerini al\u0131n.

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.wappfy.io/api/instances/inst_abc123/labels \
    -H "X-Api-Key: YOUR_API_KEY"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/labels",
    {
      headers: { "X-Api-Key": "YOUR_API_KEY" },
    }
  );

  const { data } = await response.json();
  data.forEach((label) => {
    console.log(`${label.id}: ${label.name} (color: ${label.color})`);
  });
  ```
</CodeGroup>

**Yan\u0131t:**

```json theme={null}
{
  "data": [
    { "id": "1", "name": "New Customer", "color": 0 },
    { "id": "2", "name": "VIP Customer", "color": 1 },
    { "id": "3", "name": "Pending Payment", "color": 3 },
    { "id": "4", "name": "Resolved", "color": 2 }
  ]
}
```

***

## Etiket G\u00fcncelleme

Mevcut bir etiketin ad\u0131n\u0131 veya rengini g\u00fcncelleyin.

```bash theme={null}
curl -X PUT https://api.wappfy.io/api/instances/inst_abc123/labels/2 \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Premium Customer",
    "color": 2
  }'
```

***

## Etiket Silme

Bir etiketi kal\u0131c\u0131 olarak silin. Bu i\u015flem, etiketin atand\u0131\u011f\u0131 t\u00fcm sohbetlerden de kald\u0131r\u0131r.

```bash theme={null}
curl -X DELETE https://api.wappfy.io/api/instances/inst_abc123/labels/2 \
  -H "X-Api-Key: YOUR_API_KEY"
```

<Warning>
  Bir etiketin silinmesi, etiketin ili\u015fkili t\u00fcm sohbetlerden kald\u0131r\u0131lmas\u0131na neden olur. Bu i\u015flem geri al\u0131namaz.
</Warning>

***

## Sohbet Etiketleri

### Bir Sohbetin Etiketlerini Alma

Belirli bir sohbete atanan t\u00fcm etiketleri al\u0131n.

```bash theme={null}
curl https://api.wappfy.io/api/instances/inst_abc123/labels/chats/5511999998888@s.whatsapp.net \
  -H "X-Api-Key: YOUR_API_KEY"
```

**Yan\u0131t:**

```json theme={null}
{
  "data": [
    { "id": "1", "name": "New Customer", "color": 0 },
    { "id": "3", "name": "Pending Payment", "color": 3 }
  ]
}
```

### Sohbete Etiket Atama

Bir sohbete bir veya daha fazla etiket atay\u0131n. Bu, sohbetteki mevcut etiketlerin yerine ge\u00e7er.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT https://api.wappfy.io/api/instances/inst_abc123/labels/chats/5511999998888@s.whatsapp.net \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "label_ids": ["1", "2"]
    }'
  ```

  ```javascript Node.js theme={null}
  await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/labels/chats/5511999998888@s.whatsapp.net",
    {
      method: "PUT",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        label_ids: ["1", "2"],
      }),
    }
  );
  ```
</CodeGroup>

<Tip>
  Bir sohbetteki t\u00fcm etiketleri kald\u0131rmak i\u00e7in bo\u015f bir dizi ge\u00e7irin: `{"label_ids": []}`.
</Tip>

### Etikete G\u00f6re Sohbetleri Alma

Belirli bir etiketin atand\u0131\u011f\u0131 t\u00fcm sohbetleri al\u0131n.

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.wappfy.io/api/instances/inst_abc123/labels/2/chats \
    -H "X-Api-Key: YOUR_API_KEY"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/labels/2/chats",
    {
      headers: { "X-Api-Key": "YOUR_API_KEY" },
    }
  );

  const { data } = await response.json();
  console.log(`${data.length} chats with the "VIP Customer" label`);
  ```
</CodeGroup>

**Yan\u0131t:**

```json theme={null}
{
  "data": [
    {
      "chat_id": "5511999998888@s.whatsapp.net",
      "name": "Maria Silva"
    },
    {
      "chat_id": "5511888887777@s.whatsapp.net",
      "name": "Carlos Oliveira"
    }
  ]
}
```

***

## Yayg\u0131n Kullan\u0131m Senaryolar\u0131

<AccordionGroup>
  <Accordion title="Yeni potansiyel m\u00fc\u015fterileri otomatik etiketleme">
    `message.received` olaylar\u0131n\u0131 dinlemek i\u00e7in bir webhook kullan\u0131n. Bilinmeyen bir ki\u015fiden mesaj geldi\u011finde, API \u00fczerinden "Yeni Potansiyel M\u00fc\u015fteri" etiketini atay\u0131n. Bu, ekibinizin yeni konu\u015fmalar\u0131 h\u0131zla tespit etmesine ve \u00f6nceliklendirmesine yard\u0131mc\u0131 olur.
  </Accordion>

  <Accordion title="Destek talebi durumunu takip etme">
    "A\u00e7\u0131k", "Devam Ediyor" ve "\u00c7\u00f6z\u00fcld\u00fc" gibi etiketler olu\u015fturun. Ekibiniz destek taleplerini i\u015fledik\u00e7e etiketi g\u00fcncelleyin. Basit bir destek kuyru\u011fu olu\u015fturmak i\u00e7in "Etikete G\u00f6re Sohbetleri Alma" ucu noktas\u0131n\u0131 kullan\u0131n.
  </Accordion>

  <Accordion title="Toplu mesajlar i\u00e7in m\u00fc\u015fterileri segmentleme">
    M\u00fc\u015fterileri kategoriye g\u00f6re etiketleyin (orn. "VIP", "Toptan", "Perakende"). Toplu mesaj g\u00f6nderirken, bir etiketin t\u00fcm sohbetlerini al\u0131n ve mesajlar\u0131 d\u00f6ng\u00fc ile g\u00f6nderin.
  </Accordion>
</AccordionGroup>

***

## Ucu Noktas\u0131 Referans\u0131

| Y\u00f6ntem | Ucu Noktas\u0131                             | A\u00e7\u0131klama              |
| ----------- | -------------------------------------------- | ------------------------------- |
| `POST`      | `/api/instances/{id}/labels`                 | Yeni etiket olu\u015ftur        |
| `GET`       | `/api/instances/{id}/labels`                 | T\u00fcm etiketleri listele     |
| `PUT`       | `/api/instances/{id}/labels/{labelId}`       | Etiket g\u00fcncelle            |
| `DELETE`    | `/api/instances/{id}/labels/{labelId}`       | Etiket sil                      |
| `GET`       | `/api/instances/{id}/labels/chats/{chatId}`  | Sohbetin etiketlerini al        |
| `PUT`       | `/api/instances/{id}/labels/chats/{chatId}`  | Sohbete etiket ata              |
| `GET`       | `/api/instances/{id}/labels/{labelId}/chats` | Etikete g\u00f6re sohbetleri al |

***

## Hata Y\u00f6netimi

| Durum Kodu | A\u00e7\u0131klama                                     |
| ---------- | ------------------------------------------------------ |
| `400`      | Ge\u00e7ersiz etiket rengi veya eksik zorunlu alanlar. |
| `404`      | Etiket veya sohbet bulunamad\u0131.                    |
| `409`      | Ayn\u0131 isimde bir etiket zaten mevcut.              |
| `422`      | Ge\u00e7ersiz sohbet kimli\u011fi format\u0131.        |
