# Aboneler API Referansı

Source: https://instatus.com/help/tr/api/subscribers

## Aboneleri getirin

**Uç nokta:**

```bash
GET /v2/:page_id/subscribers?page=:page&per_page=:per_page&search=:search_query&status=:status
```

- Varsayılan sayfa numarası 1'dir.
- Varsayılan per_page değeri 50'dir; sayfa başına en fazla 100 öğedir.
- İsteğe bağlı arama sorgusu, aboneleri e-posta adresine veya telefon numarasına göre filtrelemek için kullanılır.
- İsteğe bağlı `status`, aboneleri abonelik durumuna göre filtreler. Henüz doğrulama yapmamış olanları dışarıda bırakmak için `status=confirmed` kullanın.

| Değer | Döndürülen aboneler |
| --- | --- |
| `confirmed` | Bildirim alan doğrulanmış aboneler. |
| `unconfirmed` | Onaylanmış ancak aboneliğini henüz doğrulamamış aboneler. |
| `unapproved` | Onay bekleyen aboneler, örneğin içe aktarılan listeler. |

**Örnek yanıt**

```json
[
  {
    "id": "cm1111x6ofgsd5666mzxcw978qh",
    "email": "ali@instatus.com",
    "phone": null,
    "webhook": null,
    "webhookEmail": null,
    "confirmed": false,
    "approved": true,
    "all": true,
    "components": []
  },
  {
    "id": "cm1111x6ofgsd5666mzxcw978qh",
    "email": null,
    "phone": "5417543010",
    "webhook": null,
    "webhookEmail": null,
    "confirmed": false,
    "approved": true,
    "all": true,
    "components": []
  }
]
```

## Abone ekleyin

**Uç nokta:**

```bash
POST /v1/:page_id/subscribers
```

Biri abone olduğunda doğrulama davranışı, sayfanın `subscriberConfirmationMode` ayarını izler. Bu davranışı tek bir abone için geçersiz kılmak amacıyla bu uç noktada `autoConfirm` kullanın.

**Örnek istek**

```json
{
  "email": "sarah@instatus.com",
  "all": true,
  "autoConfirm": false
}
```

- `autoConfirm` — isteğe bağlı. `true` olduğunda, sayfa ayarından bağımsız olarak aboneyi doğrulama veya karşılama e-postası göndermeden hemen ekler. Yalnızca Pro.

**Örnek yanıt**

```json
{
  "id": "cm1111x6ofgsd5666mzxcw978df",
  "name": null,
  "email": "sarahs@instatus.com",
  "phone": null,
  "confirmed": false,
  "all": true,
  "createdAt": "2024-10-01T03:48:41.474Z",
  "updatedAt": "2024-10-01T03:48:41.474Z",
  "siteId": "cm1111x6ofgsd5666mzxcw978qh",
  "unsubscribeToken": "e3b51de6-1234-4664-zxyv-1679gg524260",
  "webhook": null,
  "webhookEmail": null,
  "discord": null,
  "discordTeam": null,
  "slack": null,
  "slackTeam": null,
  "language": "en",
  "company": null,
  "microsoftTeamsWebhook": null,
  "googleChatWebhook": null,
  "googleChatSpace": null,
  "failedAttempts": 0,
  "approved": true,
  "importedFrom": null,
  "hideUnsubLink": false,
  "webhookIncidentBody": null,
  "webhookMaintenanceBody": null,
  "webhookComponentBody": null,
  "webhookHttpMethod": "POST",
  "webhookHeaders": null,
  "site": {
    "id": "cm1111x6ofgsd5666mzxcw978qh"
  }
}
```

### Belirli bileşenlere abone olun

**Örnek istek**

```json
{
  "email": "adam@instatus.com",
  "all": false,
  "components": ["cl2xv23rl0119e7jlk2mweepd"],
  "autoConfirm": false
}
```

**Örnek yanıt**

```json
{
  "id": "cl09gt11151422bjluflghewx",
  "email": "adam@instatus.com",
  "site": {
    "id": "ckg8a112344s5v86wrn",
    "name": "Test",
    "logoUrl": null,
    "subdomain": "test",
    "publicEmail": null,
    "language": "en"
  }
}
```

## Birden fazla abone ekleyin

**Uç nokta:**

```bash
POST /v1/:page_id/subscribers/bulk
```

Bu uç nokta, tek bir istekte birden fazla abone oluşturmanızı sağlar.

**Örnek istek**

```json
{
  "subscribers": [
    {
      "email": "sarah@instatus.com",
      "all": true
    },
    {
      "email": "john@instatus.com",
      "components": ["cl2xv23rl0119e7jlk2mweepd"]
    },
    {
      "name": "Jane Doe",
      "phone": "5417543010",
      "all": true
    }
  ],
  "autoConfirm": false
}
```

- `autoConfirm`, gruptaki her aboneye uygulanır. Yalnızca Pro.

**Örnek yanıt**

```json
{
  "success": true,
  "created": 3,
  "failed": 0,
  "results": {
    "created": [
      {
        "id": "cm1111x6ofgsd5666mzxcw978df",
        "email": "sarah@instatus.com",
        "phone": null,
        "confirmed": false,
        "all": true,
        "site": {
          "id": "cm1111x6ofgsd5666mzxcw978qh"
        }
      },
      {
        "id": "cm2222x6ofgsd5666mzxcw978df",
        "email": "john@instatus.com",
        "phone": null,
        "confirmed": false,
        "all": false,
        "site": {
          "id": "cm1111x6ofgsd5666mzxcw978qh"
        }
      },
      {
        "id": "cm3333x6ofgsd5666mzxcw978df",
        "email": null,
        "phone": "5417543010",
        "name": "Jane Doe",
        "confirmed": false,
        "all": true,
        "site": {
          "id": "cm1111x6ofgsd5666mzxcw978qh"
        }
      }
    ],
    "failed": []
  }
}
```

**Bazı aboneler eklenemediğinde yanıt**

Bazı aboneler oluşturulamazsa (örneğin mükerrer e-posta, hatalı biçim), yanıt bu hatalara dair ayrıntıları içerir:

```json
{
  "success": false,
  "created": 2,
  "failed": 1,
  "results": {
    "created": [
      {
        "id": "cm1111x6ofgsd5666mzxcw978df",
        "email": "sarah@instatus.com",
        "site": {
          "id": "cm1111x6ofgsd5666mzxcw978qh"
        }
      },
      {
        "id": "cm2222x6ofgsd5666mzxcw978df",
        "email": "john@instatus.com",
        "site": {
          "id": "cm1111x6ofgsd5666mzxcw978qh"
        }
      }
    ],
    "failed": [
      {
        "index": 2,
        "subscriber": {
          "email": "duplicate@instatus.com",
          "all": true
        },
        "error": {
          "code": "creation_failed",
          "message": "Subscriber with this email already exists"
        }
      }
    ]
  }
}
```

**Notlar:**

- İstek başına en fazla 100 abone
- Her abone nesnesi, tekil abone uç noktasıyla aynı alanları içerebilir
- Kısmi başarı desteklenir; bazıları başarısız olsa bile başarıyla oluşturulan aboneler döndürülür

## Doğrulama davranışı

Durum sayfaları, yeni abonelerin nasıl ele alınacağını [Durum sayfasını güncelleyin](https://instatus.com/help/tr/api/status-pages) uç noktasındaki `subscriberConfirmationMode` ile denetler:

| Değer | Davranış |
| --- | --- |
| `REQUIRED` | Aboneler güncellemeleri almadan önce e-posta ile doğrulama yapmalıdır. Varsayılan. |
| `WELCOME` | Aboneler hemen eklenir ve bir karşılama e-postası alır. Yalnızca Pro. |
| `NONE` | Aboneler e-posta gönderilmeden hemen eklenir. Yalnızca Pro. |

Oluşturma uç noktalarındaki `autoConfirm` parametresi, o istek için sayfa ayarını geçersiz kılar ve `NONE` gibi davranır.

## Aboneyi kaldırın

**Uç nokta:**

```bash
DELETE /v1/:page_id/subscribers/:subscriber_id
```

**Örnek yanıt**

```json
{
  "id": "cm1zvzm3434dlp9255d6jgy8",
  "name": null,
  "email": "sarah@instatus.com",
  "phone": null,
  "webhook": null,
  "webhookEmail": null,
  "discord": null,
  "microsoftTeamsWebhook": null,
  "company": null,
  "site": {
    "id": "cm180slpo000g9343478qh"
  }
}
```
